Package com.mayam.wf.config.shared
Class HasIdentity.Utilities
java.lang.Object
com.mayam.wf.config.shared.HasIdentity.Utilities
- Enclosing interface:
HasIdentity
-
Field Summary
Modifier and TypeFieldDescriptionstatic final Comparator
<HasIdentity> Comparator for use with objects implementing theHasIdentity
interface. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic final String
createUniqueId
(String sourceId) Makes a unique identifier based on an existing identifier.static <T extends HasIdentity>
List<String> identityList
(Collection<T> entries) Extracts a list of identities from a collection ofHasIdentity
objects.static <T extends HasIdentity>
Set<String> identitySet
(Collection<T> entries) Extracts a set of identities from a collection ofHasIdentity
objects.static <T extends HasIdentity>
Tlookup
(String id, Collection<T> entries) Looks up an object implementingHasIdentity
by its identitfier within a collection.static <T extends HasIdentity>
List<T> objectList
(Collection<String> needles, Collection<T> haystack) Compiles a list that is a subset, selected using the provided identifiers, of a collection ofHasIdentity
objects.
-
Field Details
-
COMPARATOR
Comparator for use with objects implementing theHasIdentity
interface. Equivalent toString.compareTo(String)
onHasIdentity.getId()
.
-
-
Constructor Details
-
Utilities
public Utilities()
-
-
Method Details
-
createUniqueId
Makes a unique identifier based on an existing identifier. Typically used when creating copies. A naive time based algorithm is used, but it should ensure uniqueness within a specific configuration since there is only ever one writer.- Parameters:
sourceId
- identifier used as base.- Returns:
- newly created unique identifier.
-
lookup
Looks up an object implementingHasIdentity
by its identitfier within a collection. -
identityList
Extracts a list of identities from a collection ofHasIdentity
objects. -
objectList
public static <T extends HasIdentity> List<T> objectList(Collection<String> needles, Collection<T> haystack) Compiles a list that is a subset, selected using the provided identifiers, of a collection ofHasIdentity
objects. -
identitySet
Extracts a set of identities from a collection ofHasIdentity
objects.
-