类javax.persistence.Enumerated源码实例Demo

下面列出了怎么用javax.persistence.Enumerated的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: o2oa   文件: CheckCore.java
public static void checkEnum(List<Class<?>> classes) throws Exception {
	for (Class<?> cls : classes) {
		List<Field> fields = FieldUtils.getFieldsListWithAnnotation(cls, FieldDescribe.class);
		for (Field field : fields) {
			if (field.getType().isEnum()) {
				Enumerated enumerated = field.getAnnotation(Enumerated.class);
				Column column = field.getAnnotation(Column.class);
				if (null == enumerated || (!Objects.equals(EnumType.STRING, enumerated.value())) || (null == column)
						|| column.length() > 200) {
					System.err.println(String.format("checkEnum error: class: %s, field: %s.", cls.getName(),
							field.getName()));
				}
			}
		}
	}
}
 
源代码2 项目: 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 ) );
	}
}
 
源代码3 项目: cloudbreak   文件: EnumeratedTest.java
@Test
public void testIfThereAreEnumeratedAnnotations() {
    Reflections reflections = new Reflections("com.sequenceiq",
            new FieldAnnotationsScanner());

    Map<String, Set<String>> enumeratedFields = new HashMap<>();
    reflections.getFieldsAnnotatedWith(Enumerated.class).forEach(field -> {
        try {
            String className = field.getDeclaringClass().getName();
            enumeratedFields.computeIfAbsent(className, key -> new HashSet<>()).add(field.toString());
        } catch (RuntimeException e) {
            // ignore if cannot check fields
        }
    });

    Set<String> fields = new HashSet<>();

    enumeratedFields.forEach((key, value) -> {
        fields.add(key + ": " + String.join(", ", value));
    });

    Assert.assertTrue(
            String.format("Classes with @Enumerated fields: %s%s%s%s", lineSeparator(),
                    String.join(lineSeparator(), fields), lineSeparator(), "Use @Converter instead of @Enumerated"), enumeratedFields.isEmpty());
}
 
源代码4 项目: website   文件: User.java
@ElementCollection(targetClass = Role.class, fetch = FetchType.EAGER)
@CollectionTable(name = "USER_ROLES", joinColumns = @JoinColumn(name = "USER_ID"))
@Enumerated(EnumType.STRING)
@Column(name = "role", nullable = false)
public Set<Role> getRoles() {
	return roles;
}
 
源代码5 项目: cia   文件: AssignmentElement.java
/**
* Gets the org code.
*
* @return the org code
*/
  @Basic
  @Column(name = "ORG_CODE")
  @Enumerated(EnumType.STRING)
  public OrgCode getOrgCode() {
      return orgCode;
  }
 
源代码6 项目: cia   文件: AssignmentElement.java
/**
* Gets the role code.
*
* @return the role code
*/
  @Basic
  @Column(name = "ROLE_CODE")
  @Enumerated(EnumType.STRING)
  public RoleStatus getRoleCode() {
      return roleCode;
  }
 
源代码7 项目: cia   文件: AssignmentElement.java
/**
* Gets the status.
*
* @return the status
*/
  @Basic
  @Column(name = "STATUS")
  @Enumerated(EnumType.STRING)
  public RoleStatus getStatus() {
      return status;
  }
 
源代码8 项目: cia   文件: PersonElement.java
/**
* Gets the gender.
*
* @return the gender
*/
  @Basic
  @Column(name = "GENDER")
  @Enumerated(EnumType.STRING)
  public SexType getGender() {
      return gender;
  }
 
源代码9 项目: cia   文件: PersonElement.java
/**
* Gets the status.
*
* @return the status
*/
  @Basic
  @Column(name = "STATUS")
  @Enumerated(EnumType.STRING)
  public RoleStatus getStatus() {
      return status;
  }
 
源代码10 项目: cia   文件: VoteDataDto.java
/**
* Gets the vote.
*
* @return the vote
*/
  @Basic
  @Column(name = "VOTE")
  @Enumerated(EnumType.STRING)
  public VoteDecision getVote() {
      return vote;
  }
 
源代码11 项目: cia   文件: VoteDataDto.java
/**
* Gets the ballot type.
*
* @return the ballot type
*/
  @Basic
  @Column(name = "BALLOT_TYPE")
  @Enumerated(EnumType.STRING)
  public BallotType getBallotType() {
      return ballotType;
  }
 
源代码12 项目: cia   文件: VoteData.java
/**
* Gets the vote.
*
* @return the vote
*/
  @Basic
  @Column(name = "VOTE")
  @Enumerated(EnumType.STRING)
  public VoteDecision getVote() {
      return vote;
  }
 
源代码13 项目: cia   文件: VoteData.java
/**
* Gets the ballot type.
*
* @return the ballot type
*/
  @Basic
  @Column(name = "BALLOT_TYPE")
  @Enumerated(EnumType.STRING)
  public BallotType getBallotType() {
      return ballotType;
  }
 
源代码14 项目: website   文件: User.java
@ElementCollection(targetClass = Permission.class, fetch = FetchType.EAGER)
@CollectionTable(name = "USER_PERMISSIONS", joinColumns = @JoinColumn(name = "USER_ID"))
@Enumerated(EnumType.STRING)
@Column(name = "permission", nullable = false)
public Set<Permission> getPermissions() {
	return permissions;
}
 
源代码15 项目: cia   文件: Region.java
/**
* Gets the value.
*
* @return the value
*/
  @Basic
  @Column(name = "VALUE_")
  @Enumerated(EnumType.STRING)
  public RegionCategory getValue() {
      return value;
  }
 
源代码16 项目: cia   文件: Adminregion.java
/**
* Gets the value.
*
* @return the value
*/
  @Basic
  @Column(name = "VALUE_")
  @Enumerated(EnumType.STRING)
  public AdminRegionCategory getValue() {
      return value;
  }
 
源代码17 项目: cia   文件: LendingType.java
/**
* Gets the value.
*
* @return the value
*/
  @Basic
  @Column(name = "VALUE_")
  @Enumerated(EnumType.STRING)
  public LendingTypeCategory getValue() {
      return value;
  }
 
源代码18 项目: cia   文件: PersonData.java
/**
* Gets the gender.
*
* @return the gender
*/
  @Basic
  @Column(name = "GENDER")
  @Enumerated(EnumType.STRING)
  public SexType getGender() {
      return gender;
  }
 
源代码19 项目: cia   文件: DocumentReferenceData.java
/**
* Gets the reference type.
*
* @return the reference type
*/
  @Basic
  @Column(name = "REFERENCE_TYPE")
  @Enumerated(EnumType.STRING)
  public ReferenceType getReferenceType() {
      return referenceType;
  }
 
源代码20 项目: cia   文件: DocumentPersonReferenceData.java
/**
* Gets the role description.
*
* @return the role description
*/
  @Basic
  @Column(name = "ROLE_DESCRIPTION")
  @Enumerated(EnumType.STRING)
  public DocumentPersonReferenceRoleType getRoleDescription() {
      return roleDescription;
  }
 
源代码21 项目: website   文件: Product.java
@Enumerated(EnumType.STRING)
public ProductAvailabilityStatus getAvailabilityStatus() {
	if (availabilityStatus == null) {
		availabilityStatus = ProductAvailabilityStatus.ON_SALE;
	}
	return availabilityStatus;
}
 
源代码22 项目: uyuni   文件: ProjectSource.java
/**
 * Gets the state.
 *
 * @return state
 */
@Enumerated(EnumType.STRING)
@Column
public State getState() {
    return state;
}
 
源代码23 项目: uyuni   文件: EnvironmentTarget.java
/**
 * Gets the status.
 *
 * @return status
 */
@Column
@Enumerated(EnumType.STRING)
public Status getStatus() {
    return status;
}
 
源代码24 项目: uyuni   文件: FilterCriteria.java
/**
 * Gets the type.
 *
 * @return type
 */
@Column(name = "matcher")
@Enumerated(EnumType.STRING)
public Matcher getMatcher() {
    return matcher;
}
 
源代码25 项目: uyuni   文件: NotificationMessage.java
/**
 * Get the type of this notification.
 * @return notification type
 */
@Enumerated(EnumType.STRING)
@Column(columnDefinition = "type")
public NotificationType getType() {
    return type;
}
 
源代码26 项目: aws-photosharing-example   文件: Role.java
@Id
@Enumerated(EnumType.STRING)	
public com.amazon.photosharing.enums.Role getRole() {return this._role;}
 
源代码27 项目: 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 );
	}
}
 
源代码28 项目: lams   文件: SimpleValueBinder.java
private void applyAttributeConverter(XProperty property, ConverterDescriptor attributeConverterDescriptor) {
	if ( attributeConverterDescriptor == 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 ( !key && property.isAnnotationPresent( Temporal.class ) ) {
		LOG.debugf( "Skipping AttributeConverter checks for Temporal attribute [%s]", property.getName() );
		return;
	}
	if ( key && property.isAnnotationPresent( MapKeyTemporal.class ) ) {
		LOG.debugf( "Skipping AttributeConverter checks for map-key annotated as MapKeyTemporal [%s]", property.getName() );
		return;
	}

	if ( !key && property.isAnnotationPresent( Enumerated.class ) ) {
		LOG.debugf( "Skipping AttributeConverter checks for Enumerated attribute [%s]", property.getName() );
		return;
	}
	if ( key && property.isAnnotationPresent( MapKeyEnumerated.class ) ) {
		LOG.debugf( "Skipping AttributeConverter checks for map-key annotated as MapKeyEnumerated [%s]", property.getName() );
		return;
	}

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

	this.attributeConverterDescriptor = attributeConverterDescriptor;
}
 
源代码29 项目: mybatis-jpa   文件: ColumnMetaResolver.java
public static String resolveJdbcAlias(Field field) {

    if (field.isAnnotationPresent(MappedJdbcType.class)) {
      MappedJdbcType jdbcType = field.getAnnotation(MappedJdbcType.class);
      return jdbcType.value().name();
    }

    if (field.isAnnotationPresent(CodeEnum.class)) {
      CodeEnum codeEnum = field.getAnnotation(CodeEnum.class);
      if (Objects.equals(codeEnum.value(), CodeType.INT)) {
        return JdbcType.INTEGER.name();
      }
      if (Objects.equals(codeEnum.value(), CodeType.STRING)) {
        return JdbcType.VARCHAR.name();
      }
    }
    if (field.getType().isEnum()) {
      if (field.isAnnotationPresent(Enumerated.class)) {
        Enumerated enumerated = field.getAnnotation(Enumerated.class);
        if (Objects.equals(enumerated.value(), EnumType.ORDINAL)) {
          return "INTEGER";
        }
      }
      return "VARCHAR";
    }

    Class<?> fieldType = field.getType();

    if (Integer.class.equals(fieldType)) {
      return "INTEGER";
    }
    if (Double.class.equals(fieldType)) {
      return "DOUBLE";
    }
    if (Float.class.equals(fieldType)) {
      return "FLOAT";
    }
    if (String.class.equals(fieldType)) {
      return "VARCHAR";
    }
    if (java.util.Date.class.isAssignableFrom(fieldType)) {
      return "TIMESTAMP";
    }
    return null;
  }
 
源代码30 项目: ponto-inteligente-api   文件: Lancamento.java
@Enumerated(EnumType.STRING)
@Column(name = "tipo", nullable = false)
public TipoEnum getTipo() {
	return tipo;
}
 
 类所在包
 同包方法