java.lang.Object
church.i18n.processing.message.ContextValue
All Implemented Interfaces:
Serializable

public class ContextValue extends Object implements Serializable
See Also:
  • Constructor Details

    • ContextValue

      public ContextValue(@Nullable @Nullable Serializable value, @Nullable @Nullable ValueType valueType)
      Constructor of a value with its type.
      Parameters:
      value - Value or data you want to assign.
      valueType - The type of the value argument you have provided. For example when value is string you may specify what type of data it carries, e.g. List, Enum, Regular expression or so. When it is an object you can closely specify what format of object it is — e.g., JSON, XML.
    • ContextValue

      public ContextValue(@Nullable @Nullable Serializable value, @Nullable @Nullable String valueType)
      Constructor of a value with its type.
      Parameters:
      value - Value or data you want to assign.
      valueType - The type of the value argument you have provided. For example when value is string you may specify what type of data it carries, e.g. List, Enum, Regular expression or so. When it is an object you can closely specify what format of object it is — e.g., JSON, XML.
    • ContextValue

      public ContextValue(@Nullable @Nullable Serializable value)
      Constructor of a value without specifying a type.
      Parameters:
      value - Value or data you want to assign.
  • Method Details

    • fromCollection

      @NotNull public static <C> @NotNull ContextValue fromCollection(@Nullable @Nullable Collection<C> collection, @NotNull @NotNull ValueType type)
      Constructs a ContextValue from collection and assign the type of collection.
      Type Parameters:
      C - Type of objects in the collection.
      Parameters:
      collection - Collections of values.
      type - Type of a collection.
      Returns:
      A ContextValue with collection values and it's type.
    • fromEnum

      @NotNull public static <E extends Enum<E>> @NotNull ContextValue fromEnum(@Nullable @Nullable Class<E> enumeration)
      Constructs a ContextValue from all enumeration values.
      Type Parameters:
      E - Enum type.
      Parameters:
      enumeration - Enum to use.
      Returns:
      A ContextValue with array of all enum values and as value type ValueType.ENUM is used.
    • fromEnum

      @SafeVarargs @NotNull public static <E extends Enum<E>> @NotNull ContextValue fromEnum(@Nullable @Nullable Enum<E>... enumeration)
      Constructs a ContextValue from listed enum values.
      Type Parameters:
      E - Enum type.
      Parameters:
      enumeration - List of enum values to use (Could be only subset of the enum)
      Returns:
      A ContextValue with array of listed enum values and as value type ValueType.ENUM is used.
    • fromList

      @NotNull public static <L> @NotNull ContextValue fromList(@Nullable @Nullable List<L> list)
      Constructs a ContextValue from list of values.
      Type Parameters:
      L - Type of objects in the list.
      Parameters:
      list - List of values to use.
      Returns:
      A ContextValue with array of list values and as value type ValueType.LIST is used.
    • fromMap

      @NotNull public static <K, V> @NotNull ContextValue fromMap(@Nullable @Nullable Map<K,V> map)
      Constructs a ContextValue from map of key-value entries.
      Type Parameters:
      K - Type of map keys.
      V - Type of values in the map.
      Parameters:
      map - Map of key-pair entries to use.
      Returns:
      A ContextValue with all map key-value entries and as value type ValueType.MAP is used.
    • fromSet

      @NotNull public static <S> @NotNull ContextValue fromSet(@Nullable @Nullable Set<S> set)
      Constructs a ContextValue from set of values.
      Type Parameters:
      S - Type of objects in the set.
      Parameters:
      set - Set of values to use.
      Returns:
      A ContextValue with array of set values and as value type ValueType.SET is used.
    • getValue

      @Nullable public @Nullable Object getValue()
      Get assigned value.
      Returns:
      Assigned value.
    • getValueType

      @Nullable public @Nullable String getValueType()
      Get assigned value type.
      Returns:
      Assigned value type.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • toString

      @NotNull public @NotNull String toString()
      Overrides:
      toString in class Object