Class ResourceReference
- java.lang.Object
-
- org.apache.wicket.request.resource.ResourceReference
-
- All Implemented Interfaces:
java.io.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 java.lang.Object implements org.apache.wicket.util.io.IClusterableReference 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
scopeandname. Those are used to generate URLs for resource references.locale,styleandvariationare 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 classResourceReference.KeyA (re-usable) data store for all relevant ResourceReference datastatic classResourceReference.LambdaResourceReferencestatic classResourceReference.UrlAttributes
-
Constructor Summary
Constructors Constructor Description ResourceReference(java.lang.Class<?> scope, java.lang.String name)Creates newResourceReferenceinstance.ResourceReference(java.lang.Class<?> scope, java.lang.String name, java.util.Locale locale, java.lang.String style, java.lang.String variation)Creates newResourceReferenceinstance.ResourceReference(java.lang.String name)Construct.ResourceReference(ResourceReference.Key key)Creates newResourceReferenceinstance.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleancanBeRegistered()Can be used to disable registering certain resource references inResourceReferenceRegistry.booleanequals(java.lang.Object obj)java.util.List<HeaderItem>getDependencies()java.lang.StringgetExtension()returns extension of the resource referenceResourceReference.KeygetKey()java.util.LocalegetLocale()java.lang.StringgetName()abstract IResourcegetResource()Returns the resource.java.lang.Class<?>getScope()java.lang.StringgetStyle()ResourceReference.UrlAttributesgetUrlAttributes()Allows to specify which locale, style and variation values will the generated URL for this resource reference have.java.lang.StringgetVariation()inthashCode()static ResourceReferenceof(java.lang.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 ResourceReferenceof(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.java.lang.StringtoString()
-
-
-
Constructor Detail
-
ResourceReference
public ResourceReference(ResourceReference.Key key)
Creates newResourceReferenceinstance.- Parameters:
key- The data making up the resource reference
-
ResourceReference
public ResourceReference(java.lang.Class<?> scope, java.lang.String name, java.util.Locale locale, java.lang.String style, java.lang.String variation)Creates newResourceReferenceinstance.- Parameters:
scope- mandatory parametername- mandatory parameterlocale- resource localestyle- resource stylevariation- resource variation
-
ResourceReference
public ResourceReference(java.lang.Class<?> scope, java.lang.String name)Creates newResourceReferenceinstance.- Parameters:
scope- mandatory parametername- mandatory parameter
-
ResourceReference
public ResourceReference(java.lang.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.
-
getName
public java.lang.String getName()
- Returns:
- name
-
getExtension
public final java.lang.String getExtension()
returns extension of the resource reference- Returns:
- extension of the resource's name in lower-case or
nullif there is no extension
-
getScope
public java.lang.Class<?> getScope()
- Returns:
- scope
-
getLocale
public java.util.Locale getLocale()
- Returns:
- locale
-
getStyle
public java.lang.String getStyle()
- Returns:
- style
-
getVariation
public java.lang.String getVariation()
- Returns:
- variation
-
canBeRegistered
public boolean canBeRegistered()
Can be used to disable registering certain resource references inResourceReferenceRegistry.- Returns:
trueif this reference can be registered,falseotherwise.
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object- See Also:
Object.equals(java.lang.Object)
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object- 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(java.lang.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.Keyto use with the resourceresourceSupplier- Lambda supplier to build the resource- Returns:
- the new resource reference
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getDependencies
public java.util.List<HeaderItem> getDependencies()
- Returns:
- the resources this ResourceReference depends on.
-
-