Interface TypeContext<T>

  • All Known Implementing Classes:
    BinaryContext, BooleanContext, DateContext, FormatContext, GenericContext, NumberContext, StringContext, TemporalContext

    public interface TypeContext<T>
    A type context provides two basic services:
    1. It enforces some sort of rule/limit regarding size, accuracy or similar. This feature is for instance useful when writing data to a database where attributes are often very specifically typed. "enforcing" is typically a one-way operation that cannot be undone.
    2. It translates back and forth between some specific type and String - essentially a formatter.
    • Method Detail

      • enforce

        default T enforce​(T object)
        Will force the object to conform to the context's specification. The default implementation formats a String and then parses that back to an object (of the original type).
      • format

        java.lang.String format​(java.lang.Object object)
      • parse

        T parse​(java.lang.CharSequence text)