Java 类javax.persistence.MapKeyEnumerated 实例源码

项目:lams    文件:JPAOverriddenAnnotationReader.java   
/**
 * Adds a @MapKeyEnumerated annotation to the specified annotationList if the specified element
 * contains a map-key-enumerated sub-element. This should only be the case for
 * element-collection, many-to-many, or one-to-many associations.
 */
private void getMapKeyEnumerated(List<Annotation> annotationList, Element element) {
    Element subelement = element != null ? element.element( "map-key-enumerated" ) : null;
    if ( subelement != null ) {
        AnnotationDescriptor ad = new AnnotationDescriptor( MapKeyEnumerated.class );
        EnumType value = EnumType.valueOf( subelement.getTextTrim() );
        ad.setValue( "value", value );
        annotationList.add( AnnotationFactory.create( ad ) );
    }
}
项目:lams    文件:CollectionPropertyHolder.java   
public void prepare(XProperty collectionProperty) {
    // fugly
    if ( prepared ) {
        return;
    }

    if ( collectionProperty == null ) {
        return;
    }

    prepared = true;

    if ( collection.isMap() ) {
        if ( collectionProperty.isAnnotationPresent( MapKeyEnumerated.class ) ) {
            canKeyBeConverted = false;
        }
        else if ( collectionProperty.isAnnotationPresent( MapKeyTemporal.class ) ) {
            canKeyBeConverted = false;
        }
        else if ( collectionProperty.isAnnotationPresent( MapKeyClass.class ) ) {
            canKeyBeConverted = false;
        }
        else if ( collectionProperty.isAnnotationPresent( MapKeyType.class ) ) {
            canKeyBeConverted = false;
        }
    }
    else {
        canKeyBeConverted = false;
    }

    if ( collectionProperty.isAnnotationPresent( ManyToAny.class ) ) {
        canElementBeConverted = false;
    }
    else if ( collectionProperty.isAnnotationPresent( OneToMany.class ) ) {
        canElementBeConverted = false;
    }
    else if ( collectionProperty.isAnnotationPresent( ManyToMany.class ) ) {
        canElementBeConverted = false;
    }
    else if ( collectionProperty.isAnnotationPresent( Enumerated.class ) ) {
        canElementBeConverted = false;
    }
    else if ( collectionProperty.isAnnotationPresent( Temporal.class ) ) {
        canElementBeConverted = false;
    }
    else if ( collectionProperty.isAnnotationPresent( CollectionType.class ) ) {
        canElementBeConverted = false;
    }

    // Is it valid to reference a collection attribute in a @Convert attached to the owner (entity) by path?
    // if so we should pass in 'clazzToProcess' also
    if ( canKeyBeConverted || canElementBeConverted ) {
        buildAttributeConversionInfoMaps( collectionProperty, elementAttributeConversionInfoMap, keyAttributeConversionInfoMap );
    }
}