Java 类org.hibernate.annotations.TypeDef 实例源码

项目:lams    文件:AnnotationBinder.java   
private static void bindTypeDefs(XAnnotatedElement annotatedElement, Mappings mappings) {
    TypeDef defAnn = annotatedElement.getAnnotation( TypeDef.class );
    TypeDefs defsAnn = annotatedElement.getAnnotation( TypeDefs.class );
    if ( defAnn != null ) {
        bindTypeDef( defAnn, mappings );
    }
    if ( defsAnn != null ) {
        for ( TypeDef def : defsAnn.value() ) {
            bindTypeDef( def, mappings );
        }
    }
}
项目:lams    文件:AnnotationBinder.java   
private static void bindTypeDef(TypeDef defAnn, Mappings mappings) {
    Properties params = new Properties();
    for ( Parameter param : defAnn.parameters() ) {
        params.setProperty( param.name(), param.value() );
    }

    if ( BinderHelper.isEmptyAnnotationValue( defAnn.name() ) && defAnn.defaultForType().equals( void.class ) ) {
        throw new AnnotationException(
                "Either name or defaultForType (or both) attribute should be set in TypeDef having typeClass " +
                        defAnn.typeClass().getName()
        );
    }

    final String typeBindMessageF = "Binding type definition: %s";
    if ( !BinderHelper.isEmptyAnnotationValue( defAnn.name() ) ) {
        if ( LOG.isDebugEnabled() ) {
            LOG.debugf( typeBindMessageF, defAnn.name() );
        }
        mappings.addTypeDef( defAnn.name(), defAnn.typeClass().getName(), params );
    }
    if ( !defAnn.defaultForType().equals( void.class ) ) {
        if ( LOG.isDebugEnabled() ) {
            LOG.debugf( typeBindMessageF, defAnn.defaultForType().getName() );
        }
        mappings.addTypeDef( defAnn.defaultForType().getName(), defAnn.typeClass().getName(), params );
    }

}