Package net.mtrop.doom.map
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 TypeMethodDescriptiondefault 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
Gets the corresponding value on the element as a double.default double
Gets the corresponding value on the element as a double.default Float
Gets the corresponding value on the element as a float.default float
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
Gets the corresponding value on the element as a long.default long
Gets the corresponding value on the element as a double.default String
Gets the corresponding value on the element as a String.default String
Gets the corresponding value on the element as a String.Gets the corresponding value on the element.
-
Method Details
-
getValue
Gets the corresponding value on the element. If the field type is not valid for this element, this returnsnull
.- 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
Gets the corresponding value on the element as a boolean. If the field type is not valid for this element, this returnsnull
. Numeric values returntrue
if nonzero, and String values aretrue
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
Gets the corresponding value on the element as a boolean. If the field type is not valid for this element, this returnsdef
. Numeric values returntrue
if nonzero, and String values aretrue
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
Gets the corresponding value on the element as an integer. If the field type is not valid for this element, this returnsnull
. Boolean values return1
if true, and String values are converted to integer (ornull
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
Gets the corresponding value on the element as an integer. If the field type is not valid for this element, this returnsdef
. Boolean values return1
if true0
if false, and String values are converted to integer (ordef
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
Gets the corresponding value on the element as a float. If the field type is not valid for this element, this returnsnull
. Boolean values return1f
if true,0f
if false, and String values are converted to float (ornull
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
Gets the corresponding value on the element as a float. If the field type is not valid for this element, this returnsdef
. Boolean values return1f
if true,0f
if false, and String values are converted to float (ordef
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
Gets the corresponding value on the element as a long. If the field type is not valid for this element, this returnsnull
. Boolean values return1L
if true,0L
if false, and String values are converted to long (ornull
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
Gets the corresponding value on the element as a double. If the field type is not valid for this element, this returnsdef
. Boolean values return1L
if true,0L
if false, and String values are converted to long (ordef
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
Gets the corresponding value on the element as a double. If the field type is not valid for this element, this returnsnull
. Boolean values return1.0
if true,0.0
if false, and String values are converted to double (ornull
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
Gets the corresponding value on the element as a double. If the field type is not valid for this element, this returnsnull
. Boolean values return1.0
if true,0.0
if false, and String values are converted to double (ornull
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
Gets the corresponding value on the element as a String. If the field type is not valid for this element, this returnsnull
. 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
Gets the corresponding value on the element as a String. If the field type is not valid for this element, this returnsdef
. 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.
-