Class PathConverter<S,T>

All Implemented Interfaces:
Serializable, Function<S,T>, ObjectConverter<S,T>
Direct Known Subclasses:
PathConverter.FilePath, PathConverter.FileURI, PathConverter.FileURL, PathConverter.PathFile, PathConverter.PathURI, PathConverter.PathURL, PathConverter.URI_URL, PathConverter.URIFile, PathConverter.URIPath, PathConverter.URL_URI, PathConverter.URLFile, PathConverter.URLPath

abstract class PathConverter<S,T> extends SystemConverter<S,T>
Handles conversions between Path, File, URI and URL objects.

Immutability and thread safety

This base class and all inner classes are immutable, and thus inherently thread-safe.
Since:
0.3
Version:
0.7
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      For cross-version compatibility.
      See Also:
  • Constructor Details

    • PathConverter

      PathConverter(Class<S> sourceClass, Class<T> targetClass)
      Creates a path converter from the given source class to the given target class.
  • Method Details

    • properties

      public final Set<FunctionProperty> properties()
      Returns the properties of this converter.
      Returns:
      the manners in which source values are mapped to target values. May be an empty set, but never null.
    • apply

      public final T apply(S source) throws UnconvertibleObjectException
      Converts the given path to the target type of this converter. This method verifies that the given path is non-null, then delegates to doConvert(Object).
      Parameters:
      source - the path to convert, or null.
      Returns:
      the converted value, or null if the given path was null.
      Throws:
      UnconvertibleObjectException - if an error occurred during the conversion.
    • doConvert

      abstract T doConvert(S source) throws Exception
      Invoked by apply(Object) for converting the given path to the target type of this converter.
      Parameters:
      source - the path to convert, guaranteed to be non-null.
      Returns:
      the converted path.
      Throws:
      Exception - if an error occurred during the conversion.