@PublicApi public abstract class TrailItemSet extends Object
Abstract class for defining a set of items (by their ItemIdentity
).
Specific subclasses provide the different ways to define a set.
TrailItemSet
is used in AttributeTrail
to provide a filter for item changes that should
cause invalidation of a calculated value.
The implementations of this class are immutable and thread-safe.
Implementation note: when adding another specific sub-class, make sure it is serializable and can be sent over to the client code.
TrailItemSet.SpecificItems
,
TrailItemSet.OneType
Modifier and Type | Class and Description |
---|---|
static class |
TrailItemSet.AllItems
Represents a set of all items.
|
static class |
TrailItemSet.Collector
Used to collect specific types and items stored in the TrailItemSet.
|
static class |
TrailItemSet.None
Represents an empty set.
|
static class |
TrailItemSet.OneItem
Represents a set with just one item.
|
static class |
TrailItemSet.OneType
Represents a set of all items of one specific type.
|
static interface |
TrailItemSet.ReadVisitor
Alternate visitor interface for reading out the specific items and types.
|
static class |
TrailItemSet.SpecificItems
Represents a set of several sepecific items.
|
static class |
TrailItemSet.SpecificTypes
Represents a set of all items of several specific types.
|
static interface |
TrailItemSet.Visitor
Visitor interface for analyzing the set.
|
Modifier and Type | Method and Description |
---|---|
abstract void |
accept(TrailItemSet.Visitor visitor)
Allows the caller to perform per-subclass actions.
|
abstract boolean |
contains(ItemIdentity id)
Checks if the set contains the given item.
|
boolean |
equals(Object obj) |
abstract TrailItemSet |
expand(ItemIdentity trailItem)
Expands the set to include the given item.
|
int |
hashCode() |
boolean |
isEmpty()
Returns true if this set will not match any item.
|
static TrailItemSet |
of(ItemIdentity... ids)
Constructs a set for specific item IDs.
|
static TrailItemSet |
ofTypes(Collection<String> types)
Constructs a set for specific item types.
|
String |
toString() |
public abstract boolean contains(@Nullable ItemIdentity id)
id
- item ID@NotNull public abstract TrailItemSet expand(@Nullable ItemIdentity trailItem)
Expands the set to include the given item. The result of this operation is a new set, which a) includes everything this set includes, b) includes given item.
Note that the resulting set may contain more items, due to escalation to a more wide set class. If you expand a set by a sufficient number of items, it will switch to be type-based set, which will contain all items of the given types.
trailItem
- item to add to the settrailItem
public abstract void accept(@NotNull TrailItemSet.Visitor visitor)
public final boolean isEmpty()
public static TrailItemSet of(ItemIdentity... ids)
ids
- item identities - each element in the array must not be null!public static TrailItemSet ofTypes(Collection<String> types)
types
- item types - each element in the array must not be nullCopyright © 2017 ALM Works. All Rights Reserved.