Package com.globalmentor.net
Class DefaultResource
- java.lang.Object
-
- com.globalmentor.net.AbstractResource
-
- com.globalmentor.net.DefaultResource
-
- Direct Known Subclasses:
AbstractObjectResource
,FileResource
public class DefaultResource extends AbstractResource implements java.lang.Comparable<Resource>
Represents the default implementation of a resource. This class provides compare functionality that sorts according to the reference URI, if available.- Author:
- Garret Wilson
-
-
Field Summary
-
Fields inherited from interface com.globalmentor.net.Resource
URI_PROPERTY_NAME
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
DefaultResource()
Default constructor that allows the URI to be set later.protected
DefaultResource(java.net.URI uri)
URI constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(Resource resource)
Compares this object to another object.java.net.URI
getURI()
void
setURI(java.net.URI uri)
Sets the URI of the resource.
-
-
-
Method Detail
-
getURI
public java.net.URI getURI()
-
setURI
public void setURI(java.net.URI uri)
Sets the URI of the resource.- Parameters:
uri
- The new URI, ornull
if the identifier is not known.
-
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 resource.- 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()
,AbstractResource.hashCode()
-
-