use of com.yahoo.elide.core.exceptions.DuplicateMappingException in project elide by yahoo.
the class MetaDataStore method addMetaData.
/**
* Add a meta data object into this data store, check for duplication.
*
* @param object a meta data object
*/
private void addMetaData(Object object, String version) {
HashMapDataStore hashMapDataStore = hashMapDataStores.computeIfAbsent(version, SERVER_ERROR);
EntityDictionary dictionary = hashMapDataStore.getDictionary();
Type<?> cls = dictionary.lookupBoundClass(EntityDictionary.getType(object));
String id = dictionary.getId(object);
if (hashMapDataStore.get(cls).containsKey(id)) {
if (!hashMapDataStore.get(cls).get(id).equals(object)) {
throw new DuplicateMappingException("Duplicated " + cls.getSimpleName() + " metadata " + id);
}
} else {
hashMapDataStore.get(cls).put(id, object);
}
}
use of com.yahoo.elide.core.exceptions.DuplicateMappingException in project elide by yahoo.
the class NonEntityDictionary method bindEntity.
/**
* Add given class to dictionary.
*
* @param cls Entity bean class
*/
@Override
public void bindEntity(Type<?> cls) {
String type = WordUtils.uncapitalize(cls.getSimpleName());
Type<?> duplicate = bindJsonApiToEntity.put(Pair.of(type, NO_VERSION), cls);
if (duplicate != null && !duplicate.equals(cls)) {
log.error("Duplicate binding {} for {}, {}", type, cls, duplicate);
throw new DuplicateMappingException(type + " " + cls.getName() + ":" + duplicate.getName());
}
entityBindings.put(cls, new EntityBinding(getInjector(), cls, type));
}
Aggregations