Class ResourceReference

    • Constructor Detail

      • ResourceReference

        public ResourceReference​(Class<?> scope,
                                 String name,
                                 Locale locale,
                                 String style,
                                 String variation)
        Creates new ResourceReference instance.
        Parameters:
        scope - mandatory parameter
        name - mandatory parameter
        locale - resource locale
        style - resource style
        variation - resource variation
      • ResourceReference

        public ResourceReference​(Class<?> scope,
                                 String name)
        Creates new ResourceReference instance.
        Parameters:
        scope - mandatory parameter
        name - 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.
      • getName

        public String getName()
        Returns:
        name
      • 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
      • getScope

        public Class<?> getScope()
        Returns:
        scope
      • getLocale

        public Locale getLocale()
        Returns:
        locale
      • getStyle

        public String getStyle()
        Returns:
        style
      • getVariation

        public String getVariation()
        Returns:
        variation
      • canBeRegistered

        public boolean canBeRegistered()
        Can be used to disable registering certain resource references in ResourceReferenceRegistry.
        Returns:
        true if this reference can be registered, false otherwise.
      • 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 resource
        resourceSupplier - 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 - The ResourceReference.Key to use with the resource
        resourceSupplier - Lambda supplier to build the resource
        Returns:
        the new resource reference
      • getDependencies

        public List<HeaderItem> getDependencies()
        Returns:
        the resources this ResourceReference depends on.