nl._42.jarb.constraint.metadata.database.CachingBeanMetadataRepository Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jarb Show documentation
Show all versions of jarb Show documentation
Provides support for databases
/*
* (C) 2013 42 bv (www.42.nl). All rights reserved.
*/
package nl._42.jarb.constraint.metadata.database;
import java.util.HashMap;
import java.util.Map;
import nl._42.jarb.utils.bean.PropertyReference;
/**
* Caching bean metadata repository.
*
* @author Jeroen van Schagen
* @since Feb 11, 2014
*/
public class CachingBeanMetadataRepository implements BeanMetadataRepository {
private final Map caches = new HashMap();
private final BeanMetadataRepository delegate;
public CachingBeanMetadataRepository(BeanMetadataRepository delegate) {
this.delegate = delegate;
}
@Override
public ColumnMetadata getColumnMetadata(PropertyReference propertyReference) {
ColumnMetadata columnMetadata = caches.get(propertyReference);
if (columnMetadata == null) {
columnMetadata = delegate.getColumnMetadata(propertyReference);
caches.put(propertyReference, columnMetadata);
}
return columnMetadata;
}
@Override
public boolean isEmbeddable(Class> propertyType) {
return delegate.isEmbeddable(propertyType);
}
public void evictAll() {
caches.clear();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy