/** * Examine class hierarchy using {@link CFMappingDef} objects to discover the * given class' "base inheritance" class. A base inheritance class is * determined by {@link CFMappingDef#isBaseEntity()} * * @param <T> * * @param cfMapDef * @return returns the base in the ColumnFamily mapping hierarchy */ public <T> CFMappingDef<? super T> findBaseClassViaMappings(CFMappingDef<T> cfMapDef) { CFMappingDef<? super T> tmpDef = cfMapDef; CFMappingDef<? super T> cfSuperDef; while (null != (cfSuperDef = tmpDef.getCfSuperMapDef())) { if (cfSuperDef.isBaseEntity()) { return cfSuperDef; } tmpDef = cfSuperDef; } return null; }
public boolean isPersistableDerivedEntity() { return !isBaseEntity() && null != getDiscValue() && !isAbstract(); }
public boolean isNonPersistableDerivedEntity() { return !isBaseEntity() && !isPersistableDerivedEntity() && isAbstract(); }
@Override public <T> void validateAndSetDefaults(ClassCacheMgr cacheMgr, CFMappingDef<T> cfMapDef) { if (cfMapDef.isBaseEntity()) { validateBaseClassInheritance(cfMapDef); } else if (cfMapDef.isPersistableDerivedEntity()) { validateDerivedClassInheritance(cfMapDef); } else if (!cfMapDef.isNonPersistableDerivedEntity()) { if (null != cacheMgr.findBaseClassViaMappings(cfMapDef)) throw new HectorObjectMapperException("@" + Inheritance.class.getSimpleName() + " found in class hierarchy, but no @" + DiscriminatorValue.class.getSimpleName() + " - quitting"); } }
@Override public <T> void validateAndSetDefaults(ClassCacheMgr cacheMgr, CFMappingDef<T> cfMapDef) { if (cfMapDef.isBaseEntity()) { validateBaseEntityClass(cacheMgr, cfMapDef); } else if ( cfMapDef.isDerivedEntity() ) { validateDerivedEntityClass(cacheMgr, cfMapDef); if (cfMapDef.isPersistableDerivedEntity()) { validatePersistableDerivedEntityClass(cacheMgr, cfMapDef); } } if (cfMapDef.isPersistableEntity()) { validatePersistableEntityClass(cacheMgr, cfMapDef); } }