Interface Instructions

  • All Superinterfaces:
    java.util.Map<java.lang.String,​java.lang.Object>
    All Known Subinterfaces:
    Layer

    public interface Instructions
    extends java.util.Map<java.lang.String,​java.lang.Object>
    An extended map storing key-value instructions for rendering plans.

    Provides type conversion and default value handling through generic getters and a convenience setter method allowing for chained operations.

    Type Conversions

    When values are added to the instructions, they will be stored as is. Any type conversion is done on reading only, using get(String, Class) or get(String, Object), depending on what format the consumer requires.

    When getting an object a consumer could ask for an object <T> or for a String. The list below shows the availabe conversions between <T> and String, which will work in both ways (parsing string to retrieve object or serializing the object as string).

    Available type conversions between String and <T>:
    • Boolean: true if string is "1"
    • Integer: normal decimal representation "123" using Integer.toString(int)
    • Float: normal floating point representation "3.14" using Float.toString(float)
    • Dimension: represented as "width,height"
    • Rectangle: represented as "x,y,width,height"
    • other Objects are represented using Object.toString() when converted to string, but cannot be parsed from a string
    • Nested Class Summary

      • Nested classes/interfaces inherited from interface java.util.Map

        java.util.Map.Entry<K extends java.lang.Object,​V extends java.lang.Object>
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      <T> T get​(java.lang.String name, java.lang.Class<T> type)
      Get a named property and convert it into the given type if necessary.
      <T> T get​(java.lang.String name, T defaultValue)
      Get a named property and convert it into the type given by the defaultValue argument, if necessary.
      <T> Instructions set​(java.lang.String name, T value)
      Sets the value of a named property.
      • Methods inherited from interface java.util.Map

        clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
    • Method Detail

      • get

        <T> T get​(java.lang.String name,
                  java.lang.Class<T> type)
        Get a named property and convert it into the given type if necessary. If the property is not present or cannot be converted, return null.
        Parameters:
        name - The name of the property
        type - The class of the type
        Returns:
        Return named value converted to type T or null if non existing or cannot be converted.
        See Also:
        class javadoc for available type conversions
      • get

        <T> T get​(java.lang.String name,
                  T defaultValue)
        Get a named property and convert it into the type given by the defaultValue argument, if necessary. If the property is not present or cannot be converted, return the defaultValue.
        Parameters:
        name - The name of the property
        defaultValue - The default value to use if the named property does not exist or cannot be converted to the requested type. The default value is also used to define the type to convert the value to. If this is null any existing property is not converted.
        Returns:
        Return named value converted to type T or the default value if non existing or cannot be converted.
        See Also:
        class javadoc for available type conversions
      • set

        <T> Instructions set​(java.lang.String name,
                             T value)
        Sets the value of a named property.

        This allows chaining by returning the Instructions itself. Note that the object will be stored as is and no conversion will happen.

        Parameters:
        name - The name of the property
        value - The value to set.
        Returns:
        Returns this to allow for method chaining.