Interface MapElementView<T>

Type Parameters:
T - the type of element that this handles.

public interface MapElementView<T>
This class provides a means for reading map data in a data- or implementation-agnostic way. Each of the methods take an arbitrary field type enumeration. Each implementation of this view should be clear as to what those valid values are.
Since:
2.6.0
Author:
Matthew Tropiano
  • Method Summary

    Modifier and Type
    Method
    Description
    default Boolean
    getBoolean(T source, int fieldType)
    Gets the corresponding value on the element as a boolean.
    default boolean
    getBoolean(T source, int fieldType, boolean def)
    Gets the corresponding value on the element as a boolean.
    default Double
    getDouble(T source, int fieldType)
    Gets the corresponding value on the element as a double.
    default double
    getDouble(T source, int fieldType, double def)
    Gets the corresponding value on the element as a double.
    default Float
    getFloat(T source, int fieldType)
    Gets the corresponding value on the element as a float.
    default float
    getFloat(T source, int fieldType, float def)
    Gets the corresponding value on the element as a float.
    default Integer
    getInteger(T source, int fieldType)
    Gets the corresponding value on the element as an integer.
    default int
    getInteger(T source, int fieldType, int def)
    Gets the corresponding value on the element as an integer.
    default Long
    getLong(T source, int fieldType)
    Gets the corresponding value on the element as a long.
    default long
    getLong(T source, int fieldType, long def)
    Gets the corresponding value on the element as a double.
    default String
    getString(T source, int fieldType)
    Gets the corresponding value on the element as a String.
    default String
    getString(T source, int fieldType, String def)
    Gets the corresponding value on the element as a String.
    getValue(T source, int fieldType)
    Gets the corresponding value on the element.
  • Method Details

    • getValue

      Object getValue(T source, int fieldType)
      Gets the corresponding value on the element. If the field type is not valid for this element, this returns null.
      Parameters:
      source - the source object.
      fieldType - the field type to retrieve.
      Returns:
      the corresponding value or null if the field type is not valid.
    • getBoolean

      default Boolean getBoolean(T source, int fieldType)
      Gets the corresponding value on the element as a boolean. If the field type is not valid for this element, this returns null. Numeric values return true if nonzero, and String values are true if they are not blank.
      Parameters:
      source - the source object.
      fieldType - the field type to retrieve.
      Returns:
      the corresponding value or null if the field type is not valid.
    • getBoolean

      default boolean getBoolean(T source, int fieldType, boolean def)
      Gets the corresponding value on the element as a boolean. If the field type is not valid for this element, this returns def. Numeric values return true if nonzero, and String values are true if they are not blank.
      Parameters:
      source - the source object.
      fieldType - the field type to retrieve.
      def - the default value to return if the field type is not valid.
      Returns:
      the corresponding value or def if the field type is not valid.
    • getInteger

      default Integer getInteger(T source, int fieldType)
      Gets the corresponding value on the element as an integer. If the field type is not valid for this element, this returns null. Boolean values return 1 if true, and String values are converted to integer (or null if not convertible).
      Parameters:
      source - the source object.
      fieldType - the field type to retrieve.
      Returns:
      the corresponding value or null if the field type is not valid.
    • getInteger

      default int getInteger(T source, int fieldType, int def)
      Gets the corresponding value on the element as an integer. If the field type is not valid for this element, this returns def. Boolean values return 1 if true 0 if false, and String values are converted to integer (or def if not convertible).
      Parameters:
      source - the source object.
      fieldType - the field type to retrieve.
      def - the default value to return if the field type is not valid.
      Returns:
      the corresponding value or def if the field type is not valid.
    • getFloat

      default Float getFloat(T source, int fieldType)
      Gets the corresponding value on the element as a float. If the field type is not valid for this element, this returns null. Boolean values return 1f if true, 0f if false, and String values are converted to float (or null if not convertible).
      Parameters:
      source - the source object.
      fieldType - the field type to retrieve.
      Returns:
      the corresponding value or null if the field type is not valid.
    • getFloat

      default float getFloat(T source, int fieldType, float def)
      Gets the corresponding value on the element as a float. If the field type is not valid for this element, this returns def. Boolean values return 1f if true, 0f if false, and String values are converted to float (or def if not convertible).
      Parameters:
      source - the source object.
      fieldType - the field type to retrieve.
      def - the default value to return if the field type is not valid.
      Returns:
      the corresponding value or def if the field type is not valid.
    • getLong

      default Long getLong(T source, int fieldType)
      Gets the corresponding value on the element as a long. If the field type is not valid for this element, this returns null. Boolean values return 1L if true, 0L if false, and String values are converted to long (or null if not convertible).
      Parameters:
      source - the source object.
      fieldType - the field type to retrieve.
      Returns:
      the corresponding value or null if the field type is not valid.
    • getLong

      default long getLong(T source, int fieldType, long def)
      Gets the corresponding value on the element as a double. If the field type is not valid for this element, this returns def. Boolean values return 1L if true, 0L if false, and String values are converted to long (or def if not convertible).
      Parameters:
      source - the source object.
      fieldType - the field type to retrieve.
      def - the default value to return if the field type is not valid.
      Returns:
      the corresponding value or def if the field type is not valid.
    • getDouble

      default Double getDouble(T source, int fieldType)
      Gets the corresponding value on the element as a double. If the field type is not valid for this element, this returns null. Boolean values return 1.0 if true, 0.0 if false, and String values are converted to double (or null if not convertible).
      Parameters:
      source - the source object.
      fieldType - the field type to retrieve.
      Returns:
      the corresponding value or null if the field type is not valid.
    • getDouble

      default double getDouble(T source, int fieldType, double def)
      Gets the corresponding value on the element as a double. If the field type is not valid for this element, this returns null. Boolean values return 1.0 if true, 0.0 if false, and String values are converted to double (or null if not convertible).
      Parameters:
      source - the source object.
      fieldType - the field type to retrieve.
      def - the default value to return if the field type is not valid.
      Returns:
      the corresponding value or def if the field type is not valid.
    • getString

      default String getString(T source, int fieldType)
      Gets the corresponding value on the element as a String. If the field type is not valid for this element, this returns null. If the value is not a String, it will be converted to one.
      Parameters:
      source - the source object.
      fieldType - the field type to retrieve.
      Returns:
      the corresponding value or null if the field type is not valid.
    • getString

      default String getString(T source, int fieldType, String def)
      Gets the corresponding value on the element as a String. If the field type is not valid for this element, this returns def. If the value is not a String, it will be converted to one.
      Parameters:
      source - the source object.
      fieldType - the field type to retrieve.
      def - the default value to return if the field type is not valid.
      Returns:
      the corresponding value or def if the field type is not valid.