Class Resources
- Since:
- 3.7.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends IExtendedResource>
Tclone(T resource) Creates and returns a clone of this resource.static ObjectgetExtendedProperty(IExtendedResource resource, String propertyDefinition) Returns the value in extended properties associated to the property definition, if any.static ObjectgetExtendedProperty(IExtendedResource resource, URI propertyDefinition) Returns the value in extended properties associated to the property definition, if any.static ObjectgetExtendedProperty(IExtendedResource resource, QName qname) Returns the value in extended properties associated to the property definition, if any.static booleanisOfType(IExtendedResource resource, URI type) Determines whether a resource contains the given type on either theIExtendedResource.getTypes()property or theOslcResourceShapeannotation.static voidsetExtendedProperty(IExtendedResource resource, QName qname, Object value) Changes the value in extended properties associated to the property definition.
-
Method Details
-
getExtendedProperty
Returns the value in extended properties associated to the property definition, if any.This method gracefully handles the case
getExtendedProperties()returnsnull. Usage should be limited to checking theMapreturned bygetExtendedProperties(). Prefer usingResourcePropertiesfor accessing a property value when it's uncertain whether property definition is mapped to a field or stored as an extended property.- Parameters:
resource- the resource having extended propertiesqname- the qualified name of the OSLC property (e.g.Dcterms.qname("title")).- Returns:
- the value associated,
nullif none. - Throws:
NullPointerException- if resource or qname isnull.
-
getExtendedProperty
Returns the value in extended properties associated to the property definition, if any.This method gracefully handles the case
getExtendedProperties()returnsnull. Usage should be limited to checking theMapreturned bygetExtendedProperties(). Prefer usingResourcePropertiesfor accessing a property value when it's uncertain whether property definition is mapped to a field or stored as an extended property.- Parameters:
resource- the resource having extended propertiespropertyDefinition- the URI of the OSLC property (e.g.URI.create("http://purl.org/dc/terms/title")).- Returns:
- the value associated,
nullif none. - Throws:
NullPointerException- if resource or propertyDefinition isnull.
-
getExtendedProperty
Returns the value in extended properties associated to the property definition, if any.This method gracefully handles the case
getExtendedProperties()returnsnull. Usage should be limited to checking theMapreturned bygetExtendedProperties(). Prefer usingResourcePropertiesfor accessing a property value when it's uncertain whether property definition is mapped to a field or stored as an extended property.- Parameters:
resource- the resource having extended propertiespropertyDefinition- the qualified name of the OSLC property (e.g."http://purl.org/dc/terms/title").- Returns:
- the value associated,
nullif none. - Throws:
NullPointerException- if resource or propertyDefinition isnull
-
setExtendedProperty
Changes the value in extended properties associated to the property definition. Usingnullas value removes the extended property, if any.This method gracefully handles the case
getExtendedProperties()returnsnull. In such case, and if the value to assign is notnull, a newMapis assigned as extended properties. Usage should be limited to changing explicitly theMapreturned bygetExtendedProperties(). Prefer usingResourcePropertiesfor changing a property value when it's uncertain whether property definition is mapped to a field or stored as an extended property.- Parameters:
resource- the resource having extended propertiesqname- the qualified name of the OSLC property (e.g.Dcterms.qname("title")).value- the new value to assign (possiblynull)
-
clone
Creates and returns a clone of this resource.Cloning is implemented by serializing the given resource to RDF content and de-serializing it back. The only subtle difference between the original resource and the clone is that the latter has an explicit
rdf:typevalue (inIExtendedResource.getTypes()result), which comes from the serialization of theOslcResourceShapeannotation of the resource class. Both forms are semantically equivalent.- Type Parameters:
T- the type of resource to clone- Parameters:
resource- the resource to clone- Returns:
- the cloned resource
- Throws:
NullPointerException- if resource is null
-
isOfType
Determines whether a resource contains the given type on either theIExtendedResource.getTypes()property or theOslcResourceShapeannotation.- Parameters:
resource- the resource to evaluate.type- the given type.- Returns:
trueif thetypeis contained in therdf:typeproperty or theOslcResourceShapeannotation;falseotherwise.- Throws:
NullPointerException- if any argument is null.- Since:
- 3.9.0
-