Class Resource<R extends Resource<R> & Comparable<? super R>>
java.lang.Object
com.aoapps.web.resources.registry.Resource<R>
- All Implemented Interfaces:
Serializable
public abstract class Resource<R extends Resource<R> & Comparable<? super R>>
extends Object
implements Serializable
A resource given its full URL or application context-relative path.
TODO: Support inline resources without URI.
TODO: Support comments, which would not be displayed in production mode.
- Author:
- AO Industries, Inc.
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Resource.Builder<R extends Resource<R> & Comparable<? super R>>
Base builder pattern. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected int
All concrete implementations of Resource must be comparable to themselves.abstract boolean
Two resources may be compared to see if they are exactly equal, including all relevant attributes.final String
getUri()
Gets the URI if the resource.abstract int
hashCode()
The hash key must be consistent withequals(java.lang.Object)
.toString()
-
Constructor Details
-
Resource
Creates a new resource.- Parameters:
uri
- SeegetUri()
-
-
Method Details
-
toString
-
equals
Two resources may be compared to see if they are exactly equal, including all relevant attributes. -
hashCode
public abstract int hashCode()The hash key must be consistent withequals(java.lang.Object)
. -
compareTo
All concrete implementations of Resource must be comparable to themselves.This default implementation compares by URI only via
SmartComparator.ROOT
. -
getUri
Gets the URI if the resource. May be any of:-
Absolute URI (Example
https://…/…
): Used verbatim. -
Full path (Example
/…/…
): Path within the application. This may be prefixed with a context-path, depending on application type. -
Relative path (Example
../…/…
): Path relative to the application. This will be relative to the top of the application, which can be used to pull content from a different context-path, depending on application type. It is an error if the series of../
would go past the root path"/"
.
It is strongly recommended for this URI to be normalized, so that ordering will be consistent. However, no normalization is performed within this API.
All types of URI may be subjected to URL encoding, depending on application type.
-
Absolute URI (Example
-