Class MappedResource

All Implemented Interfaces:
Cloneable, Comparable<Resource>, Iterable<Resource>, ResourceCollection

public class MappedResource extends ResourceDecorator
A decorator around a different resource that uses a mapper to dynamically remap the resource's name.

Strips the FileProvider interface from decorated resources since it may be used to circumvent name mapping.

Since:
Ant 1.8.0
  • Constructor Details

    • MappedResource

      public MappedResource(Resource r, FileNameMapper m)
      Wraps an existing resource.
      Parameters:
      r - Resource to wrap
      m - FileNameMapper that handles mapping
  • Method Details

    • getName

      public String getName()
      Maps the name.
      Overrides:
      getName in class ResourceDecorator
      Returns:
      the name of the wrapped resource.
    • setRefid

      public void setRefid(Reference r)
      Not really supported since mapper is never null.
      Overrides:
      setRefid in class ResourceDecorator
      Parameters:
      r - reference to set
    • as

      public <T> T as(Class<T> clazz)
      Suppress FileProvider
      Overrides:
      as in class ResourceDecorator
      Type Parameters:
      T - desired type
      Parameters:
      clazz - the type to implement
      Returns:
      resource of a desired type
    • hashCode

      public int hashCode()
      Get the hash code for this Resource.
      Overrides:
      hashCode in class ResourceDecorator
      Returns:
      hash code as int.
      Since:
      Ant 1.8.1
    • equals

      public boolean equals(Object other)
      Equality check based on the resource's name in addition to the resource itself.
      Overrides:
      equals in class Resource
      Parameters:
      other - the object to check against.
      Returns:
      true if the specified Object is equal to this Resource.
      Since:
      Ant 1.8.1
    • toString

      public String toString()
      Description copied from class: Resource
      Get the string representation of this Resource.
      Overrides:
      toString in class Resource
      Returns:
      this Resource formatted as a String.