GigaSpaces XAP 9.7.2 API

net.jini.core.constraint
Class InvocationConstraints

java.lang.Object
  extended by net.jini.core.constraint.InvocationConstraints
All Implemented Interfaces:
Serializable

public final class InvocationConstraints
extends Object
implements 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:
Serialized Form

Field Summary
static InvocationConstraints EMPTY
          An empty instance, one that has no requirements and no preferences.
 
Constructor Summary
InvocationConstraints(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-null value, and has all of the constraints from the second collection, prefs, added as preferences if the collection is a non-null value.
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-null value, and has all of the constraints from the second array, prefs, added as preferences if the array is a non-null value.
InvocationConstraints(InvocationConstraint req, InvocationConstraint pref)
          Creates an instance that has the first constraint, req, added as a requirement if it is a non-null value, and has the second constraint, pref, added as a preference if it is a non-null value and is not a duplicate of the requirement.
 
Method Summary
static InvocationConstraints combine(InvocationConstraints constraints1, InvocationConstraints constraints2)
          Returns an instance of this class that has all of the requirements from each non-null argument added as requirements and has all of the preferences from each non-null argument added as preferences.
 boolean equals(Object obj)
          Two instances of this class are equal if they have the same requirements and the same preferences.
 int hashCode()
          Returns a hash code value for this object.
 boolean isEmpty()
          Returns true if the instance has no requirements and no preferences; returns false otherwise.
 InvocationConstraints 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 of RelativeTimeConstraint replaced by the result of invoking the constraint's makeAbsolute method with the current time (as given by System.currentTimeMillis).
 InvocationConstraints 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 of RelativeTimeConstraint with the result of invoking that constraint's makeAbsolute method 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.
 Set preferences()
          Returns an immutable set of all of the preferences.
 Set requirements()
          Returns an immutable set of all of the requirements.
 String toString()
          Returns a string representation of this object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY

public static final InvocationConstraints EMPTY
An empty instance, one that has no requirements and no preferences.

Constructor Detail

InvocationConstraints

public InvocationConstraints(InvocationConstraint req,
                             InvocationConstraint pref)
Creates an instance that has the first constraint, req, added as a requirement if it is a non-null value, and has the second constraint, pref, added as a preference if it is a non-null value and is not a duplicate of the requirement.

Parameters:
req - a requirement, or null
pref - a preference, or null

InvocationConstraints

public 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-null value, and has all of the constraints from the second array, prefs, added as preferences if the array is a non-null value. 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, or null
prefs - preferences, or null
Throws:
NullPointerException - if any element of an argument is null

InvocationConstraints

public InvocationConstraints(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-null value, and has all of the constraints from the second collection, prefs, added as preferences if the collection is a non-null value. 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, or null
prefs - preferences, or null
Throws:
NullPointerException - if any element of an argument is null
IllegalArgumentException - if any element of an argument is not an instance of InvocationConstraint
Method Detail

combine

public static InvocationConstraints combine(InvocationConstraints constraints1,
                                            InvocationConstraints constraints2)
Returns an instance of this class that has all of the requirements from each non-null argument added as requirements and has all of the preferences from each non-null argument added as preferences. Duplicate requirements, duplicate preferences, and preferences that are duplicates of requirements are all removed.

Parameters:
constraints1 - constraints, or null
constraints2 - constraints, or null
Returns:
an instance of this class that has all of the requirements from each non-null argument added as requirements and has all of the preferences from each non-null argument added as preferences

makeAbsolute

public InvocationConstraints 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 of RelativeTimeConstraint with the result of invoking that constraint's makeAbsolute method 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 RelativeTimeConstraint with the result of invoking that constraint's makeAbsolute method 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

public InvocationConstraints 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 of RelativeTimeConstraint replaced by the result of invoking the constraint's makeAbsolute method with the current time (as given by System.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 RelativeTimeConstraint replaced by the result of invoking the constraint's makeAbsolute method with the current time

requirements

public Set requirements()
Returns an immutable set of all of the requirements. Any attempt to modify this set results in an UnsupportedOperationException being thrown.

Returns:
an immutable set of all of the requirements

preferences

public Set preferences()
Returns an immutable set of all of the preferences. Any attempt to modify this set results in an UnsupportedOperationException being thrown.

Returns:
an immutable set of all of the preferences

isEmpty

public boolean isEmpty()
Returns true if the instance has no requirements and no preferences; returns false otherwise.

Returns:
true if the instance has no requirements and no preferences; false otherwise

hashCode

public int hashCode()
Returns a hash code value for this object.

Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Two instances of this class are equal if they have the same requirements and the same preferences. This method is a sufficient substitute for TrustEquivalence.checkTrustEquivalence.

Overrides:
equals in class Object

toString

public String toString()
Returns a string representation of this object.

Overrides:
toString in class Object

GigaSpaces XAP 9.7.2 API

Copyright © GigaSpaces.