Package com.globalmentor.net
Class BoundPropertyResource
- java.lang.Object
-
- com.globalmentor.beans.BoundPropertyObject
-
- com.globalmentor.net.BoundPropertyResource
-
- All Implemented Interfaces:
PropertyBindable
,PropertyConstrainable
,Resource
,java.lang.Comparable<Resource>
public class BoundPropertyResource extends BoundPropertyObject implements Resource, java.lang.Comparable<Resource>
Represents the default implementation of a resource that recognizes bound properties. This class provides compare functionality that sorts according to the reference URI, if available.- Author:
- Garret Wilson
- See Also:
DefaultResource
-
-
Field Summary
-
Fields inherited from class com.globalmentor.beans.BoundPropertyObject
NO_PROPERTY_CHANGE_LISTENERS, NO_VETOABLE_CHANGE_LISTENERS
-
Fields inherited from interface com.globalmentor.net.Resource
URI_PROPERTY_NAME
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
BoundPropertyResource()
Default constructor that allows the reference URI to be set later.protected
BoundPropertyResource(java.net.URI referenceURI)
Constructs a resource with a reference URI.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(Resource resource)
Compares this object to another object.boolean
equals(java.lang.Object object)
Compares the resource reference URIs.java.net.URI
getURI()
int
hashCode()
void
setReferenceURI(java.net.URI uri)
Sets the reference URI of the resource.java.lang.String
toString()
Returns a string representation of the resource.-
Methods inherited from class com.globalmentor.beans.BoundPropertyObject
addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, createPostponedPropertyChangeEvent, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, fireVetoableChange, getForwardPropertyChangeListener, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeSupport, getRepeatPropertyChangeListener, getRepeatVetoableChangeListener, getVetoableChangeListeners, getVetoableChangeListeners, getVetoableChangeSupport, hasPropertyChangeListeners, hasVetoableChangeListeners, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener
-
-
-
-
Constructor Detail
-
BoundPropertyResource
protected BoundPropertyResource()
Default constructor that allows the reference URI to be set later.
-
BoundPropertyResource
protected BoundPropertyResource(java.net.URI referenceURI)
Constructs a resource with a reference URI.- Parameters:
referenceURI
- The reference URI for the new resource.
-
-
Method Detail
-
getURI
public java.net.URI getURI()
-
setReferenceURI
public void setReferenceURI(java.net.URI uri)
Sets the reference URI of the resource.- Parameters:
uri
- The new reference URI, ornull
if the identifier is not known.
-
equals
public boolean equals(java.lang.Object object)
Compares the resource reference URIs. If neither object has a reference URI, the default identity comparison is performed.- Overrides:
equals
in classjava.lang.Object
- Parameters:
object
- The object with which to compare this resource.- Returns:
true
if this resource equals that specified inobject
.- See Also:
getURI()
,AbstractResource.equals(Object)
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- A hashcode value composed from the reference URI, if available.
-
compareTo
public int compareTo(Resource resource)
Compares this object to another object.This method determines order based upon the reference URI of the resource, if any; otherwise, the hash codes of the resources are compared. The resource with no URI is sorted before a resource with a URI. The same resource will always be considered equal.
- Specified by:
compareTo
in interfacejava.lang.Comparable<Resource>
- Parameters:
resource
- The resource with which to compare this resouce.- Returns:
- A negative integer, zero, or a positive integer as this resource reference URI is less than, equal to, or greater than the reference URI of the specified resource, respectively.
- See Also:
getURI()
,hashCode()
,DefaultResource.compareTo(Resource)
-
toString
public java.lang.String toString()
Returns a string representation of the resource. This version returns the URI, if there is one, between double angle quotation marks; otherwise the default string representation of the object is returned.- Overrides:
toString
in classjava.lang.Object
- Returns:
- A string representation of the resource.
-
-