微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

javax.persistence.Enumerated的实例源码

项目:lams    文件JPAOverriddenAnnotationReader.java   
private void getEnumerated(List<Annotation> annotationList,Element element) {
    Element subElement = element != null ? element.element( "enumerated" ) : null;
    if ( subElement != null ) {
        AnnotationDescriptor ad = new AnnotationDescriptor( Enumerated.class );
        String enumerated = subElement.getTextTrim();
        if ( "ORDINAL".equalsIgnoreCase( enumerated ) ) {
            ad.setValue( "value",EnumType.ORDINAL );
        }
        else if ( "STRING".equalsIgnoreCase( enumerated ) ) {
            ad.setValue( "value",EnumType.STRING );
        }
        else if ( StringHelper.isNotEmpty( enumerated ) ) {
            throw new AnnotationException( "UnkNown EnumType: " + enumerated + ". " + SCHEMA_VALIDATION );
        }
        annotationList.add( AnnotationFactory.create( ad ) );
    }
}
项目:domui    文件HibernateChecker.java   
/**
 * Enums must be mapped as String,not ORDINAL.
 * @param g
 */
private void checkEnumMapping(Method g) {
    if(Enum.class.isAssignableFrom(g.getReturnType())) {        // Is type enum?
        if(g.getAnnotation(Transient.class) != null)
            return;

        //-- If the enum has a @Type we will have to assume the type handles mapping correctly (like MappedEnumType)
        org.hibernate.annotations.Type ht = g.getAnnotation(Type.class);
        if(null == ht) {
            //-- No @Type mapping,so this must have proper @Enumerated deFinition.
            Enumerated e = g.getAnnotation(Enumerated.class);
            if(null == e) {
                problem(Severity.ERROR,"Missing @Enumerated annotation on enum property - this will cause ORDINAL mapping of an enum which is undesirable");
                m_enumErrors++;
            } else if(e.value() != EnumType.STRING) {
                problem(Severity.ERROR,"@Enumerated(ORDINAL) annotation on enum property - this will cause ORDINAL mapping of an enum which is undesirable");
                m_enumErrors++;
            }
        }
    }
}
项目:lams    文件SimpleValueBinder.java   
private void applyAttributeConverter(XProperty property,AttributeConverterDeFinition attributeConverterDeFinition) {
    if ( attributeConverterDeFinition == null ) {
        return;
    }

    LOG.debugf( "Starting applyAttributeConverter [%s:%s]",persistentClassName,property.getName() );

    if ( property.isAnnotationPresent( Id.class ) ) {
        LOG.debugf( "Skipping AttributeConverter checks for Id attribute [%s]",property.getName() );
        return;
    }

    if ( isversion ) {
        LOG.debugf( "Skipping AttributeConverter checks for version attribute [%s]",property.getName() );
        return;
    }

    if ( property.isAnnotationPresent( Temporal.class ) ) {
        LOG.debugf( "Skipping AttributeConverter checks for Temporal attribute [%s]",property.getName() );
        return;
    }

    if ( property.isAnnotationPresent( Enumerated.class ) ) {
        LOG.debugf( "Skipping AttributeConverter checks for Enumerated attribute [%s]",property.getName() );
        return;
    }

    if ( isAssociation() ) {
        LOG.debugf( "Skipping AttributeConverter checks for association attribute [%s]",property.getName() );
        return;
    }

    this.attributeConverterDeFinition = attributeConverterDeFinition;
}
项目:holon-datastore-jpa    文件JpaEnumeratedBeanPropertyPostProcessor.java   
@SuppressWarnings({ "unchecked","rawtypes" })
@Override
public Builder<?> processBeanProperty(Builder<?> property,Class<?> beanornestedClass) {
    property.getAnnotation(Enumerated.class).ifPresent(a -> {
        final EnumType enumType = a.value();
        if (enumType == EnumType.STRING) {
            ((Builder) property).converter(PropertyValueConverter.enumByName());
        } else {
            ((Builder) property).converter(PropertyValueConverter.enumByOrdinal());
        }
        LOGGER.debug(() -> "JpaEnumeratedBeanPropertyPostProcessor: setted property [" + property
                + "] value converter to default enumeration converter using [" + enumType.name() + "] mode");
    });
    return property;
}
项目:myWMS    文件LogItem.java   
/**
 * Getter for property type.
 * 
 * @return Value of property type.
 */
@Enumerated(EnumType.STRING)
@Column(nullable = false)
public LogItemType getType() {

    return this.type;
}
项目:maven-plugin    文件GeraEntidade.java   
@Enumerated(EnumType.STRING)
private Attribute createAttribute(String[] parts) {
    Boolean onetoMany = false;
    Boolean onetoOne = false;
    Boolean manyToOne = false;
    Boolean manyToMany = false;
    Boolean required = false;
    Boolean enumString = false;
    Boolean enumOrdinal = false;

    if (parts.length > 2) {
        for (int i = 2; i < parts.length; i++) {
            if (this.isrequired(parts[i])) {
                required = Boolean.valueOf(parts[i]);
            } else if (this.isOnetoMany(parts[i])) {
                onetoMany = true;
            } else if (this.isOnetoOne(parts[i])) {
                onetoOne = true;
            } else if (this.isManyToOne(parts[i])) {
                manyToOne = true;
            } else if (this.isManyToMany(parts[i])) {
                manyToMany = true;
            } else if (this.isEnumString(parts[i])) {
                enumString = true;
            } else if (this.isEnumOrdinal(parts[i])) {
                enumOrdinal = true;
            }
        }
    }

    return new Attribute(parts[0],parts[1],Util.primeiraMaiuscula(parts[0]),onetoMany,onetoOne,manyToOne,manyToMany,required,enumString,enumOrdinal);
}
项目:oval    文件JPAAnnotationsConfigurer.java   
protected void initializeChecks(final Column annotation,final Collection<Check> checks,final AccessibleObject fieldOrMethod) {
    /* If the value is generated (annotated with @GeneratedValue) it is allowed to be null
     * before the entity has been persisted,same is true in case of optimistic locking
     * when a field is annotated with @Version.
     * Therefore and because of the fact that there is no generic way to determine if an entity
     * has been persisted already,a not-null check will not be performed for such fields.
     */
    if (!annotation.nullable() && !fieldOrMethod.isAnnotationPresent(GeneratedValue.class) && !fieldOrMethod.isAnnotationPresent(Version.class)
            && !fieldOrMethod.isAnnotationPresent(NotNull.class))
        if (!containsCheckOfType(checks,NotNullCheck.class))
            checks.add(new NotNullCheck());

    // add Length check based on Column.length parameter,but only:
    if (!fieldOrMethod.isAnnotationPresent(Lob.class) && // if @Lob is not present
            !fieldOrMethod.isAnnotationPresent(Enumerated.class) && // if @Enumerated is not present
            !fieldOrMethod.isAnnotationPresent(Length.class) // if an explicit @Length constraint is not present
    ) {
        final LengthCheck lengthCheck = new LengthCheck();
        lengthCheck.setMax(annotation.length());
        checks.add(lengthCheck);
    }

    // add Range check based on Column.precision/scale parameters,but only:
    if (!fieldOrMethod.isAnnotationPresent(Range.class) // if an explicit @Range is not present
            && annotation.precision() > 0 // if precision is > 0
            && Number.class.isAssignableFrom(fieldOrMethod instanceof Field ? ((Field) fieldOrMethod).getType() : ((Method) fieldOrMethod).getReturnType()) // if numeric field type
    ) {
        /* precision = 6,scale = 2  => -9999.99<=x<=9999.99
         * precision = 4,scale = 1  =>   -999.9<=x<=999.9
         */
        final RangeCheck rangeCheck = new RangeCheck();
        rangeCheck.setMax(Math.pow(10,annotation.precision() - annotation.scale()) - Math.pow(0.1,annotation.scale()));
        rangeCheck.setMin(-1 * rangeCheck.getMax());
        checks.add(rangeCheck);
    }
}
项目:omr    文件GrupoVO.java   
/**
 * 
 * @return
 */
@ElementCollection(targetClass=EAuthority.class,fetch=FetchType.EAGER)
@JoinTable(name = "grupo_autorities")
@Enumerated(EnumType.STRING)
@Fetch(FetchMode.SELECT)
public List<EAuthority> getAuthorities() {
    return authorities;
}
项目:omr    文件PessoaVO.java   
@ElementCollection(targetClass=EAuthority.class,fetch=FetchType.EAGER)
@JoinTable(name = "pessoa_autorities")
@Enumerated(EnumType.STRING)
@Fetch(FetchMode.SELECT)
public List<EAuthority> getAuthorities() {
    return authorities;
}
项目:Project-H-Backend    文件KeyPerformanceIndicatorType.java   
/**
 * @return type type of KPI
 */
@Enumerated(EnumType.ORDINAL)
@Column(name = "type",unique = false,nullable = false)
@Field(index=org.hibernate.search.annotations.Index.TOKENIZED,store=Store.NO)
public Type getType() {
    return this.type;
}
项目:powop    文件Description.java   
/**
 *
 * @return Return the subjects that this content is about.
 */
@ElementCollection
@Column(name = "type")
@Enumerated(EnumType.STRING)
@Sort(type = SortType.NATURAL)
public SortedSet<DescriptionType> getTypes() {
    return types;
}
项目:omr    文件GrupoVO.java   
/**
 * 
 * @return
 */
@ElementCollection(targetClass=EAuthority.class,fetch=FetchType.EAGER)
@JoinTable
@Enumerated(EnumType.STRING)
@Fetch(FetchMode.SELECT)
public List<EAuthority> getAuthorities() {
    return authorities;
}
项目:omr    文件PessoaVO.java   
@ElementCollection(targetClass=EAuthority.class,fetch=FetchType.EAGER)
@JoinTable
@Enumerated(EnumType.STRING)
@Fetch(FetchMode.SELECT)
public List<EAuthority> getAuthorities() {
    return authorities;
}
项目: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 );
    }
}
项目:aws-photosharing-example    文件Role.java   
@Id
@Enumerated(EnumType.STRING)    
public com.amazon.photosharing.enums.Role getRole() {return this._role;}
项目:ponto-inteligente-api    文件Lancamento.java   
@Enumerated(EnumType.STRING)
@Column(name = "tipo",nullable = false)
public TipoEnum getTipo() {
    return tipo;
}
项目:ponto-inteligente-api    文件Funcionario.java   
@Enumerated(EnumType.STRING)
@Column(name = "perfil",nullable = false)
public PerfilEnum getPerfil() {
    return perfil;
}
项目:appng-examples    文件Person.java   
@Enumerated(EnumType.STRING)
public Gender getGender() {
    return gender;
}
项目:borabeber-api    文件Usuario.java   
@Enumerated(EnumType.STRING)
@Column(name = "perfil",nullable = false)
public PerfilEnum getPerfil() {
    return perfil;
}
项目:lj-projectbuilder    文件AttributeEntity.java   
@Enumerated(EnumType.STRING)
@Column(name="TYPE",nullable = false)
public DataType getDataType() {
    return dataType;
}
项目:lj-projectbuilder    文件CodeTemplateEntity.java   
@Enumerated(EnumType.STRING)
@Column(name="TEMPLATE_TYPE",nullable = false)
public TemplateType getType() {
    return type;
}
项目:helium    文件Persona.java   
@Enumerated
@Column(name="sexe",nullable=false)
public Sexe getSexe() {
    return this.sexe;
}
项目:webpedidos    文件Cliente.java   
@NotNull
@Enumerated(EnumType.STRING)
@Column(nullable = false,length = 10,name = "tipo_pessoa")
public TipoPessoa getTipoPessoa() {
    return tipoPessoa;
}
项目:webpedidos    文件Pedido.java   
@NotNull
@Enumerated(EnumType.STRING)
@Column(name = "status_pedido",nullable = false,length = 20)
public StatusPedido getStatusPedido() {
    return this.statusPedido;
}
项目:webpedidos    文件Pedido.java   
@NotNull
@Enumerated(EnumType.STRING)
@Column(name = "forma_pagamento",length = 20)
public FormaPagamento getFormaPagamento() {
    return formaPagamento;
}
项目:mycore    文件MCRUser.java   
/**
 * @return the hashType
 */
@Column(name = "hashType",nullable = true)
@Enumerated(EnumType.STRING)
public MCRPasswordHashType getHashType() {
    return password == null ? null : password.hashType;
}
项目:mycore    文件MCRJob.java   
/**
 * Returns the current state ({@link MCRJobStatus}) of the job.
 * 
 */
@Column(name = "status",nullable = false)
@Enumerated(EnumType.STRING)
public MCRJobStatus getStatus() {
    return status;
}
项目:myWMS    文件LOSGoodsReceiptPosition.java   
@Enumerated(EnumType.STRING)
public LOSGoodsReceiptType getReceiptType() {
    return receiptType;
}
项目:myWMS    文件LOSGoodsReceipt.java   
@Enumerated(EnumType.STRING)
public LOSGoodsReceiptState getReceiptState() {
    return receiptState;
}
项目:myWMS    文件OrderReceipt.java   
@Enumerated(EnumType.STRING)
public LOSOrderRequestState getState() {
    return state;
}
项目:myWMS    文件OrderReceipt.java   
@Enumerated(EnumType.STRING)
@Column(nullable=false)
public OrderType getorderType() {
    return orderType;
}
项目:myWMS    文件LOSAdvice.java   
@Enumerated(EnumType.STRING)
public LOSAdviceState getAdviceState() {
    return adviceState;
}
项目:myWMS    文件LOsstockUnitRecord.java   
@Enumerated(EnumType.STRING)
public LOsstockUnitrecordtype getType() {
    return type;
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。