Package net.jini.constraint
Class BasicMethodConstraints
java.lang.Object
net.jini.constraint.BasicMethodConstraints
- All Implemented Interfaces:
Serializable,MethodConstraints
Basic implementation of
MethodConstraints, allowing limited wildcard matching on method
names and parameter types. Methods can be specified by exact name and parameter types (matching a
single method), by exact name (matching all methods with that name), by name prefix (matching all
methods with names that start with that prefix), by name suffix (matching all methods with names
that end with that suffix), and by a default that matches all methods. Normally instances of this
class should be obtained from a Configuration rather than being
explicitly constructed.- Since:
- 2.0
- Author:
- Sun Microsystems, Inc.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classDescriptor for specifying the constraints associated with one or more methods allowing limited wildcard matching on method names and parameter types. -
Constructor Summary
ConstructorsConstructorDescriptionCreates an instance with the specified ordered array of descriptors.BasicMethodConstraints(InvocationConstraints constraints) Creates an instance that maps all methods to the specified constraints. -
Method Summary
Modifier and TypeMethodDescriptionbooleanTwo instances of this class are equal if they have the same descriptors in the same order.getConstraints(Method method) Returns the constraints for the specified remote method as a non-nullvalue.Returns the descriptors.inthashCode()Returns a hash code value for this object.Returns an iterator that yields all of the possible distinct constraints that can be returned bygetConstraints, in arbitrary order and with duplicates permitted.toString()Returns a string representation of this object.
-
Constructor Details
-
BasicMethodConstraints
Creates an instance with the specified ordered array of descriptors. ThegetConstraintsmethod searches the descriptors in the specified order. For any given descriptor in the array, no preceding descriptor can match at least the same methods as the given descriptor; that is, more specific descriptors must precede less specific descriptors. The array passed to the constructor is neither modified nor retained; subsequent changes to that array have no effect on the instance created.- Parameters:
descs- the descriptors- Throws:
NullPointerException- if the argument isnullor any element of the argument isnullIllegalArgumentException- if the descriptors array is empty, or if any descriptor is preceded by another descriptor that matches at least the same methods
-
BasicMethodConstraints
Creates an instance that maps all methods to the specified constraints. The constraints can benull, which is treated the same as an empty instance. Calling this constructor is equivalent to constructing an instance of this class with an array containing a single default descriptor constructed with the specified constraints.- Parameters:
constraints- the constraints, ornull
-
-
Method Details
-
getConstraints
Returns the constraints for the specified remote method as a non-nullvalue. Searches the descriptors in order, and returns the constraints in the first descriptor that matches the method, or an empty constraints instance if there is no match.- Specified by:
getConstraintsin interfaceMethodConstraints- Parameters:
method- the method- Returns:
- the constraints for the specified method as a non-
nullvalue - Throws:
NullPointerException- if the argument isnull
-
possibleConstraints
Description copied from interface:MethodConstraintsReturns an iterator that yields all of the possible distinct constraints that can be returned bygetConstraints, in arbitrary order and with duplicates permitted. The iterator throws anUnsupportedOperationExceptionon any attempt to remove an element.- Specified by:
possibleConstraintsin interfaceMethodConstraints- Returns:
- an iterator that yields all of the possible distinct constraints that can be returned
by
getConstraints, in arbitrary order and with duplicates permitted
-
getMethodDescs
Returns the descriptors. Returns a new non-nullarray every time it is called.- Returns:
- the descriptors as a new non-
nullarray
-
hashCode
public int hashCode()Returns a hash code value for this object. -
toString
Returns a string representation of this object. -
equals
Two instances of this class are equal if they have the same descriptors in the same order.
-