/** * * @return */ @ElementCollection(targetClass=EAuthority.class,fetch=FetchType.EAGER) @JoinTable(name = "grupo_autorities") @Enumerated(EnumType.STRING) @Fetch(FetchMode.SELECT) public List<EAuthority> getAuthorities() { return authorities; }
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 ) ); } }
/** * 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++; } } } }
public BasicTypeRegistry(TypeConfiguration typeConfiguration) { this.typeConfiguration = typeConfiguration; this.baseJdbcRecommendedSqlTypeMappingContext = new JdbcRecommendedSqlTypeMappingContext() { @Override public boolean isNationalized() { return false; } @Override public boolean isLob() { return false; } @Override public EnumType getEnumeratedType() { return EnumType.STRING; } @Override public TypeConfiguration getTypeConfiguration() { return typeConfiguration; } }; registerBasicTypes(); }
/** * 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 ) ); } }
@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; }
public static EnumType valueOf(ENUM_TYPE en) { switch (en) { case ORDINAL: return EnumType.ORDINAL; case STRING: return EnumType.STRING; default: return null; } }
public EnumType getEnumType() { if (enumType == null && classMapper != null) { enumType = classMapper.enumType; } return enumType; }
@Test public void testSerializeBasicDateTypeRaw() { BascicDateType datetype = new BascicDateType(); datetype.character = 'A'; datetype.pdouble = 123.456; datetype.pfloat = 3.456f; datetype.ddouble = 5.34; datetype.dfloat = 89.345f; String json = oson.setAppendingFloatingZero(false).setEnumType(EnumType.ORDINAL).setDate2Long(true).serialize(datetype); Map<String, Object> map = (Map<String, Object>)oson.getListMapObject(json); Field[] fields = oson.getFields(BascicDateType.class); for (Field field: fields) { String name = field.getName(); // System.err.println("\n" + field.getName() + ":"); //System.err.println(field.getType()); Object obj = map.get(name); // System.err.println(obj); if (obj != null) { //System.err.println(obj.getClass()); assertTrue(ObjectUtil.isSameDataType(field.getType(), obj.getClass())); } } }
@Test public void testSerializeEnumWithEnumType() { Enum value = MODIFIER.Synchronized; String expected = "10"; oson.setEnumType(EnumType.ORDINAL); String result = oson.serialize(value); assertEquals(expected, result); }
/** * Getter for property type. * * @return Value of property type. */ @Enumerated(EnumType.STRING) @Column(nullable = false) public LogItemType getType() { return this.type; }
@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); }
@ElementCollection(targetClass=EAuthority.class,fetch=FetchType.EAGER) @JoinTable(name = "pessoa_autorities") @Enumerated(EnumType.STRING) @Fetch(FetchMode.SELECT) public List<EAuthority> getAuthorities() { return authorities; }
/** * @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; }
/** * * @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; }
@Override public SqlTypeDescriptor getJdbcRecommendedSqlType(JdbcRecommendedSqlTypeMappingContext context) { final int jdbcCode; if ( context.getEnumeratedType() != null && context.getEnumeratedType() == EnumType.STRING ) { return context.isNationalized() ? context.getTypeConfiguration().getSqlTypeDescriptorRegistry().getDescriptor( Types.NVARCHAR ) : context.getTypeConfiguration().getSqlTypeDescriptorRegistry().getDescriptor( Types.VARCHAR ); } else { return context.getTypeConfiguration().getSqlTypeDescriptorRegistry().getDescriptor( Types.INTEGER ); } }
/** * * @return */ @ElementCollection(targetClass=EAuthority.class,fetch=FetchType.EAGER) @JoinTable @Enumerated(EnumType.STRING) @Fetch(FetchMode.SELECT) public List<EAuthority> getAuthorities() { return authorities; }
@ElementCollection(targetClass=EAuthority.class,fetch=FetchType.EAGER) @JoinTable @Enumerated(EnumType.STRING) @Fetch(FetchMode.SELECT) public List<EAuthority> getAuthorities() { return authorities; }
@Id @Enumerated(EnumType.STRING) public com.amazon.photosharing.enums.Role getRole() {return this._role;}
@Enumerated(EnumType.STRING) @Column(name = "tipo", nullable = false) public TipoEnum getTipo() { return tipo; }
@Enumerated(EnumType.STRING) @Column(name = "perfil", nullable = false) public PerfilEnum getPerfil() { return perfil; }
@Enumerated(EnumType.STRING) public Gender getGender() { return gender; }
public EnumType value() { return valueOf(this); }
private EnumType getEnumType() { return options.getEnumType(); }
public Oson setEnumType(EnumType enumType) { options.setEnumType(enumType); return this; }
public <T> Oson setEnumType(Class<T> type, EnumType enumType) { cMap(type).setEnumType(enumType); return this; }
public FieldMapper setEnumType(EnumType enumType) { this.enumType = enumType; return this; }
public EnumType getEnumType() { return enumType; }
public void setEnumType(EnumType enumType) { this.enumType = enumType; }
public ClassMapper setEnumType(EnumType enumType) { this.enumType = enumType; return this; }
@Enumerated(EnumType.STRING) @Column(name="TYPE", nullable = false) public DataType getDataType() { return dataType; }
@Enumerated(EnumType.STRING) @Column(name="TEMPLATE_TYPE", nullable = false) public TemplateType getType() { return type; }