Package net.jini.core.constraint
Class ConstraintAlternatives
java.lang.Object
net.jini.core.constraint.ConstraintAlternatives
- All Implemented Interfaces:
Serializable,InvocationConstraint,RelativeTimeConstraint
public final class ConstraintAlternatives
extends Object
implements RelativeTimeConstraint, Serializable
Combines two or more constraint alternatives into a single overall constraint. The semantics of
this aggregate constraint are that at least one of the individual constraint alternatives must be
satisfied. The alternatives do not have to be instances of the same type, but they cannot
themselves be
ConstraintAlternatives instances. Note that this class implements
RelativeTimeConstraint even though the constraint elements might not implement
RelativeTimeConstraint.
An instance containing an exhaustive list of
alternatives (for example, an instance containing both ClientAuthentication.YES and
ClientAuthentication.NO) serves no useful purpose, as a requirement or as a
preference. A don't care condition should be expressed by the absence of
constraints.
- Since:
- 2.0
- Author:
- Sun Microsystems, Inc.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates an instance containing the specified alternative constraints, with duplicate constraints removed.ConstraintAlternatives(InvocationConstraint[] constraints) Creates an instance containing the specified alternative constraints, with duplicate constraints removed. -
Method Summary
Modifier and TypeMethodDescriptionstatic InvocationConstraintcreate(Collection c) Returns a constraint representing the specified alternative constraints, with duplicate constraints removed.static InvocationConstraintcreate(InvocationConstraint[] constraints) Returns a constraint representing the specified alternative constraints, with duplicate constraints removed.elements()Returns an immutable set of all of the constraints.booleanTwo instances of this class are equal if they have the same constraints (ignoring order).inthashCode()Returns a hash code value for this object.makeAbsolute(long baseTime) Returns a constraint equal to the result of taking the constraints in this instance, replacing each constraint that is an instance ofRelativeTimeConstraintwith the result of invoking that constraint'smakeAbsolutemethod with the specified base time, and invoking thecreatemethod of this class with the revised collection of constraints.toString()Returns a string representation of this object.
-
Constructor Details
-
ConstraintAlternatives
Creates an instance containing the specified alternative constraints, with duplicate constraints removed. The argument passed to this constructor is neither modified nor retained; subsequent changes to that argument have no effect on the instance created.- Parameters:
constraints- the alternative constraints- Throws:
NullPointerException- if the argument isnullor any element isnullIllegalArgumentException- if any of the elements are instances ofConstraintAlternatives, or if fewer than two elements remain after duplicate constraints are removed
-
ConstraintAlternatives
Creates an instance containing the specified alternative constraints, with duplicate constraints removed. The argument passed to this constructor is neither modified nor retained; subsequent changes to that argument have no effect on the instance created.- Parameters:
c- the alternative constraints- Throws:
NullPointerException- if the argument isnullor any element isnullIllegalArgumentException- if any of the elements are instances ofConstraintAlternatives, or if the elements are not all instances ofInvocationConstraint, or if fewer than two elements remain after duplicate constraints are removed
-
-
Method Details
-
create
Returns a constraint representing the specified alternative constraints, with duplicate constraints removed. If a single constraint remains after duplicates are removed, then that constraint is returned, otherwise an instance ofConstraintAlternativescontaining the remaining constraints is returned. The argument passed to this method is neither modified nor retained; subsequent changes to that argument have no effect on the instance created.- Parameters:
constraints- the alternative constraints- Returns:
- a constraint representing the specified alternative constraints, with duplicate constraints removed
- Throws:
NullPointerException- if the argument isnullor any element isnullIllegalArgumentException- if the argument is empty, or if any of the elements are instances ofConstraintAlternatives
-
create
Returns a constraint representing the specified alternative constraints, with duplicate constraints removed. If a single constraint remains after duplicates are removed, then that constraint is returned, otherwise an instance ofConstraintAlternativescontaining the remaining constraints is returned. The argument passed to this method is neither modified nor retained; subsequent changes to that argument have no effect on the instance created.- Parameters:
c- the alternative constraints- Returns:
- a constraint representing the specified alternative constraints, with duplicate constraints removed
- Throws:
NullPointerException- if the argument isnullor any element isnullIllegalArgumentException- if the argument is empty, or if any of the elements are instances ofConstraintAlternatives, or if the elements are not all instances ofInvocationConstraint
-
elements
Returns an immutable set of all of the constraints. Any attempt to modify this set results in anUnsupportedOperationExceptionbeing thrown.- Returns:
- an immutable set of all of the constraints
-
makeAbsolute
Returns a constraint equal to the result of taking the constraints in this instance, replacing each constraint that is an instance ofRelativeTimeConstraintwith the result of invoking that constraint'smakeAbsolutemethod with the specified base time, and invoking thecreatemethod of this class with the revised collection of constraints.- Specified by:
makeAbsolutein interfaceRelativeTimeConstraint- Parameters:
baseTime- an absolute time, specified in milliseconds from midnight, January 1, 1970 UTC- Returns:
- a constraint that has the relative times converted to absolute times by adding the specified absolute time to each relative time
-
hashCode
public int hashCode()Returns a hash code value for this object. -
equals
Two instances of this class are equal if they have the same constraints (ignoring order). -
toString
Returns a string representation of this object.
-