Class AbstractToString<N>

java.lang.Object
org.meeuw.configuration.spi.AbstractToString<N>
All Implemented Interfaces:
Comparable<ToStringProvider<?>>, ToStringProvider<N>
Direct Known Subclasses:
BooleanToString, NumberToString

public abstract class AbstractToString<N> extends Object implements ToStringProvider<N>
  • Field Details

    • type

      protected final Class<?> type
  • Constructor Details

    • AbstractToString

      protected AbstractToString(Class<N> type)
  • Method Details

    • weight

      public int weight()
      Specified by:
      weight in interface ToStringProvider<N>
    • toString

      public Optional<String> toString(@Nullable Object value)
      Description copied from interface: ToStringProvider
      For given value, check if the type is supported, and then convert it to a String.
      Specified by:
      toString in interface ToStringProvider<N>
    • valueOf

      protected abstract N valueOf(String value)
    • fromString

      public Optional<N> fromString(Class<?> t, @Nullable String value)
      Description copied from interface: ToStringProvider
      Given a desired type, and a string value, convert it to the supported type. Normally, the given type must be some superclass of C, but it also might be a primitive type.
      Specified by:
      fromString in interface ToStringProvider<N>
    • toWrapper

      protected Class<?> toWrapper(Class<?> clazz)