Class DefaultIntrospectionContext

  • All Implemented Interfaces:
    IntrospectionContext

    class DefaultIntrospectionContext
    extends java.lang.Object
    implements IntrospectionContext

    An implementation of the IntrospectionContext interface used by PropertyUtilsBean when doing introspection of a bean class.

    This class implements the methods required by the IntrospectionContext interface in a straight-forward manner based on a map. It is used internally only. It is not thread-safe.

    Since:
    1.9
    Version:
    $Id: DefaultIntrospectionContext.java 1540359 2013-11-09 18:10:52Z oheger $
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.Class<?> currentClass
      The current class for introspection.
      private java.util.Map<java.lang.String,​java.beans.PropertyDescriptor> descriptors
      A map for storing the already added property descriptors.
      private static java.beans.PropertyDescriptor[] EMPTY_DESCRIPTORS
      Constant for an empty array of property descriptors.
    • Constructor Summary

      Constructors 
      Constructor Description
      DefaultIntrospectionContext​(java.lang.Class<?> cls)
      Creates a new instance of DefaultIntrospectionContext and sets the current class for introspection.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addPropertyDescriptor​(java.beans.PropertyDescriptor desc)
      Adds the given property descriptor to this context.
      void addPropertyDescriptors​(java.beans.PropertyDescriptor[] descs)
      Adds an array of property descriptors to this context.
      java.beans.PropertyDescriptor getPropertyDescriptor​(java.lang.String name)
      Returns the descriptor for the property with the given name or null if this property is unknown.
      java.beans.PropertyDescriptor[] getPropertyDescriptors()
      Returns an array with all descriptors added to this context.
      java.lang.Class<?> getTargetClass()
      Returns the class that is subject of introspection.
      boolean hasProperty​(java.lang.String name)
      Tests whether a descriptor for the property with the given name is already contained in this context.
      java.util.Set<java.lang.String> propertyNames()
      Returns a set with the names of all properties known to this context.
      void removePropertyDescriptor​(java.lang.String name)
      Removes the descriptor for the property with the given name.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • EMPTY_DESCRIPTORS

        private static final java.beans.PropertyDescriptor[] EMPTY_DESCRIPTORS
        Constant for an empty array of property descriptors.
      • currentClass

        private final java.lang.Class<?> currentClass
        The current class for introspection.
      • descriptors

        private final java.util.Map<java.lang.String,​java.beans.PropertyDescriptor> descriptors
        A map for storing the already added property descriptors.
    • Constructor Detail

      • DefaultIntrospectionContext

        public DefaultIntrospectionContext​(java.lang.Class<?> cls)
        Creates a new instance of DefaultIntrospectionContext and sets the current class for introspection.
        Parameters:
        cls - the current class
    • Method Detail

      • addPropertyDescriptor

        public void addPropertyDescriptor​(java.beans.PropertyDescriptor desc)
        Description copied from interface: IntrospectionContext
        Adds the given property descriptor to this context. This method is called by a BeanIntrospector during introspection for each detected property. If this context already contains a descriptor for the affected property, it is overridden.
        Specified by:
        addPropertyDescriptor in interface IntrospectionContext
        Parameters:
        desc - the property descriptor
      • addPropertyDescriptors

        public void addPropertyDescriptors​(java.beans.PropertyDescriptor[] descs)
        Description copied from interface: IntrospectionContext
        Adds an array of property descriptors to this context. Using this method multiple descriptors can be added at once.
        Specified by:
        addPropertyDescriptors in interface IntrospectionContext
        Parameters:
        descs - the array of descriptors to be added
      • hasProperty

        public boolean hasProperty​(java.lang.String name)
        Description copied from interface: IntrospectionContext
        Tests whether a descriptor for the property with the given name is already contained in this context. This method can be used for instance to prevent that an already existing property descriptor is overridden.
        Specified by:
        hasProperty in interface IntrospectionContext
        Parameters:
        name - the name of the property in question
        Returns:
        true if a descriptor for this property has already been added, false otherwise
      • getPropertyDescriptor

        public java.beans.PropertyDescriptor getPropertyDescriptor​(java.lang.String name)
        Description copied from interface: IntrospectionContext
        Returns the descriptor for the property with the given name or null if this property is unknown.
        Specified by:
        getPropertyDescriptor in interface IntrospectionContext
        Parameters:
        name - the name of the property in question
        Returns:
        the descriptor for this property or null if this property is unknown
      • removePropertyDescriptor

        public void removePropertyDescriptor​(java.lang.String name)
        Description copied from interface: IntrospectionContext
        Removes the descriptor for the property with the given name.
        Specified by:
        removePropertyDescriptor in interface IntrospectionContext
        Parameters:
        name - the name of the affected property
      • propertyNames

        public java.util.Set<java.lang.String> propertyNames()
        Description copied from interface: IntrospectionContext
        Returns a set with the names of all properties known to this context.
        Specified by:
        propertyNames in interface IntrospectionContext
        Returns:
        a set with the known property names
      • getPropertyDescriptors

        public java.beans.PropertyDescriptor[] getPropertyDescriptors()
        Returns an array with all descriptors added to this context. This method is used to obtain the results of introspection.
        Returns:
        an array with all known property descriptors