Class CustomPropertyProvider

java.lang.Object
de.gurkenlabs.litiengine.environment.tilemap.xml.CustomPropertyProvider
All Implemented Interfaces:
ICustomPropertyProvider
Direct Known Subclasses:
GameInfo, Layer, MapImage, MapObject, Material, Tile, Tileset, TilesetEntry, TmxMap, WangSet

public class CustomPropertyProvider extends Object implements ICustomPropertyProvider
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    CustomPropertyProvider(ICustomPropertyProvider propertyProviderToBeCopied)
    Copy Constructor for copying instances of CustomPropertyProviders.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    getBoolValue(String propertyName)
    Gets the boolean value of the custom property with the provided name.
    boolean
    getBoolValue(String propertyName, boolean defaultValue)
    Gets the boolean value of the custom property with the provided name.
    byte
    getByteValue(String propertyName)
    Gets the byte value of the custom property with the provided name.
    byte
    getByteValue(String propertyName, byte defaultValue)
    Gets the byte value of the custom property with the provided name.
    char
    getCharValue(String propertyName)
    Gets the char value of the custom property with the provided name.
    char
    getCharValue(String propertyName, char defaultValue)
    Gets the char value of the custom property with the provided name.
    getColorValue(String propertyName)
    Gets the color value of the custom property with the provided name.
    getColorValue(String propertyName, Color defaultValue)
    Gets the color value of the custom property with the provided name.
    getCommaSeparatedStringValues(String propertyName, String defaultValue)
    Gets a list of strings stored in a single comma-separated property.
    double
    getDoubleValue(String propertyName)
    Gets the double value of the custom property with the provided name.
    double
    getDoubleValue(String propertyName, double defaultValue)
    Gets the double value of the custom property with the provided name.
    <T extends Enum<T>>
    T
    getEnumValue(String propertyName, Class<T> enumType)
    Gets the enum value of the custom property with the provided name.
    <T extends Enum<T>>
    T
    getEnumValue(String propertyName, Class<T> enumType, T defaultValue)
    Gets the enum value of the custom property with the provided name.
    getFileValue(String propertyName)
    Gets the file value of the custom property with the provided name.
    getFileValue(String propertyName, URL defaultValue)
    Gets the file value of the custom property with the provided name.
    float
    getFloatValue(String propertyName)
    Gets the float value of the custom property with the provided name.
    float
    getFloatValue(String propertyName, float defaultValue)
    Gets the float value of the custom property with the provided name.
    int
    getIntValue(String propertyName)
    Gets the int value of the custom property with the provided name.
    int
    getIntValue(String propertyName, int defaultValue)
    Gets the int value of the custom property with the provided name.
    long
    getLongValue(String propertyName)
    Gets the long value of the custom property with the provided name.
    long
    getLongValue(String propertyName, long defaultValue)
    Gets the long value of the custom property with the provided name.
    int
    getMapObjectId(String propertyName)
     
    Returns a Map view of the custom properties for this ICustomPropertyProvider.
    getProperty(String propertyName)
     
    short
    getShortValue(String propertyName)
    Gets the short value of the custom property with the provided name.
    short
    getShortValue(String propertyName, short defaultValue)
    Gets the short value of the custom property with the provided name.
    getStringValue(String propertyName)
    Gets the string value of the custom property with the provided name.
    getStringValue(String propertyName, String defaultValue)
    Gets the string value of the custom property with the provided name.
    boolean
    hasCustomProperty(String propertyName)
    Checks if a custom property with the given name is present.
    void
    removeProperty(String propertyName)
     
    void
    Sets all the custom properties on this object to the provided values.
    void
    setValue(String propertyName, boolean value)
    Sets the value for the custom property with the given name to the given boolean.
    void
    setValue(String propertyName, byte value)
    Sets the value for the custom property with the given name to the given byte.
    void
    setValue(String propertyName, char value)
    Sets the value for the custom property with the given name to the given char.
    void
    setValue(String propertyName, double value)
    Sets the value for the custom property with the given name to the given double.
    void
    setValue(String propertyName, float value)
    Sets the value for the custom property with the given name to the given float.
    void
    setValue(String propertyName, int value)
    Sets the value for the custom property with the given name to the given int.
    void
    setValue(String propertyName, long value)
    Sets the value for the custom property with the given name to the given long.
    void
    setValue(String propertyName, short value)
    Sets the value for the custom property with the given name to the given short.
    void
    setValue(String propertyName, ICustomProperty value)
     
    void
    setValue(String propertyName, IMapObject value)
    Sets the value for the custom property with the ID of the given map object.
    void
    setValue(String propertyName, Color value)
    Sets the value for the custom property with the given name to the given color.
    void
    setValue(String propertyName, Enum<?> value)
    Sets the value for the custom property with the given name to the given enum.
    void
    setValue(String propertyName, String value)
    Sets the value for the custom property with the given name to the given string.
    void
    setValue(String propertyName, URL value)
    Sets the value for the custom property with the given name to the given file.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CustomPropertyProvider

      public CustomPropertyProvider()
    • CustomPropertyProvider

      public CustomPropertyProvider(ICustomPropertyProvider propertyProviderToBeCopied)
      Copy Constructor for copying instances of CustomPropertyProviders.
      Parameters:
      propertyProviderToBeCopied - the PropertyProvider we want to copy
  • Method Details

    • getProperties

      public Map<String,ICustomProperty> getProperties()
      Description copied from interface: ICustomPropertyProvider
      Returns a Map view of the custom properties for this ICustomPropertyProvider.
      Specified by:
      getProperties in interface ICustomPropertyProvider
      Returns:
      a Map view of the custom properties for this ICustomPropertyProvider
    • hasCustomProperty

      public boolean hasCustomProperty(String propertyName)
      Description copied from interface: ICustomPropertyProvider
      Checks if a custom property with the given name is present.
      Specified by:
      hasCustomProperty in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      Returns:
      true if a custom property with the given name is present. False otherwise.
    • getProperty

      public ICustomProperty getProperty(String propertyName)
      Specified by:
      getProperty in interface ICustomPropertyProvider
    • setValue

      public void setValue(String propertyName, ICustomProperty value)
      Specified by:
      setValue in interface ICustomPropertyProvider
    • getStringValue

      public String getStringValue(String propertyName)
      Description copied from interface: ICustomPropertyProvider
      Gets the string value of the custom property with the provided name.
      Specified by:
      getStringValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      Returns:
      the string value of the custom property
    • getStringValue

      public String getStringValue(String propertyName, String defaultValue)
      Description copied from interface: ICustomPropertyProvider
      Gets the string value of the custom property with the provided name. If the value is null, the provided default value is used as a fallback.
      Specified by:
      getStringValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      defaultValue - the fallback value in case the property value is null.
      Returns:
      the string value of the custom property, if present. Otherwise, the provided default value is returned.
    • getCharValue

      public char getCharValue(String propertyName)
      Description copied from interface: ICustomPropertyProvider
      Gets the char value of the custom property with the provided name.
      Specified by:
      getCharValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      Returns:
      the char value of the custom property
    • getCharValue

      public char getCharValue(String propertyName, char defaultValue)
      Description copied from interface: ICustomPropertyProvider
      Gets the char value of the custom property with the provided name. If the value is null, the provided default value is used as a fallback.
      Specified by:
      getCharValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      defaultValue - the fallback value in case the property value is null.
      Returns:
      the char value of the custom property, if present. Otherwise, the provided default value is returned.
    • getIntValue

      public int getIntValue(String propertyName)
      Description copied from interface: ICustomPropertyProvider
      Gets the int value of the custom property with the provided name.
      Specified by:
      getIntValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      Returns:
      the int value of the custom property
    • getIntValue

      public int getIntValue(String propertyName, int defaultValue)
      Description copied from interface: ICustomPropertyProvider
      Gets the int value of the custom property with the provided name. If the value is null, the provided default value is used as a fallback.
      Specified by:
      getIntValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      defaultValue - the fallback value in case the property value is null.
      Returns:
      the int value of the custom property, if present. Otherwise, the provided default value is returned.
    • getLongValue

      public long getLongValue(String propertyName)
      Description copied from interface: ICustomPropertyProvider
      Gets the long value of the custom property with the provided name.
      Specified by:
      getLongValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      Returns:
      the long value of the custom property
    • getLongValue

      public long getLongValue(String propertyName, long defaultValue)
      Description copied from interface: ICustomPropertyProvider
      Gets the long value of the custom property with the provided name. If the value is null, the provided default value is used as a fallback.
      Specified by:
      getLongValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      defaultValue - the fallback value in case the property value is null.
      Returns:
      the long value of the custom property, if present. Otherwise, the provided default value is returned.
    • getShortValue

      public short getShortValue(String propertyName)
      Description copied from interface: ICustomPropertyProvider
      Gets the short value of the custom property with the provided name.
      Specified by:
      getShortValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      Returns:
      the short value of the custom property
    • getShortValue

      public short getShortValue(String propertyName, short defaultValue)
      Description copied from interface: ICustomPropertyProvider
      Gets the short value of the custom property with the provided name. If the value is null, the provided default value is used as a fallback.
      Specified by:
      getShortValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      defaultValue - the fallback value in case the property value is null.
      Returns:
      the short value of the custom property, if present. Otherwise, the provided default value is returned.
    • getByteValue

      public byte getByteValue(String propertyName)
      Description copied from interface: ICustomPropertyProvider
      Gets the byte value of the custom property with the provided name.
      Specified by:
      getByteValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      Returns:
      the byte value of the custom property
    • getByteValue

      public byte getByteValue(String propertyName, byte defaultValue)
      Description copied from interface: ICustomPropertyProvider
      Gets the byte value of the custom property with the provided name. If the value is null, the provided default value is used as a fallback.
      Specified by:
      getByteValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      defaultValue - the fallback value in case the property value is null.
      Returns:
      the byte value of the custom property, if present. Otherwise, the provided default value is returned.
    • getBoolValue

      public boolean getBoolValue(String propertyName)
      Description copied from interface: ICustomPropertyProvider
      Gets the boolean value of the custom property with the provided name.
      Specified by:
      getBoolValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      Returns:
      the boolean value of the custom property
    • getBoolValue

      public boolean getBoolValue(String propertyName, boolean defaultValue)
      Description copied from interface: ICustomPropertyProvider
      Gets the boolean value of the custom property with the provided name. If the value is null, the provided default value is used as a fallback.
      Specified by:
      getBoolValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      defaultValue - the fallback value in case the property value is null.
      Returns:
      the boolean value of the custom property, if present. Otherwise, the provided default value is returned.
    • getFloatValue

      public float getFloatValue(String propertyName)
      Description copied from interface: ICustomPropertyProvider
      Gets the float value of the custom property with the provided name.
      Specified by:
      getFloatValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      Returns:
      the float value of the custom property
    • getFloatValue

      public float getFloatValue(String propertyName, float defaultValue)
      Description copied from interface: ICustomPropertyProvider
      Gets the float value of the custom property with the provided name. If the value is null, the provided default value is used as a fallback.
      Specified by:
      getFloatValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      defaultValue - the fallback value in case the property value is null.
      Returns:
      the float value of the custom property, if present. Otherwise, the provided default value is returned.
    • getDoubleValue

      public double getDoubleValue(String propertyName)
      Description copied from interface: ICustomPropertyProvider
      Gets the double value of the custom property with the provided name.
      Specified by:
      getDoubleValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      Returns:
      the double value of the custom property
    • getDoubleValue

      public double getDoubleValue(String propertyName, double defaultValue)
      Description copied from interface: ICustomPropertyProvider
      Gets the double value of the custom property with the provided name. If the value is null, the provided default value is used as a fallback.
      Specified by:
      getDoubleValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      defaultValue - the fallback value in case the property value is null.
      Returns:
      the double value of the custom property, if present. Otherwise, the provided default value is returned.
    • getColorValue

      public Color getColorValue(String propertyName)
      Description copied from interface: ICustomPropertyProvider
      Gets the color value of the custom property with the provided name.
      Specified by:
      getColorValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      Returns:
      the color value of the custom property
    • getColorValue

      public Color getColorValue(String propertyName, Color defaultValue)
      Description copied from interface: ICustomPropertyProvider
      Gets the color value of the custom property with the provided name. If the value is null, the provided default value is used as a fallback.
      Specified by:
      getColorValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      defaultValue - the fallback value in case the property value is null.
      Returns:
      the color value of the custom property, if present. Otherwise, the provided default value is returned.
    • getEnumValue

      public <T extends Enum<T>> T getEnumValue(String propertyName, Class<T> enumType)
      Description copied from interface: ICustomPropertyProvider
      Gets the enum value of the custom property with the provided name.
      Specified by:
      getEnumValue in interface ICustomPropertyProvider
      Type Parameters:
      T - the enum type to use
      Parameters:
      propertyName - the name of the custom property
      enumType - a Class object for <T>
      Returns:
      the enum value of the custom property
    • getEnumValue

      public <T extends Enum<T>> T getEnumValue(String propertyName, Class<T> enumType, T defaultValue)
      Description copied from interface: ICustomPropertyProvider
      Gets the enum value of the custom property with the provided name. If the value is null, the provided default value is used as a fallback.
      Specified by:
      getEnumValue in interface ICustomPropertyProvider
      Type Parameters:
      T - the enum type to use
      Parameters:
      propertyName - the name of the custom property
      enumType - a Class object for <T>
      defaultValue - the fallback value in case the property value is null.
      Returns:
      the enum value of the custom property, if present. Otherwise, the provided default value is returned.
    • getFileValue

      public URL getFileValue(String propertyName)
      Description copied from interface: ICustomPropertyProvider
      Gets the file value of the custom property with the provided name. If the property is not a file, null is returned instead.
      Specified by:
      getFileValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      Returns:
      the file value of the custom property, if present.
    • getFileValue

      public URL getFileValue(String propertyName, URL defaultValue)
      Description copied from interface: ICustomPropertyProvider
      Gets the file value of the custom property with the provided name. If the value is null or the property is not a file, the provided default value is used as a fallback.
      Specified by:
      getFileValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      defaultValue - the fallback value in case the property value is null.
      Returns:
      the file value of the custom property, if present. Otherwise, the provided default value is returned.
    • getMapObjectId

      public int getMapObjectId(String propertyName)
      Specified by:
      getMapObjectId in interface ICustomPropertyProvider
    • setValue

      public void setValue(String propertyName, URL value)
      Description copied from interface: ICustomPropertyProvider
      Sets the value for the custom property with the given name to the given file.
      Specified by:
      setValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      value - the new value
    • setValue

      public void setValue(String propertyName, String value)
      Description copied from interface: ICustomPropertyProvider
      Sets the value for the custom property with the given name to the given string.
      Specified by:
      setValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      value - the new value
    • setValue

      public void setValue(String propertyName, boolean value)
      Description copied from interface: ICustomPropertyProvider
      Sets the value for the custom property with the given name to the given boolean.
      Specified by:
      setValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      value - the new value
    • setValue

      public void setValue(String propertyName, byte value)
      Description copied from interface: ICustomPropertyProvider
      Sets the value for the custom property with the given name to the given byte.
      Specified by:
      setValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      value - the new value
    • setValue

      public void setValue(String propertyName, short value)
      Description copied from interface: ICustomPropertyProvider
      Sets the value for the custom property with the given name to the given short.
      Specified by:
      setValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      value - the new value
    • setValue

      public void setValue(String propertyName, char value)
      Description copied from interface: ICustomPropertyProvider
      Sets the value for the custom property with the given name to the given char.
      Specified by:
      setValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      value - the new value
    • setValue

      public void setValue(String propertyName, int value)
      Description copied from interface: ICustomPropertyProvider
      Sets the value for the custom property with the given name to the given int.
      Specified by:
      setValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      value - the new value
    • setValue

      public void setValue(String propertyName, long value)
      Description copied from interface: ICustomPropertyProvider
      Sets the value for the custom property with the given name to the given long.
      Specified by:
      setValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      value - the new value
    • setValue

      public void setValue(String propertyName, float value)
      Description copied from interface: ICustomPropertyProvider
      Sets the value for the custom property with the given name to the given float.
      Specified by:
      setValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      value - the new value
    • setValue

      public void setValue(String propertyName, double value)
      Description copied from interface: ICustomPropertyProvider
      Sets the value for the custom property with the given name to the given double.
      Specified by:
      setValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      value - the new value
    • setValue

      public void setValue(String propertyName, Color value)
      Description copied from interface: ICustomPropertyProvider
      Sets the value for the custom property with the given name to the given color.
      Specified by:
      setValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      value - the new value
    • setValue

      public void setValue(String propertyName, Enum<?> value)
      Description copied from interface: ICustomPropertyProvider
      Sets the value for the custom property with the given name to the given enum.
      Specified by:
      setValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      value - the new value
    • setValue

      public void setValue(String propertyName, IMapObject value)
      Description copied from interface: ICustomPropertyProvider
      Sets the value for the custom property with the ID of the given map object.
      Specified by:
      setValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      value - the new value
    • setProperties

      public void setProperties(Map<String,ICustomProperty> props)
      Description copied from interface: ICustomPropertyProvider
      Sets all the custom properties on this object to the provided values. Properties are added when they only exist in the provided properties, and deleted when they only exist in the current properties.
      Specified by:
      setProperties in interface ICustomPropertyProvider
      Parameters:
      props - the new list of properties
    • removeProperty

      public void removeProperty(String propertyName)
      Specified by:
      removeProperty in interface ICustomPropertyProvider
    • getCommaSeparatedStringValues

      public List<String> getCommaSeparatedStringValues(String propertyName, String defaultValue)
      Description copied from interface: ICustomPropertyProvider
      Gets a list of strings stored in a single comma-separated property.
      Specified by:
      getCommaSeparatedStringValues in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      defaultValue - the fallback value in case the property value is null.
      Returns:
      the list of comma-separated strings in the custom property, if present. Otherwise, the provided default value is returned.