public final class ConstraintAlternatives extends Object implements RelativeTimeConstraint, Serializable
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.
Constructor and Description |
---|
ConstraintAlternatives(Collection c)
Creates 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.
|
Modifier and Type | Method and Description |
---|---|
static InvocationConstraint |
create(Collection c)
Returns a constraint representing the specified alternative constraints,
with duplicate constraints removed.
|
static InvocationConstraint |
create(InvocationConstraint[] constraints)
Returns a constraint representing the specified alternative constraints,
with duplicate constraints removed.
|
Set |
elements()
Returns an immutable set of all of the constraints.
|
boolean |
equals(Object obj)
Two instances of this class are equal if they have the same constraints
(ignoring order).
|
int |
hashCode()
Returns a hash code value for this object.
|
InvocationConstraint |
makeAbsolute(long baseTime)
Returns a constraint equal to the result of taking the constraints 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 invoking the create method of this class with
the revised collection of constraints. |
String |
toString()
Returns a string representation of this object.
|
public ConstraintAlternatives(InvocationConstraint[] constraints)
constraints
- the alternative constraintsNullPointerException
- if the argument is null
or
any element is null
IllegalArgumentException
- if any of the elements are instances
of ConstraintAlternatives
, or if fewer than two elements
remain after duplicate constraints are removedpublic ConstraintAlternatives(Collection c)
c
- the alternative constraintsNullPointerException
- if the argument is null
or
any element is null
IllegalArgumentException
- if any of the elements are instances
of ConstraintAlternatives
, or if the elements are not all
instances of InvocationConstraint
, or if fewer than two
elements remain after duplicate constraints are removedpublic static InvocationConstraint create(InvocationConstraint[] constraints)
ConstraintAlternatives
containing 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.constraints
- the alternative constraintsNullPointerException
- if the argument is null
or
any element is null
IllegalArgumentException
- if the argument is empty, or if any
of the elements are instances of ConstraintAlternatives
public static InvocationConstraint create(Collection c)
ConstraintAlternatives
containing 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.c
- the alternative constraintsNullPointerException
- if the argument is null
or
any element is null
IllegalArgumentException
- if the argument is empty, or if any
of the elements are instances of ConstraintAlternatives
,
or if the elements are not all instances of
InvocationConstraint
public Set elements()
UnsupportedOperationException
being thrown.public InvocationConstraint makeAbsolute(long baseTime)
RelativeTimeConstraint
with the result of invoking that
constraint's makeAbsolute
method with the specified base
time, and invoking the create
method of this class with
the revised collection of constraints.makeAbsolute
in interface RelativeTimeConstraint
baseTime
- an absolute time, specified in milliseconds from
midnight, January 1, 1970 UTCpublic int hashCode()
public boolean equals(Object obj)