Class FractionConverter.FromInteger

All Implemented Interfaces:
Serializable, Function<Integer,Fraction>, ObjectConverter<Integer,Fraction>
Enclosing class:
FractionConverter

public static final class FractionConverter.FromInteger extends SystemConverter<Integer,Fraction>
The inverse of FractionConverter.
See Also:
  • Field Details

  • Constructor Details

    • FromInteger

      public FromInteger()
      Creates a new converter. Only one instance is enough, but this constructor needs to be public for allowing invocation by ServiceLoader.
  • Method Details

    • unique

      public ObjectConverter<Integer,Fraction> unique()
      Description copied from class: SystemConverter
      Returns an unique instance of this converter if one exists. If a converter already exists for the same source an target classes, then this converter is returned. Otherwise this converter is returned without being cached.
      Overrides:
      unique in class SystemConverter<Integer,Fraction>
      Returns:
      the unique instance, or this if no unique instance can be found.
      See Also:
    • inverse

      public ObjectConverter<Fraction,Integer> inverse()
      Description copied from class: SystemConverter
      Default to non-invertible conversion. Must be overridden by subclasses that support inversions.
      Specified by:
      inverse in interface ObjectConverter<Integer,Fraction>
      Overrides:
      inverse in class SystemConverter<Integer,Fraction>
      Returns:
      a converter for converting instances of T back to instances of S.
      See Also:
    • properties

      public Set<FunctionProperty> properties()
      Description copied from interface: ObjectConverter
      Returns the manner in which source values (S) are mapped to target values (T). Some possible function properties are:
      • Injective if no pair of S can produce the same T value (e.g.: conversions from Integer to String).
      • Surjective if every values of T can be created from one or many values of S (e.g.: conversions from String to Integer).
      • Bijective if there is a one-to-one relationship between the S and T values.
      • Order preserving if any sequence of increasing S values (in the sense of Comparable) is mapped to a sequence of increasing T values.
      • Order reversing if any sequence of increasing S values (in the sense of Comparable) is mapped to a sequence of decreasing T values.
      Note that if the ObjectConverter.apply(Object) method returns null for unconvertible source values, then this properties set cannot contain FunctionProperty.INJECTIVE because more than one source value could be converted to the same null target value.
      Returns:
      the manners in which source values are mapped to target values. May be an empty set, but never null.
    • apply

      public Fraction apply(Integer value)
      Creates a new fraction from the given integer.
      Parameters:
      value - the integer to convert.
      Returns:
      a fraction equals to the given integer.