Class Cascade


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

      Constructors 
      Constructor Description
      Cascade()
      Constructs a new Cascade.
      Cascade​(Cascade other)
      Constructs a new Cascade from existing one.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean containsKey​(java.lang.String key)
      Checks if this cascade has a value for given key
      static <T> T convertTo​(java.lang.Object o, java.lang.Class<T> klass)
      Converts an object to a given other class.
      java.lang.Object get​(java.lang.String key)
      Gets a property for the given key (like stroke, ...)
      <T> T get​(java.lang.String key, T def, java.lang.Class<T> klass)
      Gets the value for a given key with the given type
      <T> T get​(java.lang.String key, T def, java.lang.Class<T> klass, boolean suppressWarnings)
      Get value for the given key
      boolean isDefaultSelectedHandling()
      Get if the default selection drawing should be used for the object this cascade applies to
      void put​(java.lang.String key, java.lang.Object val)
      Sets the property for the given key
      void putOrClear​(java.lang.String key, java.lang.Object val)
      Sets the property for the given key, removes it if the value is null
      void remove​(java.lang.String key)
      Removes the property with the given key
      void setDefaultSelectedHandling​(boolean defaultSelectedHandling)
      Set that the default selection drawing should be used for the object this cascade applies to
      private static java.lang.Boolean toBool​(java.lang.Object o)  
      private static java.awt.Color toColor​(java.lang.Object o)  
      private static java.lang.Double toDouble​(java.lang.Object o)  
      private static java.lang.Float toFloat​(java.lang.Object o)  
      private static float[] toFloatArray​(java.lang.Object o)  
      java.lang.String toString()  
      private static java.lang.String toString​(java.lang.Object o)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • 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​(java.lang.String key,
                         T def,
                         java.lang.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​(java.lang.String key,
                         T def,
                         java.lang.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 java.lang.Object get​(java.lang.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​(java.lang.String key,
                        java.lang.Object val)
        Sets the property for the given key
        Parameters:
        key - The key
        val - The value
      • putOrClear

        public void putOrClear​(java.lang.String key,
                               java.lang.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​(java.lang.String key)
        Removes the property with the given key
        Parameters:
        key - The key
      • convertTo

        public static <T> T convertTo​(java.lang.Object o,
                                      java.lang.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
      • toString

        private static java.lang.String toString​(java.lang.Object o)
      • toFloat

        private static java.lang.Float toFloat​(java.lang.Object o)
      • toDouble

        private static java.lang.Double toDouble​(java.lang.Object o)
      • toBool

        private static java.lang.Boolean toBool​(java.lang.Object o)
      • toFloatArray

        private static float[] toFloatArray​(java.lang.Object o)
      • toColor

        private static java.awt.Color toColor​(java.lang.Object o)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • containsKey

        public boolean containsKey​(java.lang.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