org.ldaptive.beans.reflect.DefaultLdapEntryMapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ldaptive-beans Show documentation
Show all versions of ldaptive-beans Show documentation
Provides a mapping, persistence, and code generation API for reading and writing POJOs to an LDAP directory
/* See LICENSE for licensing and NOTICE for copyright. */
package org.ldaptive.beans.reflect;
import java.util.HashMap;
import java.util.Map;
import org.ldaptive.beans.AbstractLdapEntryMapper;
import org.ldaptive.beans.ClassDescriptor;
/**
* Stores the class descriptors for a specific object in a static map.
*
* @param type of object to map
*
* @author Middleware Services
*/
public class DefaultLdapEntryMapper extends AbstractLdapEntryMapper
{
/** Class descriptors for mapping objects. */
private static final Map, ClassDescriptor> CLASS_DESCRIPTORS = new HashMap<>();
@Override
protected ClassDescriptor getClassDescriptor(final Object object)
{
final ClassDescriptor descriptor;
final Class> type = object.getClass();
synchronized (CLASS_DESCRIPTORS) {
if (!CLASS_DESCRIPTORS.containsKey(type)) {
descriptor = createClassDescriptor(type);
CLASS_DESCRIPTORS.put(type, descriptor);
} else {
descriptor = CLASS_DESCRIPTORS.get(type);
}
}
return descriptor;
}
/**
* Creates a class descriptor for the supplied type.
*
* @param type to create class descriptor for
*
* @return class descriptor
*/
protected ClassDescriptor createClassDescriptor(final Class> type)
{
final DefaultClassDescriptor descriptor = new DefaultClassDescriptor();
descriptor.initialize(type);
return descriptor;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy