Class Cascade


  • public final class Cascade
    extends Object
    Simple map of properties with dynamic typing.
    • Constructor Detail

      • Cascade

        public Cascade()
        Constructs a new Cascade.
      • Cascade

        public Cascade​(Cascade other)
        Constructs a new Cascade from existing one.
        Parameters:
        other - other Cascade
    • Method Detail

      • get

        public <T> T get​(String key,
                         T def,
                         Class<T> klass)
        Gets the value for a given key with the given type
        Type Parameters:
        T - the expected type
        Parameters:
        key - the key
        def - default value, can be null
        klass - the same as T
        Returns:
        if a value that can be converted to class klass has been mapped to key, returns this value, def otherwise
      • get

        public <T> T get​(String key,
                         T def,
                         Class<T> klass,
                         boolean suppressWarnings)
        Get value for the given key
        Type Parameters:
        T - the expected type
        Parameters:
        key - the key
        def - default value, can be null
        klass - the same as T
        suppressWarnings - show or don't show a warning when some value is found, but cannot be converted to the requested type
        Returns:
        if a value that can be converted to class klass has been mapped to key, returns this value, def otherwise
      • get

        public Object get​(String key)
        Gets a property for the given key (like stroke, ...)
        Parameters:
        key - The key of the property
        Returns:
        The value or null if it is not set. May be of any type
      • put

        public void put​(String key,
                        Object val)
        Sets the property for the given key
        Parameters:
        key - The key
        val - The value
      • putOrClear

        public void putOrClear​(String key,
                               Object val)
        Sets the property for the given key, removes it if the value is null
        Parameters:
        key - The key
        val - The value, may be null
      • remove

        public void remove​(String key)
        Removes the property with the given key
        Parameters:
        key - The key
      • convertTo

        public static <T> T convertTo​(Object o,
                                      Class<T> klass)
        Converts an object to a given other class. Only conversions that are useful for MapCSS are supported
        Type Parameters:
        T - The class type
        Parameters:
        o - The object to convert
        klass - The class
        Returns:
        The converted object or null if the conversion failed
      • containsKey

        public boolean containsKey​(String key)
        Checks if this cascade has a value for given key
        Parameters:
        key - The key to check
        Returns:
        true if there is a value
      • isDefaultSelectedHandling

        public boolean isDefaultSelectedHandling()
        Get if the default selection drawing should be used for the object this cascade applies to
        Returns:
        true to use the default selection drawing
      • setDefaultSelectedHandling

        public void setDefaultSelectedHandling​(boolean defaultSelectedHandling)
        Set that the default selection drawing should be used for the object this cascade applies to
        Parameters:
        defaultSelectedHandling - true to use the default selection drawing