Package com.sodius.oslc.domain.config
Class ConfigContext
java.lang.Object
com.sodius.oslc.domain.config.ConfigContext
Represents a configuration context, which is the URI of a configuration (defined by OSLC Config specification),
that is set as a
oslc_config.context query parameter on a resource URI.
The configuration context controls which version of a resource is desired. The context may either hold a configuration URI or be empty.
This class provides methods to extract a configuration context from a resource URI and to assign such context on other URIs.
- Since:
- 3.0.0
-
Method Summary
Modifier and TypeMethodDescriptionCombine the given resource URI and the configuration URI to obtain a versioned resource URI.Combine the given resource URI and the configuration URI to obtain a versioned resource URI.static ConfigContextempty()Creates a context in which no configuration is desired.booleanIndicates whether some other object is "equal to" this configuration context.static ConfigContextExtract the configuration URI specified asoslc_config.contextquery parameter, if any, from the versioned resource URI.static ConfigContextExtract the configuration URI specified asoslc_config.contextquery parameter, if any, from the versioned resource URI.get()If a configuration is present in thisConfigurationContext, returns the value, otherwise throwsNoSuchElementException.inthashCode()Returns the hash code value of the present configuration, if any, or 0 (zero) if no configuration is present.booleanisEmpty()Returntrueif the configuration is absent, otherwisefalse.booleanReturntrueif there is a configuration present, otherwisefalse.static ConfigContextCreates a context for the specified configuration.static ConfigContextCreates a context for the specified configuration.static ConfigContextofNullable(URI configuration) Returns aConfigContextdescribing the specified configuration, if non-null, otherwise returns an emptyConfigContext.static ConfigContextofNullable(Link configuration) Returns aConfigContextdescribing the specified configuration, if non-null, otherwise returns an emptyConfigContext.Return the configuration URI if present, otherwise returnother.toString()Returns a non-empty string representation of this context suitable for debugging.
-
Method Details
-
empty
Creates a context in which no configuration is desired.- Returns:
- the configuration context.
-
of
Creates a context for the specified configuration.- Parameters:
configuration- the configuration, which must be non-null.- Returns:
- the configuration context.
- Throws:
NullPointerException- if configuration is null
-
of
Creates a context for the specified configuration.- Parameters:
configuration- the configuration, which must be non-null.- Returns:
- the configuration context.
- Throws:
NullPointerException- if configuration is null
-
ofNullable
Returns aConfigContextdescribing the specified configuration, if non-null, otherwise returns an emptyConfigContext.- Parameters:
configuration- the possibly-null configuration- Returns:
- a
ConfigContextwith a present configuration if the specified configuration is non-null, otherwise an emptyConfigContext
-
ofNullable
Returns aConfigContextdescribing the specified configuration, if non-null, otherwise returns an emptyConfigContext.- Parameters:
configuration- the possibly-null configuration- Returns:
- a
ConfigContextwith a present configuration if the specified configuration is non-null, otherwise an emptyConfigContext
-
from
Extract the configuration URI specified asoslc_config.contextquery parameter, if any, from the versioned resource URI.- Parameters:
versionedResourceUri- the resource URI with possibly a version information.- Returns:
- a context wrapping the configuration URI specified as query parameter,
emptyif none.
-
from
Extract the configuration URI specified asoslc_config.contextquery parameter, if any, from the versioned resource URI.- Parameters:
versionedResourceUri- the resource URI with possibly a version information.- Returns:
- a context wrapping the configuration URI specified as query parameter,
emptyif none.
-
hashCode
public int hashCode()Returns the hash code value of the present configuration, if any, or 0 (zero) if no configuration is present. -
equals
Indicates whether some other object is "equal to" this configuration context. The other object is considered equal if:- it is also a
ConfigurationContextand; - both instances have no configuration present or;
- the present configurations are "equal to" each other.
- it is also a
-
isPresent
public boolean isPresent()Returntrueif there is a configuration present, otherwisefalse.- Returns:
trueif there is a configuration present, otherwisefalse
-
isEmpty
public boolean isEmpty()Returntrueif the configuration is absent, otherwisefalse.- Returns:
trueif the configuration is absent, otherwisefalse- Since:
- 4.0.0
-
get
If a configuration is present in thisConfigurationContext, returns the value, otherwise throwsNoSuchElementException.- Returns:
- the non-null configuration held by this
Optional - Throws:
NoSuchElementException- if there is no configuration present- See Also:
-
orElse
Return the configuration URI if present, otherwise returnother.- Parameters:
other- the value to be returned if there is no configuration URI present, may be null- Returns:
- the configuration URI, if present, otherwise
other
-
apply
Combine the given resource URI and the configuration URI to obtain a versioned resource URI. The configuration URI is set asoslc_config.contextquery parameter in the returned URI.If the configuration context is
empty(), the resource URI is returned without anyoslc_config.contextquery parameter.- Parameters:
resource- the resource URI, which may not yet have a specified configuration URI.- Returns:
- the URI of the versioned resource, which includes the configuration URI as
oslc_config.contextquery parameter.
-
apply
Combine the given resource URI and the configuration URI to obtain a versioned resource URI. The configuration URI is set asoslc_config.contextquery parameter in the returned URI.If the configuration context is
empty(), the resource URI is returned without anyoslc_config.contextquery parameter.- Parameters:
resource- the resource URI, which may not yet have a specified configuration URI.- Returns:
- the URI of the versioned resource, which includes the configuration URI as
oslc_config.contextquery parameter.
-
toString
Returns a non-empty string representation of this context suitable for debugging.
-