All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.java.ao.schema.CachingTableNameConverter Maven / Gradle / Ivy

Go to download

This is the core library for Active Objects. It is generic and can be embedded in any environment. As such it is generic and won't contain all connection pooling, etc.

There is a newer version: 6.1.1
Show newest version
package net.java.ao.schema;

import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import net.java.ao.RawEntity;

import java.util.Objects;


/**
 * 

A table name converter that simply caches the converted table names.

*

This implementation uses a {@link com.google.common.cache.LoadingCache} and is thread safe.

* * @since 0.9 */ public class CachingTableNameConverter implements TableNameConverter { private final LoadingCache>, String> cache; public CachingTableNameConverter(final TableNameConverter delegateTableNameConverter) { Objects.requireNonNull(delegateTableNameConverter, "delegateTableNameConverter can't be null"); this.cache = CacheBuilder.newBuilder().build(new CacheLoader>, String>() { @Override public String load(final Class> key) throws Exception { return delegateTableNameConverter.getName(key); } }); } public String getName(Class> entityClass) { return cache.getUnchecked(entityClass); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy