AnnotationBinder.java 文件源码

java
阅读 43 收藏 0 点赞 0 评论 0

项目:lams 作者:
/**
 * For the mapped entities build some temporary data-structure containing information about the
 * inheritance status of a class.
 *
 * @param orderedClasses Order list of all annotated entities and their mapped superclasses
 *
 * @return A map of {@code InheritanceState}s keyed against their {@code XClass}.
 */
public static Map<XClass, InheritanceState> buildInheritanceStates(
        List<XClass> orderedClasses,
        Mappings mappings) {
    ReflectionManager reflectionManager = mappings.getReflectionManager();
    Map<XClass, InheritanceState> inheritanceStatePerClass = new HashMap<XClass, InheritanceState>(
            orderedClasses.size()
    );
    for ( XClass clazz : orderedClasses ) {
        InheritanceState superclassState = InheritanceState.getSuperclassInheritanceState(
                clazz, inheritanceStatePerClass
        );
        InheritanceState state = new InheritanceState( clazz, inheritanceStatePerClass, mappings );
        if ( superclassState != null ) {
            //the classes are ordered thus preventing an NPE
            //FIXME if an entity has subclasses annotated @MappedSperclass wo sub @Entity this is wrong
            superclassState.setHasSiblings( true );
            InheritanceState superEntityState = InheritanceState.getInheritanceStateOfSuperEntity(
                    clazz, inheritanceStatePerClass
            );
            state.setHasParents( superEntityState != null );
            final boolean nonDefault = state.getType() != null && !InheritanceType.SINGLE_TABLE
                    .equals( state.getType() );
            if ( superclassState.getType() != null ) {
                final boolean mixingStrategy = state.getType() != null && !state.getType()
                        .equals( superclassState.getType() );
                if ( nonDefault && mixingStrategy ) {
                    LOG.invalidSubStrategy( clazz.getName() );
                }
                state.setType( superclassState.getType() );
            }
        }
        inheritanceStatePerClass.put( clazz, state );
    }
    return inheritanceStatePerClass;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号