Package io.urf.surf
Class SurfObject
- java.lang.Object
-
- io.urf.surf.SurfObject
-
public class SurfObject extends java.lang.Object
A SURF object for a SURF document.SURF objects are considered equal if their tags, type handles, IDs, and property handles and values are equal.
- Author:
- Garret Wilson
-
-
Constructor Summary
Constructors Constructor Description SurfObject()
Constructor of a object with no tag and an unknown type.SurfObject(java.lang.String typeHandle)
Optional type handle constructor.SurfObject(java.lang.String typeHandle, java.lang.String id)
Type handle and optional ID constructor.SurfObject(java.net.URI tag)
Optional tag constructor.SurfObject(java.net.URI tag, java.lang.String typeHandle)
Optional tag and optional type handle constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearProperties()
Removes all properties.boolean
equals(java.lang.Object object)
java.util.Optional<java.lang.String>
getId()
Returns the ID, if any, of the object for its type.java.lang.Iterable<java.util.Map.Entry<java.lang.String,java.lang.Object>>
getProperties()
int
getPropertyCount()
java.util.Optional<java.lang.Object>
getPropertyValue(java.lang.String propertyHandle)
Retrieves the value of a property by the property handle.java.util.Optional<java.net.URI>
getTag()
java.util.Optional<java.lang.String>
getTypeHandle()
boolean
hasDescription()
int
hashCode()
void
setProperties(java.util.Map<java.lang.String,?> properties)
Sets property values from a map of property handles and values.java.util.Optional<java.lang.Object>
setPropertyValue(java.lang.String propertyHandle, java.lang.Object value)
Sets a property value by the property handle.
-
-
-
Constructor Detail
-
SurfObject
public SurfObject()
Constructor of a object with no tag and an unknown type.
-
SurfObject
public SurfObject(@Nullable java.net.URI tag)
Optional tag constructor.- Parameters:
tag
- The identifying object tag, ornull
if not known.- Throws:
java.lang.IllegalArgumentException
- if a tag is given that is not an absolute IRI.
-
SurfObject
public SurfObject(@Nullable java.net.URI tag, @Nullable java.lang.String typeHandle)
Optional tag and optional type handle constructor.- Parameters:
tag
- The identifying object tag, ornull
if not known.typeHandle
- The handle of the object type, ornull
if not known.- Throws:
java.lang.IllegalArgumentException
- if a tag is given that is not an absolute URI.java.lang.IllegalArgumentException
- if the given type handle is not a valid SURF handle.
-
SurfObject
public SurfObject(@Nullable java.lang.String typeHandle)
Optional type handle constructor.- Parameters:
typeHandle
- The handle of the object type, ornull
if not known.- Throws:
java.lang.IllegalArgumentException
- if the given type handle is not a valid SURF handle.
-
SurfObject
public SurfObject(@Nonnull java.lang.String typeHandle, @Nullable java.lang.String id)
Type handle and optional ID constructor.- Parameters:
typeHandle
- The handle of the object type.id
- The object identifier unique for the object type.- Throws:
java.lang.NullPointerException
- if the given type handle isnull
.java.lang.IllegalArgumentException
- if the given type handle is not a valid SURF handle.
-
-
Method Detail
-
getTag
public java.util.Optional<java.net.URI> getTag()
- Returns:
- The object identifier tag.
-
getTypeHandle
public java.util.Optional<java.lang.String> getTypeHandle()
- Returns:
- The handle of the object type if known.
-
getId
public java.util.Optional<java.lang.String> getId()
Returns the ID, if any, of the object for its type. Objects with no type never have an ID.- Returns:
- The ID, if any, of the object.
-
getPropertyCount
public int getPropertyCount()
- Returns:
- The number of properties this object has.
-
hasDescription
public boolean hasDescription()
- Returns:
true
if this object has at least one property.
-
getPropertyValue
public java.util.Optional<java.lang.Object> getPropertyValue(java.lang.String propertyHandle)
Retrieves the value of a property by the property handle.- Parameters:
propertyHandle
- The handle of the property.- Returns:
- The value of the property, if any.
-
setPropertyValue
public java.util.Optional<java.lang.Object> setPropertyValue(java.lang.String propertyHandle, java.lang.Object value)
Sets a property value by the property handle.- Parameters:
propertyHandle
- The handle of the property.value
- The new value of the property.- Returns:
- The previous value of the property, if any.
- Throws:
java.lang.IllegalArgumentException
- if the given property handle does not conform to the rules for a SURF handle.
-
getProperties
public java.lang.Iterable<java.util.Map.Entry<java.lang.String,java.lang.Object>> getProperties()
- Returns:
- An iterable to the object's properties by handle and their associated values.
-
clearProperties
public void clearProperties()
Removes all properties.
-
setProperties
public void setProperties(@Nonnull java.util.Map<java.lang.String,?> properties)
Sets property values from a map of property handles and values. Neithernull
property handles nornull
property values are allowed.- Parameters:
properties
- The map of property handles and values.- Throws:
java.lang.NullPointerException
- if one or more of the given property handles or values isnull
.java.lang.IllegalArgumentException
- if one of the given property handles does not conform to the rules for a SURF handle.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object object)
- Overrides:
equals
in classjava.lang.Object
-
-