net.java.ao.schema.CachingTableNameConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of activeobjects Show documentation
Show all versions of activeobjects Show documentation
This is the full Active Objects library, if you don't know which one to use, you probably want this one.
package net.java.ao.schema;
import com.google.common.base.Function;
import com.google.common.collect.MapMaker;
import net.java.ao.RawEntity;
import java.util.Map;
import static com.google.common.base.Preconditions.*;
/**
* A table name converter that simply caches the converted table names.
* This implementation uses a {@link java.util.concurrent.ConcurrentMap} and is thread safe.
*
* @since 0.9
*/
public final class CachingTableNameConverter implements TableNameConverter
{
private final Map>, String> cache;
public CachingTableNameConverter(final TableNameConverter delegateTableNameConverter)
{
checkNotNull(delegateTableNameConverter);
this.cache = new MapMaker().makeComputingMap(new Function>, String>()
{
public String apply(Class extends RawEntity>> entityClass)
{
return delegateTableNameConverter.getName(entityClass);
}
});
}
public String getName(Class extends RawEntity>> entityClass)
{
return cache.get(entityClass);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy