Class ClassInfo


  • public final class ClassInfo
    extends java.lang.Object
    Computes class information to determine data key name/value pairs associated with the class.

    Implementation is thread-safe.

    Since:
    1.0
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.util.concurrent.ConcurrentMap<java.lang.Class<?>,​ClassInfo> CACHE
      Class information cache, with case-sensitive field names.
      private static java.util.concurrent.ConcurrentMap<java.lang.Class<?>,​ClassInfo> CACHE_IGNORE_CASE
      Class information cache, with case-insensitive fields names.
      private java.lang.Class<?> clazz
      Class.
      private boolean ignoreCase
      Whether field names are case sensitive.
      (package private) java.util.List<java.lang.String> names
      Unmodifiable sorted (with any possible null member first) list (without duplicates) of FieldInfo.getName().
      private java.util.IdentityHashMap<java.lang.String,​FieldInfo> nameToFieldInfoMap
      Map from FieldInfo.getName() to the field information.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private ClassInfo​(java.lang.Class<?> srcClass, boolean ignoreCase)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.reflect.Field getField​(java.lang.String name)
      Returns the field for the given FieldInfo.getName().
      FieldInfo getFieldInfo​(java.lang.String name)
      Returns the information for the given FieldInfo.getName().
      java.util.Collection<FieldInfo> getFieldInfos()
      Returns an unmodifiable collection of the FieldInfos for this class, without any guarantee of order.
      boolean getIgnoreCase()
      Returns whether field names are case sensitive.
      java.util.Collection<java.lang.String> getNames()
      Returns an unmodifiable sorted set (with any possible null member first) of names.
      java.lang.Class<?> getUnderlyingClass()
      Returns the underlying class.
      boolean isEnum()
      Returns the underlying class is an enum.
      static ClassInfo of​(java.lang.Class<?> underlyingClass)
      Returns the class information for the given underlying class.
      static ClassInfo of​(java.lang.Class<?> underlyingClass, boolean ignoreCase)
      Returns the class information for the given underlying class.
      • Methods inherited from class java.lang.Object

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

      • CACHE

        private static final java.util.concurrent.ConcurrentMap<java.lang.Class<?>,​ClassInfo> CACHE
        Class information cache, with case-sensitive field names.
      • CACHE_IGNORE_CASE

        private static final java.util.concurrent.ConcurrentMap<java.lang.Class<?>,​ClassInfo> CACHE_IGNORE_CASE
        Class information cache, with case-insensitive fields names.
      • clazz

        private final java.lang.Class<?> clazz
        Class.
      • ignoreCase

        private final boolean ignoreCase
        Whether field names are case sensitive.
      • nameToFieldInfoMap

        private final java.util.IdentityHashMap<java.lang.String,​FieldInfo> nameToFieldInfoMap
        Map from FieldInfo.getName() to the field information.
      • names

        final java.util.List<java.lang.String> names
        Unmodifiable sorted (with any possible null member first) list (without duplicates) of FieldInfo.getName().
    • Constructor Detail

      • ClassInfo

        private ClassInfo​(java.lang.Class<?> srcClass,
                          boolean ignoreCase)
    • Method Detail

      • of

        public static ClassInfo of​(java.lang.Class<?> underlyingClass)
        Returns the class information for the given underlying class.
        Parameters:
        underlyingClass - underlying class or null for null result
        Returns:
        class information or null for null input
      • of

        public static ClassInfo of​(java.lang.Class<?> underlyingClass,
                                   boolean ignoreCase)
        Returns the class information for the given underlying class.
        Parameters:
        underlyingClass - underlying class or null for null result
        ignoreCase - whether field names are case sensitive
        Returns:
        class information or null for null input
        Since:
        1.10
      • getUnderlyingClass

        public java.lang.Class<?> getUnderlyingClass()
        Returns the underlying class.
        Since:
        1.4
      • getIgnoreCase

        public final boolean getIgnoreCase()
        Returns whether field names are case sensitive.
        Since:
        1.10
      • getField

        public java.lang.reflect.Field getField​(java.lang.String name)
        Returns the field for the given FieldInfo.getName().
        Parameters:
        name - FieldInfo.getName() or null
        Returns:
        field or null for none
      • isEnum

        public boolean isEnum()
        Returns the underlying class is an enum.
        Since:
        1.4
      • getNames

        public java.util.Collection<java.lang.String> getNames()
        Returns an unmodifiable sorted set (with any possible null member first) of names.
      • getFieldInfos

        public java.util.Collection<FieldInfo> getFieldInfos()
        Returns an unmodifiable collection of the FieldInfos for this class, without any guarantee of order.

        If you need sorted order, instead use getNames() with getFieldInfo(String).

        Since:
        1.16