Package de.xima.fc.common.etag
Class ETagResource<T>
- java.lang.Object
-
- de.xima.fc.common.etag.ETagResource<T>
-
- Type Parameters:
T
- Type of the resource.
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
ETagResource.Modified
,ETagResource.NotFound
,ETagResource.NotModified
public abstract class ETagResource<T> extends Object implements Serializable
Represents a resource cached via the ETag mechanism. An etag resource has three possible states: (1) The resource was not found. (2) The resource was not modified. (3) The resource was modified.- Since:
- 8.3.0
- Author:
- XIMA MEDIA GmbH
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
ETagResource.Matcher<T,R>
Matcher for the different states of anETagResource
.static class
ETagResource.Modified<T>
AnETagResource
that represents a resource that was modified.static class
ETagResource.NotFound<T>
AnETagResource
that represents a resource that was not found.static class
ETagResource.NotModified<T>
AnETagResource
that represents a resource that was not modified.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <R> R
match(ETagResource.Matcher<T,R> matcher)
Matches this resource against the given matcher.static <T> ETagResource<T>
modified(ETag tag, T resource)
Creates an ETag resource that represents a modified resource.static <T> ETagResource<T>
notFound()
Gets an ETag resource representing a resource that was not found.static <T> ETagResource<T>
notModified()
Gets an ETag resource representing a resource that was not modified.
-
-
-
Method Detail
-
match
public <R> R match(ETagResource.Matcher<T,R> matcher)
Matches this resource against the given matcher. Invokes the method corresponding to the status of this resource.- Type Parameters:
R
- Type returned by the matcher.- Parameters:
matcher
- Matcher to use.- Returns:
- Result as returned by the matcher.
-
modified
public static <T> ETagResource<T> modified(ETag tag, T resource)
Creates an ETag resource that represents a modified resource.- Type Parameters:
T
- Type of the resource.- Parameters:
tag
- ETag of the resource, must not be null.resource
- Wrapped resource, must not be null.- Returns:
- A new ETag resource.
-
notFound
public static <T> ETagResource<T> notFound()
Gets an ETag resource representing a resource that was not found.- Type Parameters:
T
- Type of the resource.- Returns:
- A new ETag resource.
-
notModified
public static <T> ETagResource<T> notModified()
Gets an ETag resource representing a resource that was not modified.- Type Parameters:
T
- Type of the resource.- Returns:
- A new ETag resource.
-
-