Class LDAPObjectHandler<T>

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String constructDN​(T o, java.lang.String parentDN)
      Determines the DN that should be used for the entry associated with the given object.
      Filter createBaseFilter()
      Retrieves a filter that will match any entry containing the structural and auxiliary classes for this object type.
      Filter createFilter​(T o)
      Retrieves a filter that can be used to search for entries matching the provided object.
      java.lang.String[] getAttributesToRequest()
      Retrieves the names of the attributes that should be requested when performing a search.
      java.lang.String[] getAuxiliaryClasses()
      Retrieves the names of the auxiliary object classes for objects of the associated type.
      java.lang.reflect.Constructor<T> getConstructor()
      Retrieves the constructor used to create a new instance of the appropriate type.
      DN getDefaultParentDN()
      Retrieves the default parent DN for objects of the associated type.
      java.lang.reflect.Field getDNField()
      Retrieves the field that will be used to hold the DN of the associated entry, if defined.
      ReadOnlyEntry getEntry​(T o)
      Retrieves a read-only copy of the entry that was used to initialize the provided object, if available.
      java.lang.String getEntryDN​(T o)
      Retrieves the DN of the entry in which the provided object is stored, if available.
      java.lang.reflect.Field getEntryField()
      Retrieves the field that will be used to hold a read-only copy of the entry used to create the object instance, if defined.
      java.util.Map<java.lang.String,​FieldInfo> getFields()
      Retrieves a map of all fields in the class that should be persisted as LDAP attributes.
      java.util.Map<java.lang.String,​GetterInfo> getGetters()
      Retrieves a map of all getter methods in the class whose values should be persisted as LDAP attributes.
      java.lang.String[] getLazilyLoadedAttributes()
      Retrieves the names of the attributes that should be lazily loaded for objects of this type.
      LDAPObject getLDAPObjectAnnotation()
      Retrieves the LDAPObject annotation for the associated class.
      java.util.Map<java.lang.String,​SetterInfo> getSetters()
      Retrieves a map of all setter methods in the class that should be invoked with information read from LDAP attributes.
      java.lang.String getStructuralClass()
      Retrieves the name of the structural object class for objects of the associated type.
      LDAPObjectHandler<?> getSuperclassHandler()
      Retrieves the LDAPObjectHandler object for the superclass of the associated type, if it is marked with the LDAPObject annotation.
      java.lang.String[] getSuperiorClasses()
      Retrieves the names of the superior object classes for objects of the associated type.
      java.lang.Class<T> getType()
      Retrieves the type of object handled by this class.
      boolean requestAllAttributes()
      Indicates whether to request all attributes.
      • Methods inherited from class java.lang.Object

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

      • getType

        @NotNull
        public java.lang.Class<TgetType()
        Retrieves the type of object handled by this class.
        Returns:
        The type of object handled by this class.
      • getSuperclassHandler

        @Nullable
        public LDAPObjectHandler<?> getSuperclassHandler()
        Retrieves the LDAPObjectHandler object for the superclass of the associated type, if it is marked with the LDAPObject annotation.
        Returns:
        The LDAPObjectHandler object for the superclass of the associated type, or null if the superclass is not marked with the LDAPObject annotation.
      • getConstructor

        @NotNull
        public java.lang.reflect.Constructor<TgetConstructor()
        Retrieves the constructor used to create a new instance of the appropriate type.
        Returns:
        The constructor used to create a new instance of the appropriate type.
      • getDNField

        @Nullable
        public java.lang.reflect.Field getDNField()
        Retrieves the field that will be used to hold the DN of the associated entry, if defined.
        Returns:
        The field that will be used to hold the DN of the associated entry, or null if no DN field is defined in the associated object type.
      • getEntryField

        @Nullable
        public java.lang.reflect.Field getEntryField()
        Retrieves the field that will be used to hold a read-only copy of the entry used to create the object instance, if defined.
        Returns:
        The field that will be used to hold a read-only copy of the entry used to create the object instance, or null if no entry field is defined in the associated object type.
      • getDefaultParentDN

        @NotNull
        public DN getDefaultParentDN()
        Retrieves the default parent DN for objects of the associated type.
        Returns:
        The default parent DN for objects of the associated type.
      • getStructuralClass

        @NotNull
        public java.lang.String getStructuralClass()
        Retrieves the name of the structural object class for objects of the associated type.
        Returns:
        The name of the structural object class for objects of the associated type.
      • getAuxiliaryClasses

        @NotNull
        public java.lang.String[] getAuxiliaryClasses()
        Retrieves the names of the auxiliary object classes for objects of the associated type.
        Returns:
        The names of the auxiliary object classes for objects of the associated type. It may be empty if no auxiliary classes are defined.
      • getSuperiorClasses

        @NotNull
        public java.lang.String[] getSuperiorClasses()
        Retrieves the names of the superior object classes for objects of the associated type.
        Returns:
        The names of the superior object classes for objects of the associated type. It may be empty if no superior classes are defined.
      • requestAllAttributes

        public boolean requestAllAttributes()
        Indicates whether to request all attributes. This will return true if the associated LDAPObject, or any LDAPObject for any superclass, has requestAllAttributes set to true.
        Returns:
        true if LDAPObject has requestAllAttributes set to true for any class in the hierarchy, or false if not.
      • getAttributesToRequest

        @NotNull
        public java.lang.String[] getAttributesToRequest()
        Retrieves the names of the attributes that should be requested when performing a search. It will not include lazily-loaded attributes.
        Returns:
        The names of the attributes that should be requested when performing a search.
      • getLazilyLoadedAttributes

        @NotNull
        public java.lang.String[] getLazilyLoadedAttributes()
        Retrieves the names of the attributes that should be lazily loaded for objects of this type.
        Returns:
        The names of the attributes that should be lazily loaded for objects of this type. It may be empty if no attributes should be lazily-loaded.
      • getEntryDN

        @Nullable
        public java.lang.String getEntryDN​(@NotNull
                                           T o)
                                    throws LDAPPersistException
        Retrieves the DN of the entry in which the provided object is stored, if available. The entry DN will not be available if the provided object was not retrieved using the persistence framework, or if the associated class (or one of its superclasses) does not have a field marked with either the LDAPDNField or LDAPEntryField annotation.
        Parameters:
        o - The object for which to retrieve the associated entry DN.
        Returns:
        The DN of the entry in which the provided object is stored, or null if that is not available.
        Throws:
        LDAPPersistException - If a problem occurred while attempting to obtain the entry DN.
      • getEntry

        @Nullable
        public ReadOnlyEntry getEntry​(@NotNull
                                      T o)
                               throws LDAPPersistException
        Retrieves a read-only copy of the entry that was used to initialize the provided object, if available. The entry will only be available if the object was retrieved from the directory using the persistence framework and the associated class (or one of its superclasses) has a field marked with the LDAPEntryField annotation.
        Parameters:
        o - The object for which to retrieve the read-only entry.
        Returns:
        A read-only copy of the entry that was used to initialize the provided object, or null if that is not available.
        Throws:
        LDAPPersistException - If a problem occurred while attempting to obtain the entry DN.
      • getFields

        @NotNull
        public java.util.Map<java.lang.String,​FieldInfogetFields()
        Retrieves a map of all fields in the class that should be persisted as LDAP attributes. The keys in the map will be the lowercase names of the LDAP attributes used to persist the information, and the values will be information about the fields associated with those attributes.
        Returns:
        A map of all fields in the class that should be persisted as LDAP attributes.
      • getGetters

        @NotNull
        public java.util.Map<java.lang.String,​GetterInfogetGetters()
        Retrieves a map of all getter methods in the class whose values should be persisted as LDAP attributes. The keys in the map will be the lowercase names of the LDAP attributes used to persist the information, and the values will be information about the getter methods associated with those attributes.
        Returns:
        A map of all getter methods in the class whose values should be persisted as LDAP attributes.
      • getSetters

        @NotNull
        public java.util.Map<java.lang.String,​SetterInfogetSetters()
        Retrieves a map of all setter methods in the class that should be invoked with information read from LDAP attributes. The keys in the map will be the lowercase names of the LDAP attributes with the information used to invoke the setter, and the values will be information about the setter methods associated with those attributes.
        Returns:
        A map of all setter methods in the class that should be invoked with information read from LDAP attributes.
      • constructDN

        @NotNull
        public java.lang.String constructDN​(@NotNull
                                            T o,
                                            @Nullable
                                            java.lang.String parentDN)
                                     throws LDAPPersistException
        Determines the DN that should be used for the entry associated with the given object. If the provided object was retrieved from the directory using the persistence framework and has a field with either the LDAPDNField or LDAPEntryField annotation, then the actual DN of the corresponding entry will be returned. Otherwise, it will be constructed using the fields and getter methods marked for inclusion in the entry RDN.
        Parameters:
        o - The object for which to determine the appropriate DN.
        parentDN - The parent DN to use for the constructed DN. If a non-null value is provided, then that value will be used as the parent DN (and the empty string will indicate that the generated DN should not have a parent). If the value is null, then the default parent DN as defined in the LDAPObject annotation will be used. If the provided parent DN is null and the LDAPObject annotation does not specify a default parent DN, then the generated DN will not have a parent.
        Returns:
        The entry DN for the provided object.
        Throws:
        LDAPPersistException - If a problem occurs while obtaining the entry DN, or if the provided parent DN represents an invalid DN.
      • createBaseFilter

        @NotNull
        public Filter createBaseFilter()
        Retrieves a filter that will match any entry containing the structural and auxiliary classes for this object type.
        Returns:
        A filter that will match any entry containing the structural and auxiliary classes for this object type.
      • createFilter

        @NotNull
        public Filter createFilter​(@NotNull
                                   T o)
                            throws LDAPPersistException
        Retrieves a filter that can be used to search for entries matching the provided object. It will be constructed as an AND search using all fields with a non-null value and that have a LDAPField annotation with the inFilter element set to true, and all getter methods that return a non-null value and have a LDAPGetter annotation with the inFilter element set to true.
        Parameters:
        o - The object for which to create the search filter.
        Returns:
        A filter that can be used to search for entries matching the provided object.
        Throws:
        LDAPPersistException - If it is not possible to construct a search filter for some reason (e.g., because the provided object does not have any non-null fields or getters that are marked for inclusion in filters).