public class ResourceUtils
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.net.URI |
NULL_URI
Null URI to use to unassign certain values.
|
Constructor and Description |
---|
ResourceUtils() |
Modifier and Type | Method and Description |
---|---|
static <T extends DataObjectRestRep> |
applyFilter(java.util.Collection<T> resources,
ResourceFilter<T> filter)
Applies a resource filter to the collection of resources.
|
static java.lang.String |
asString(java.net.URI value)
Gets the value of the URI as a string, returns null if the URI is null.
|
static NamedRelatedResourceRep |
createNamedRef(DataObjectRestRep resource)
Creates a named reference to the resource.
|
static <T> java.util.List<T> |
defaultList(java.util.List<T> value)
Defaults the list to an empty list if null.
|
static boolean |
equals(java.net.URI first,
java.net.URI second)
Determines if the IDs are equal (and non-null).
|
static <T extends DataObjectRestRep> |
find(java.util.Collection<T> values,
java.net.URI id)
Finds a data object within a collection by ID.
|
static <T extends RelatedResourceRep> |
findRef(java.util.Collection<T> resources,
java.net.URI id)
Finds a resource reference within a collection by ID.
|
static java.net.URI |
id(DataObjectRestRep value)
Gets the ID of a data object, null safe.
|
static java.net.URI |
id(RelatedResourceRep ref)
Gets the ID of a reference, null safe.
|
static boolean |
idEquals(DataObjectRestRep first,
RelatedResourceRep second)
Determines if the IDs of the given values match.
|
static boolean |
idEquals(RelatedResourceRep first,
DataObjectRestRep second)
Determines if the IDs of the given values match.
|
static boolean |
idEquals(RelatedResourceRep first,
RelatedResourceRep second)
Determines if the IDs of the given values match.
|
static java.util.List<java.net.URI> |
ids(java.util.Collection<? extends DataObjectRestRep> values)
Gets a list of IDs of data objects, null safe.
|
static boolean |
isActive(DataObjectRestRep value)
Determines if the item is active.
|
static boolean |
isNotInternal(DataObjectRestRep value)
Determines if the item is not internal.
|
static boolean |
isNull(java.net.URI id)
Checks if the ID is null (or matches the NULL_URI).
|
static <T extends DataObjectRestRep> |
mapById(java.util.Collection<T> resources)
Maps a collection of resources by their IDs.
|
static java.util.Map<java.net.URI,java.lang.String> |
mapNames(java.util.Collection<? extends NamedRelatedResourceRep> references)
Maps a collection of references by their ID to their name.
|
static java.lang.String |
name(DataObjectRestRep value)
Gets the name of a data object, null safe
|
static java.lang.String |
name(NamedRelatedResourceRep ref)
Gets the name of a named reference, null safe
|
static java.util.List<java.lang.String> |
names(java.util.Collection<? extends DataObjectRestRep> values)
Gets the names of the data objects, null safe
|
static java.util.List<java.net.URI> |
refIds(java.util.Collection<? extends RelatedResourceRep> refs)
Gets a list of IDs of data objects, null safe.
|
static java.util.List<java.lang.String> |
refNames(java.util.Collection<? extends NamedRelatedResourceRep> refs)
Gets the name of the references, null safe
|
static java.lang.String |
stringId(DataObjectRestRep value)
Gets the ID of the resource, as a string.
|
static java.lang.String |
stringId(RelatedResourceRep ref)
Gets the ID of the reference, as a string.
|
static java.util.List<java.lang.String> |
stringIds(java.util.Collection<? extends DataObjectRestRep> values)
Gets the IDs of the resources, as a list of strings.
|
static java.util.List<java.lang.String> |
stringRefIds(java.util.Collection<? extends RelatedResourceRep> refs)
Gets the IDs of the references, as a list of strings.
|
static java.net.URI |
uri(java.lang.String value)
Converts a string to a URI, null safe.
|
static java.util.List<java.net.URI> |
uris(java.util.Collection<java.lang.String> values)
Converts a collection of strings to a list of URIs, null safe.
|
static java.util.List<java.net.URI> |
uris(java.lang.String... values)
Converts an array of strings to a list of URIs, null safe.
|
public static final java.net.URI NULL_URI
public static java.net.URI id(DataObjectRestRep value)
value
- the data object.public static java.net.URI id(RelatedResourceRep ref)
ref
- the resource reference.public static java.util.List<java.net.URI> ids(java.util.Collection<? extends DataObjectRestRep> values)
values
- list of data objects.public static java.util.List<java.net.URI> refIds(java.util.Collection<? extends RelatedResourceRep> refs)
refs
- list of resource references.public static java.lang.String stringId(DataObjectRestRep value)
value
- the resource.public static java.lang.String stringId(RelatedResourceRep ref)
ref
- the resource reference.public static java.util.List<java.lang.String> stringIds(java.util.Collection<? extends DataObjectRestRep> values)
values
- the resources.public static java.util.List<java.lang.String> stringRefIds(java.util.Collection<? extends RelatedResourceRep> refs)
refs
- the resource references.public static java.lang.String name(DataObjectRestRep value)
value
- the data object.public static java.lang.String name(NamedRelatedResourceRep ref)
ref
- the named reference.public static java.util.List<java.lang.String> names(java.util.Collection<? extends DataObjectRestRep> values)
values
- the data objects.public static java.util.List<java.lang.String> refNames(java.util.Collection<? extends NamedRelatedResourceRep> refs)
refs
- the named references.public static <T extends DataObjectRestRep> T find(java.util.Collection<T> values, java.net.URI id)
values
- the data objects.id
- the ID of the value to find.public static <T extends RelatedResourceRep> T findRef(java.util.Collection<T> resources, java.net.URI id)
resources
- the resource references.id
- the ID of the reference to find.public static <T> java.util.List<T> defaultList(java.util.List<T> value)
value
- the list value.public static boolean isActive(DataObjectRestRep value)
value
- the item.public static boolean isNotInternal(DataObjectRestRep value)
value
- the item.public static <T extends DataObjectRestRep> java.util.Map<java.net.URI,T> mapById(java.util.Collection<T> resources)
resources
- the resources to map.public static java.util.Map<java.net.URI,java.lang.String> mapNames(java.util.Collection<? extends NamedRelatedResourceRep> references)
references
- the references to map.public static java.lang.String asString(java.net.URI value)
value
- the URI.public static java.net.URI uri(java.lang.String value)
value
- the string value.public static java.util.List<java.net.URI> uris(java.util.Collection<java.lang.String> values)
values
- the string values.public static java.util.List<java.net.URI> uris(java.lang.String... values)
values
- the string values.public static boolean idEquals(RelatedResourceRep first, RelatedResourceRep second)
first
- the first reference.second
- the second reference.public static boolean idEquals(RelatedResourceRep first, DataObjectRestRep second)
first
- the resource reference.second
- the resource object.public static boolean idEquals(DataObjectRestRep first, RelatedResourceRep second)
first
- the resource object.second
- the resource reference.public static boolean equals(java.net.URI first, java.net.URI second)
first
- the first ID.second
- the second ID.public static boolean isNull(java.net.URI id)
id
- the ID.public static NamedRelatedResourceRep createNamedRef(DataObjectRestRep resource)
resource
- the resource.public static <T extends DataObjectRestRep> void applyFilter(java.util.Collection<T> resources, ResourceFilter<T> filter)
resources
- the resources to filter.filter
- the filter to apply.