Class ResourceReference
- java.lang.Object
-
- org.apache.wicket.request.resource.ResourceReference
-
- All Implemented Interfaces:
Serializable
,org.apache.wicket.util.io.IClusterable
- Direct Known Subclasses:
ConcatResourceBundleReference
,ContextRelativeResourceReference
,FileSystemResourceReference
,PackageResourceReference
,ResourceBundleReference
,ResourceReference.LambdaResourceReference
,SharedResourceReference
,TextTemplateResourceReference
,UrlResourceReference
public abstract class ResourceReference extends Object implements org.apache.wicket.util.io.IClusterable
Reference to a resource. Can be used to reference global resources.Even though resource reference is just a factory for resources, it still needs to be identified by a globally unique identifier, combination of
scope
andname
. Those are used to generate URLs for resource references.locale
,style
andvariation
are optional fields to allow having specific references for individual locales, styles and variations.- Author:
- Matej Knopp, Juergen Donnerstag
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ResourceReference.Key
A (re-usable) data store for all relevant ResourceReference datastatic class
ResourceReference.LambdaResourceReference
static class
ResourceReference.UrlAttributes
-
Constructor Summary
Constructors Constructor Description ResourceReference(Class<?> scope, String name)
Creates newResourceReference
instance.ResourceReference(Class<?> scope, String name, Locale locale, String style, String variation)
Creates newResourceReference
instance.ResourceReference(String name)
Construct.ResourceReference(ResourceReference.Key key)
Creates newResourceReference
instance.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
canBeRegistered()
Can be used to disable registering certain resource references inResourceReferenceRegistry
.boolean
equals(Object obj)
List<HeaderItem>
getDependencies()
String
getExtension()
returns extension of the resource referenceResourceReference.Key
getKey()
Locale
getLocale()
String
getName()
abstract IResource
getResource()
Returns the resource.Class<?>
getScope()
String
getStyle()
ResourceReference.UrlAttributes
getUrlAttributes()
Allows to specify which locale, style and variation values will the generated URL for this resource reference have.String
getVariation()
int
hashCode()
static ResourceReference
of(String name, org.danekja.java.util.function.serializable.SerializableSupplier<IResource> resourceSupplier)
Factory method to build a resource reference that uses the provided supplier to return the resource.static ResourceReference
of(ResourceReference.Key key, org.danekja.java.util.function.serializable.SerializableSupplier<IResource> resourceSupplier)
Factory method to build a resource reference that uses the provided supplier to return the resource.String
toString()
-
-
-
Constructor Detail
-
ResourceReference
public ResourceReference(ResourceReference.Key key)
Creates newResourceReference
instance.- Parameters:
key
- The data making up the resource reference
-
ResourceReference
public ResourceReference(Class<?> scope, String name, Locale locale, String style, String variation)
Creates newResourceReference
instance.- Parameters:
scope
- mandatory parametername
- mandatory parameterlocale
- resource localestyle
- resource stylevariation
- resource variation
-
ResourceReference
public ResourceReference(Class<?> scope, String name)
Creates newResourceReference
instance.- Parameters:
scope
- mandatory parametername
- mandatory parameter
-
ResourceReference
public ResourceReference(String name)
Construct.- Parameters:
name
- resource name
-
-
Method Detail
-
getKey
public final ResourceReference.Key getKey()
- Returns:
- Gets the data making up the resource reference. They'll be use by ResourceReferenceRegistry to make up the key under which the resource reference gets stored.
-
getExtension
public final String getExtension()
returns extension of the resource reference- Returns:
- extension of the resource's name in lower-case or
null
if there is no extension
-
getVariation
public String getVariation()
- Returns:
- variation
-
canBeRegistered
public boolean canBeRegistered()
Can be used to disable registering certain resource references inResourceReferenceRegistry
.- Returns:
true
if this reference can be registered,false
otherwise.
-
equals
public boolean equals(Object obj)
- Overrides:
equals
in classObject
- See Also:
Object.equals(java.lang.Object)
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classObject
- See Also:
Object.hashCode()
-
getResource
public abstract IResource getResource()
Returns the resource.- Returns:
- resource instance
-
getUrlAttributes
public ResourceReference.UrlAttributes getUrlAttributes()
Allows to specify which locale, style and variation values will the generated URL for this resource reference have.- Returns:
- url attributes
-
of
public static final ResourceReference of(String name, org.danekja.java.util.function.serializable.SerializableSupplier<IResource> resourceSupplier)
Factory method to build a resource reference that uses the provided supplier to return the resource.- Parameters:
name
- The name to use with the resourceresourceSupplier
- Lambda supplier to build the resource- Returns:
- the new resource reference
-
of
public static final ResourceReference of(ResourceReference.Key key, org.danekja.java.util.function.serializable.SerializableSupplier<IResource> resourceSupplier)
Factory method to build a resource reference that uses the provided supplier to return the resource.- Parameters:
key
- TheResourceReference.Key
to use with the resourceresourceSupplier
- Lambda supplier to build the resource- Returns:
- the new resource reference
-
getDependencies
public List<HeaderItem> getDependencies()
- Returns:
- the resources this ResourceReference depends on.
-
-