com.sun.jini.discovery
Class DiscoveryConstraints.ConstraintReducer
java.lang.Object
com.sun.jini.discovery.DiscoveryConstraints.ConstraintReducer
- Direct Known Subclasses:
- DiscoveryConstraints.MaxValueReducer
- Enclosing class:
- DiscoveryConstraints
private static class DiscoveryConstraints.ConstraintReducer
- extends Object
Utility for reducing constraints of a given type into a base set of
alternatives. For each type of constraints that it reduces, this class
makes the simplifying assumption that failure to reduce constraints of
that type into a single (perhaps one element) set of alternatives
represents a constraint conflict--i.e., that two disjoint instances of
the constraint type cannot be applied to the same operation. While this
restriction does not hold across all possible constraints, it is
satisfied by the particular constraint types that DiscoveryConstraints
handles.
If this utility encounters a set of alternatives containing instances of
both the type to reduce as well as other constraint types, then it
ignores the instances of the other types, treating the set as if it can
only be satisfied by the alternatives of the targeted type. This may in
some cases cause false positives when detecting conflicts in constraints
containing alternatives of mixed type; however, it should never result
in false negatives.
Method Summary |
private Set |
getTargetInstances(Set set)
|
(package private) Set |
reduce(InvocationConstraints constraints)
Returns the reduction of the given constraints into a single set of
alternatives for the target class. |
private Set |
reduce(Set reduced,
Set constraints,
boolean required)
|
(package private) Set |
reduce0(Set reduced,
Set toReduce)
Returns the reduction (intersection and compaction) of a new set of
alternative constraints, all instances of the target class, with a
previously reduced set (null if no other constraints have been
reduced yet). |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
targetClass
private final Class targetClass
DiscoveryConstraints.ConstraintReducer
DiscoveryConstraints.ConstraintReducer(Class targetClass)
- Creates reducer that operates on instances of the given constraint
class.
reduce
Set reduce(InvocationConstraints constraints)
throws UnsupportedConstraintException
- Returns the reduction of the given constraints into a single set of
alternatives for the target class. Returns an empty set if no
constraints of the target class are specified. Throws
UnsupportedConstraintException if the constraints conflict.
- Throws:
UnsupportedConstraintException
reduce0
Set reduce0(Set reduced,
Set toReduce)
- Returns the reduction (intersection and compaction) of a new set of
alternative constraints, all instances of the target class, with a
previously reduced set (null if no other constraints have been
reduced yet). Returns an empty set if elements in the sets
conflict. This method can be overridden by subclasses for
constraints with particular reduction semantics; the default
implementation of this method returns the intersection of the two
sets.
reduce
private Set reduce(Set reduced,
Set constraints,
boolean required)
throws UnsupportedConstraintException
- Throws:
UnsupportedConstraintException
getTargetInstances
private Set getTargetInstances(Set set)
Copyright 2007-2010, multiple authors.
Licensed under the Apache License, Version 2.0, see the NOTICE file for attributions.