private void getIdentityInfo(ClassInformation information, ReflectClass<?> cls) { JsonIdentityInfo identity = cls.getAnnotation(JsonIdentityInfo.class); if (identity == null) { return; } Class<?> generator = identity.generator(); if (generator.equals(ObjectIdGenerators.IntSequenceGenerator.class)) { information.idGenerator = IdGeneratorType.INTEGER; } else if (generator.equals(ObjectIdGenerators.PropertyGenerator.class)) { information.idGenerator = IdGeneratorType.PROPERTY; } else if (generator.equals(ObjectIdGenerators.None.class)) { information.idGenerator = IdGeneratorType.NONE; } else { information.idGenerator = IdGeneratorType.NONE; diagnostics.warning(null, "{{t0}}: unsupported identity generator {{t1}}", cls, generator); } if (information.idGenerator == IdGeneratorType.NONE) { information.idProperty = null; } else { information.idProperty = identity.property(); } }
@JsonProperty @JacksonXmlElementWrapper( localName = "organisationUnits", namespace = DxfNamespaces.DXF_2_0 ) @JacksonXmlProperty( localName = "organisationUnit", namespace = DxfNamespaces.DXF_2_0 ) @JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id") @JsonIdentityReference(alwaysAsId=true) public Set<OrganisationUnit> getOrganisationUnits() { return organisationUnits; }
public ObjectIdInfo findObjectIdInfo(Annotated paramAnnotated) { JsonIdentityInfo localJsonIdentityInfo = (JsonIdentityInfo)paramAnnotated.getAnnotation(JsonIdentityInfo.class); if ((localJsonIdentityInfo == null) || (localJsonIdentityInfo.generator() == ObjectIdGenerators.None.class)) return null; return new ObjectIdInfo(localJsonIdentityInfo.property(), localJsonIdentityInfo.scope(), localJsonIdentityInfo.generator()); }
private static void processBeanAnnotation( TreeLogger logger, JacksonTypeOracle typeOracle, RebindConfiguration configuration, JType type, PropertyAccessors propertyAccessors, PropertyInfoBuilder builder ) throws UnableToCompleteException { // identity Optional<JsonIdentityInfo> jsonIdentityInfo = propertyAccessors.getAnnotation( JsonIdentityInfo.class ); Optional<JsonIdentityReference> jsonIdentityReference = propertyAccessors.getAnnotation( JsonIdentityReference.class ); // type info Optional<JsonTypeInfo> jsonTypeInfo = propertyAccessors.getAnnotation( JsonTypeInfo.class ); Optional<JsonSubTypes> propertySubTypes = propertyAccessors.getAnnotation( JsonSubTypes.class ); // if no annotation is present that overrides bean processing, we just stop now if ( !jsonIdentityInfo.isPresent() && !jsonIdentityReference.isPresent() && !jsonTypeInfo.isPresent() && !propertySubTypes .isPresent() ) { // no override on field return; } // we need to find the bean to apply annotation on Optional<JClassType> beanType = extractBeanType( logger, typeOracle, type, builder.getPropertyName() ); if ( beanType.isPresent() ) { if ( jsonIdentityInfo.isPresent() || jsonIdentityReference.isPresent() ) { builder.setIdentityInfo( BeanProcessor.processIdentity( logger, typeOracle, configuration, beanType .get(), jsonIdentityInfo, jsonIdentityReference ) ); } if ( jsonTypeInfo.isPresent() || propertySubTypes.isPresent() ) { builder.setTypeInfo( BeanProcessor.processType( logger, typeOracle, configuration, beanType .get(), jsonTypeInfo, propertySubTypes ) ); } } else { logger.log( Type.WARN, "Annotation present on property " + builder.getPropertyName() + " but no valid bean has been found." ); } }
@JsonIdentityReference(alwaysAsId = true) @JsonIdentityInfo( resolver = ByidInstanceResolver.class, generator = ObjectIdGenerators.PropertyGenerator.class, property = "id") Byid b();
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id") @JsonIdentityReference(alwaysAsId = true) public TurMLCategory getTurMLCategory() { return this.turMLCategory; }
private static Optional<BeanIdentityInfo> processIdentity( TreeLogger logger, JacksonTypeOracle typeOracle, RebindConfiguration configuration, JClassType type ) throws UnableToCompleteException { return processIdentity( logger, typeOracle, configuration, type, Optional.<JsonIdentityInfo>absent(), Optional .<JsonIdentityReference>absent() ); }
public IdParameterWrapper( @JsonProperty( "node" ) @JsonIdentityInfo( generator = ObjectIdGenerators.IntSequenceGenerator.class, property = "@id" ) ValueParameterNode node ) { this.test = node; }
public IdParameterWrapperExt( @JsonProperty( "node" ) @JsonIdentityInfo( generator = ObjectIdGenerators.PropertyGenerator.class, property = "customId" ) ValueParameterNodeExt node ) { this.test = node; }