public final class InvocationConstraints extends Object implements Serializable
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.
Modifier and Type | Field and Description |
---|---|
static InvocationConstraints |
EMPTY
An empty instance, one that has no requirements and no preferences.
|
Constructor and Description |
---|
InvocationConstraints(AtomicSerial.GetArg arg)
AtomicSerial constructor.
|
InvocationConstraints(Collection<InvocationConstraint> reqs,
Collection<InvocationConstraint> 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. |
Modifier and Type | Method and Description |
---|---|
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<InvocationConstraint> |
preferences()
Returns an immutable set of all of the preferences.
|
Set<InvocationConstraint> |
requirements()
Returns an immutable set of all of the requirements.
|
String |
toString()
Returns a string representation of this object.
|
public static final InvocationConstraints EMPTY
public InvocationConstraints(AtomicSerial.GetArg arg) throws IOException
arg
- atomic deserialization parameterIOException
- if there are I/O errors while reading from GetArg's
underlying InputStream
public InvocationConstraints(InvocationConstraint req, InvocationConstraint pref)
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.req
- a requirement, or null
pref
- a preference, or null
public InvocationConstraints(InvocationConstraint[] reqs, InvocationConstraint[] prefs)
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.reqs
- requirements, or null
prefs
- preferences, or null
NullPointerException
- if any element of an argument is
null
public InvocationConstraints(Collection<InvocationConstraint> reqs, Collection<InvocationConstraint> prefs)
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.reqs
- requirements, or null
prefs
- preferences, or null
NullPointerException
- if any element of an argument is
null
IllegalArgumentException
- if any element of an argument is not
an instance of InvocationConstraint
public static InvocationConstraints combine(InvocationConstraints constraints1, InvocationConstraints constraints2)
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.constraints1
- constraints, or null
constraints2
- constraints, or null
null
argument added as requirements and has all
of the preferences from each non-null
argument added as
preferencespublic InvocationConstraints makeAbsolute(long baseTime)
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.baseTime
- an absolute time, specified in milliseconds from
midnight, January 1, 1970 UTCRelativeTimeConstraint
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 removedpublic InvocationConstraints makeAbsolute()
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.RelativeTimeConstraint
replaced by the result of invoking the constraint's
makeAbsolute
method with the current timepublic Set<InvocationConstraint> requirements()
UnsupportedOperationException
being thrown.public Set<InvocationConstraint> preferences()
UnsupportedOperationException
being thrown.public boolean isEmpty()
true
if the instance has no requirements and no
preferences; returns false
otherwise.true
if the instance has no requirements and no
preferences; false
otherwisepublic int hashCode()
public boolean equals(Object obj)
TrustEquivalence.checkTrustEquivalence
.Copyright © 2016–2018 The Apache Software Foundation. All rights reserved.