Package net.jini.core.constraint
Class InvocationConstraints
java.lang.Object
net.jini.core.constraint.InvocationConstraints
- All Implemented Interfaces:
Serializable
An immutable aggregation of constraints into a set of requirements and a set of preferences. A
requirement is a mandatory constraint that must be satisfied for the invocation. A preference is
a desired constraint, to be satisfied if possible, but it will not be satisfied if it conflicts
with a requirement. If two preferences conflict, it is arbitrary as to which one will be
satisfied. If a constraint is not understood, due to lack of knowledge of the type of the
constraint or the contents of the constraint, then the constraint cannot be satisfied.
Note that it is possible for an instance of this class to contain both requirements that conflict with each other, and preferences that conflict with each other and with requirements.
- Since:
- 2.0
- Author:
- Sun Microsystems, Inc.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final InvocationConstraintsAn empty instance, one that has no requirements and no preferences. -
Constructor Summary
ConstructorsConstructorDescriptionInvocationConstraints(Collection reqs, Collection prefs) Creates an instance that has all of the constraints from the first collection,reqs, added as requirements if the collection is a non-nullvalue, and has all of the constraints from the second collection,prefs, added as preferences if the collection is a non-nullvalue.InvocationConstraints(InvocationConstraint[] reqs, InvocationConstraint[] prefs) Creates an instance that has all of the constraints from the first array,reqs, added as requirements if the array is a non-nullvalue, and has all of the constraints from the second array,prefs, added as preferences if the array is a non-nullvalue.Creates an instance that has the first constraint,req, added as a requirement if it is a non-nullvalue, and has the second constraint,pref, added as a preference if it is a non-nullvalue and is not a duplicate of the requirement. -
Method Summary
Modifier and TypeMethodDescriptionstatic InvocationConstraintscombine(InvocationConstraints constraints1, InvocationConstraints constraints2) Returns an instance of this class that has all of the requirements from each non-nullargument added as requirements and has all of the preferences from each non-nullargument added as preferences.booleanTwo instances of this class are equal if they have the same requirements and the same preferences.inthashCode()Returns a hash code value for this object.booleanisEmpty()Returnstrueif the instance has no requirements and no preferences; returnsfalseotherwise.Returns an instance of this class constructed from all of the same requirements and preferences as this instance, but with every constraint that is an instance ofRelativeTimeConstraintreplaced by the result of invoking the constraint'smakeAbsolutemethod with the current time (as given bySystem.currentTimeMillis).makeAbsolute(long baseTime) Returns an instance of this class equal to the result of taking the requirements and preferences in this instance, replacing each constraint that is an instance ofRelativeTimeConstraintwith the result of invoking that constraint'smakeAbsolutemethod with the specified base time, and creating a new instance of this class with duplicate requirements, duplicate preferences, and preferences that are duplicates of requirements all removed.Returns an immutable set of all of the preferences.Returns an immutable set of all of the requirements.toString()Returns a string representation of this object.
-
Field Details
-
EMPTY
An empty instance, one that has no requirements and no preferences.
-
-
Constructor Details
-
InvocationConstraints
Creates an instance that has the first constraint,req, added as a requirement if it is a non-nullvalue, and has the second constraint,pref, added as a preference if it is a non-nullvalue and is not a duplicate of the requirement.- Parameters:
req- a requirement, ornullpref- a preference, ornull
-
InvocationConstraints
Creates an instance that has all of the constraints from the first array,reqs, added as requirements if the array is a non-nullvalue, and has all of the constraints from the second array,prefs, added as preferences if the array is a non-nullvalue. Duplicate requirements, duplicate preferences, and preferences that are duplicates of requirements are all removed. The arguments passed to the constructor are neither modified nor retained; subsequent changes to those arguments have no effect on the instance created.- Parameters:
reqs- requirements, ornullprefs- preferences, ornull- Throws:
NullPointerException- if any element of an argument isnull
-
InvocationConstraints
Creates an instance that has all of the constraints from the first collection,reqs, added as requirements if the collection is a non-nullvalue, and has all of the constraints from the second collection,prefs, added as preferences if the collection is a non-nullvalue. Duplicate requirements, duplicate preferences, and preferences that are duplicates of requirements are all removed. The arguments passed to the constructor are neither modified nor retained; subsequent changes to those arguments have no effect on the instance created.- Parameters:
reqs- requirements, ornullprefs- preferences, ornull- Throws:
NullPointerException- if any element of an argument isnullIllegalArgumentException- if any element of an argument is not an instance ofInvocationConstraint
-
-
Method Details
-
combine
public static InvocationConstraints combine(InvocationConstraints constraints1, InvocationConstraints constraints2) Returns an instance of this class that has all of the requirements from each non-nullargument added as requirements and has all of the preferences from each non-nullargument added as preferences. Duplicate requirements, duplicate preferences, and preferences that are duplicates of requirements are all removed.- Parameters:
constraints1- constraints, ornullconstraints2- constraints, ornull- Returns:
- an instance of this class that has all of the requirements from each
non-
nullargument added as requirements and has all of the preferences from each non-nullargument added as preferences
-
makeAbsolute
Returns an instance of this class equal to the result of taking the requirements and preferences in this instance, replacing each constraint that is an instance ofRelativeTimeConstraintwith the result of invoking that constraint'smakeAbsolutemethod with the specified base time, and creating a new instance of this class with duplicate requirements, duplicate preferences, and preferences that are duplicates of requirements all removed.- Parameters:
baseTime- an absolute time, specified in milliseconds from midnight, January 1, 1970 UTC- Returns:
- an instance of this class equal to the result of taking the requirements and
preferences in this instance, replacing each constraint that is an instance of
RelativeTimeConstraintwith the result of invoking that constraint'smakeAbsolutemethod with the specified base time, and creating a new instance of this class with duplicate requirements, duplicate preferences, and preferences that are duplicates of requirements all removed
-
makeAbsolute
Returns an instance of this class constructed from all of the same requirements and preferences as this instance, but with every constraint that is an instance ofRelativeTimeConstraintreplaced by the result of invoking the constraint'smakeAbsolutemethod with the current time (as given bySystem.currentTimeMillis). Duplicate requirements, duplicate preferences, and preferences that are duplicates of requirements are all removed.- Returns:
- an instance of this class constructed from all of the same requirements and
preferences as this instance, but with every constraint that is an instance of
RelativeTimeConstraintreplaced by the result of invoking the constraint'smakeAbsolutemethod with the current time
-
requirements
Returns an immutable set of all of the requirements. Any attempt to modify this set results in anUnsupportedOperationExceptionbeing thrown.- Returns:
- an immutable set of all of the requirements
-
preferences
Returns an immutable set of all of the preferences. Any attempt to modify this set results in anUnsupportedOperationExceptionbeing thrown.- Returns:
- an immutable set of all of the preferences
-
isEmpty
public boolean isEmpty()Returnstrueif the instance has no requirements and no preferences; returnsfalseotherwise.- Returns:
trueif the instance has no requirements and no preferences;falseotherwise
-
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 requirements and the same preferences. This method is a sufficient substitute forTrustEquivalence.checkTrustEquivalence. -
toString
Returns a string representation of this object.
-