Class PropertyEditorSupport<T>

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.concurrent.CopyOnWriteArrayList<java.beans.PropertyChangeListener> listeners  
      private java.lang.Class<T> type  
      private T value  
    • Constructor Summary

      Constructors 
      Constructor Description
      PropertyEditorSupport​(java.lang.Class<T> type)
      Creates PropertyEditorSupport instance.
      PropertyEditorSupport​(java.lang.Class<T> type, java.lang.Object source)
      Creates PropertyEditorSupport instance.
    • Field Detail

      • value

        private T value
      • type

        private final java.lang.Class<T> type
      • listeners

        private java.util.concurrent.CopyOnWriteArrayList<java.beans.PropertyChangeListener> listeners
    • Constructor Detail

      • PropertyEditorSupport

        public PropertyEditorSupport​(java.lang.Class<T> type)
        Creates PropertyEditorSupport instance. Requires T class to enforce runtime type checks.
      • PropertyEditorSupport

        public PropertyEditorSupport​(java.lang.Class<T> type,
                                     java.lang.Object source)
        Creates PropertyEditorSupport instance. Requires T class to enforce runtime type checks and a source.
    • Method Detail

      • addPropertyChangeListener

        public void addPropertyChangeListener​(PropertyChangeListener<T> listener)
        Description copied from interface: PropertyEditor
        Adds a listener for the value change. When the property editor changes its value it should fire a PropertyChangeEvent on all registered PropertyChangeListeners, specifying the null value for the property name and itself as the source.
        Specified by:
        addPropertyChangeListener in interface PropertyEditor<T>
        Parameters:
        listener - the PropertyChangeListener to add
      • addPropertyChangeListener

        public void addPropertyChangeListener​(java.beans.PropertyChangeListener listener)
        Specified by:
        addPropertyChangeListener in interface java.beans.PropertyEditor
        Overrides:
        addPropertyChangeListener in class java.beans.PropertyEditorSupport
      • getAsText

        public java.lang.String getAsText()
        Description copied from interface: PropertyEditor
        Gets the property value as text.
        Specified by:
        getAsText in interface java.beans.PropertyEditor
        Specified by:
        getAsText in interface PropertyEditor<T>
        Overrides:
        getAsText in class java.beans.PropertyEditorSupport
        Returns:
        The property value as a human editable string.

        Returns null if the value can't be expressed as an editable string.

        If a non-null value is returned, then the PropertyEditor should be prepared to parse that string back in setAsText().

      • getValue

        public T getValue()
        Description copied from interface: PropertyEditor
        Gets the property value.
        Specified by:
        getValue in interface java.beans.PropertyEditor
        Specified by:
        getValue in interface PropertyEditor<T>
        Overrides:
        getValue in class java.beans.PropertyEditorSupport
        Returns:
        The value of the property. Primitive types such as "int" will be wrapped as the corresponding object type such as "java.lang.Integer".
      • removePropertyChangeListener

        public void removePropertyChangeListener​(java.beans.PropertyChangeListener listener)
        Specified by:
        removePropertyChangeListener in interface java.beans.PropertyEditor
        Overrides:
        removePropertyChangeListener in class java.beans.PropertyEditorSupport
      • setValue

        public void setValue​(java.lang.Object value)
        Description copied from interface: PropertyEditor
        Set (or change) the object that is to be edited. Primitive types such as "int" must be wrapped as the corresponding object type such as "java.lang.Integer".
        Specified by:
        setValue in interface java.beans.PropertyEditor
        Specified by:
        setValue in interface PropertyEditor<T>
        Overrides:
        setValue in class java.beans.PropertyEditorSupport
        Parameters:
        value - The new target object to be edited. Note that this object should not be modified by the PropertyEditor, rather the PropertyEditor should create a new object to hold any modified value.
      • firePropertyChange

        public void firePropertyChange​(T oldValue,
                                       T newValue)
      • getType

        protected java.lang.Class<T> getType()
      • setAsText

        public abstract void setAsText​(java.lang.String text)
                                throws java.lang.IllegalArgumentException
        Description copied from interface: PropertyEditor
        Set the property value by parsing a given String. May raise java.lang.IllegalArgumentException if either the String is badly formatted or if this kind of property can't be expressed as text.
        Specified by:
        setAsText in interface java.beans.PropertyEditor
        Specified by:
        setAsText in interface PropertyEditor<T>
        Overrides:
        setAsText in class java.beans.PropertyEditorSupport
        Parameters:
        text - The string to be parsed.
        Throws:
        java.lang.IllegalArgumentException