本文整理匯總了Java中com.fasterxml.jackson.annotation.ObjectIdGenerators.PropertyGenerator方法的典型用法代碼示例。如果您正苦於以下問題:Java ObjectIdGenerators.PropertyGenerator方法的具體用法?Java ObjectIdGenerators.PropertyGenerator怎麽用?Java ObjectIdGenerators.PropertyGenerator使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.fasterxml.jackson.annotation.ObjectIdGenerators
的用法示例。
在下文中一共展示了ObjectIdGenerators.PropertyGenerator方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getOrganisationUnits
import com.fasterxml.jackson.annotation.ObjectIdGenerators; //導入方法依賴的package包/類
@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;
}
示例2: getTurMLCategory
import com.fasterxml.jackson.annotation.ObjectIdGenerators; //導入方法依賴的package包/類
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
@JsonIdentityReference(alwaysAsId = true)
public TurMLCategory getTurMLCategory() {
return this.turMLCategory;
}
示例3: findObjectIdInfo
import com.fasterxml.jackson.annotation.ObjectIdGenerators; //導入方法依賴的package包/類
@Override
public ObjectIdInfo findObjectIdInfo(Annotated annotated) {
Class<?> rawClass = annotated.getType().getRawClass();
for (Type<?> type : model.getTypes()) {
if (type.getClassType() == rawClass && type.getSingleKeyAttribute() != null) {
Attribute<?, ?> attribute = type.getSingleKeyAttribute();
String name = removePrefix(attribute.getPropertyName());
if (useTableNames) {
name = attribute.getName();
}
// if the name is overridden use that
Class<?> superClass = rawClass.getSuperclass();
while (superClass != Object.class && superClass != null) {
try {
Field field = superClass.getDeclaredField(attribute.getPropertyName());
JsonProperty jsonProperty = field.getAnnotation(JsonProperty.class);
if (jsonProperty != null) {
name = jsonProperty.value();
break;
}
} catch (NoSuchFieldException ignored) {
}
superClass = superClass.getSuperclass();
}
return new ObjectIdInfo(new PropertyName(name), rawClass,
ObjectIdGenerators.PropertyGenerator.class,
EntityStoreResolver.class);
}
}
return super.findObjectIdInfo(annotated);
}
示例4: addObjectIdReader
import com.fasterxml.jackson.annotation.ObjectIdGenerators; //導入方法依賴的package包/類
protected void addObjectIdReader(DeserializationContext ctxt,
BeanDescription beanDesc, BeanDeserializerBuilder builder)
throws JsonMappingException
{
ObjectIdInfo objectIdInfo = beanDesc.getObjectIdInfo();
if (objectIdInfo == null) {
return;
}
Class<?> implClass = objectIdInfo.getGeneratorType();
JavaType idType;
SettableBeanProperty idProp;
ObjectIdGenerator<?> gen;
// Just one special case: Property-based generator is trickier
if (implClass == ObjectIdGenerators.PropertyGenerator.class) { // most special one, needs extra work
String propName = objectIdInfo.getPropertyName();
idProp = builder.findProperty(propName);
if (idProp == null) {
throw new IllegalArgumentException("Invalid Object Id definition for "
+beanDesc.getBeanClass().getName()+": can not find property with name '"+propName+"'");
}
idType = idProp.getType();
gen = new PropertyBasedObjectIdGenerator(objectIdInfo.getScope());
} else {
JavaType type = ctxt.constructType(implClass);
idType = ctxt.getTypeFactory().findTypeParameters(type, ObjectIdGenerator.class)[0];
idProp = null;
gen = ctxt.objectIdGeneratorInstance(beanDesc.getClassInfo(), objectIdInfo);
}
// also: unlike with value deserializers, let's just resolve one we need here
JsonDeserializer<?> deser = ctxt.findRootValueDeserializer(idType);
builder.setObjectIdReader(ObjectIdReader.construct(idType,
objectIdInfo.getPropertyName(), gen, deser, idProp));
}
示例5: b
import com.fasterxml.jackson.annotation.ObjectIdGenerators; //導入方法依賴的package包/類
@JsonIdentityReference(alwaysAsId = true)
@JsonIdentityInfo(
resolver = ByidInstanceResolver.class,
generator = ObjectIdGenerators.PropertyGenerator.class,
property = "id")
Byid b();
示例6: IdParameterWrapperExt
import com.fasterxml.jackson.annotation.ObjectIdGenerators; //導入方法依賴的package包/類
public IdParameterWrapperExt( @JsonProperty( "node" ) @JsonIdentityInfo( generator = ObjectIdGenerators.PropertyGenerator.class,
property = "customId" ) ValueParameterNodeExt node ) {
this.test = node;
}
示例7: createContextual
import com.fasterxml.jackson.annotation.ObjectIdGenerators; //導入方法依賴的package包/類
/**
* Although most of post-processing is done in resolve(), we only get
* access to referring property's annotations here; and this is needed
* to support per-property ObjectIds.
* We will also consider Shape transformations (read from Array) at this
* point, since it may come from either Class definition or property.
*/
// @Override
public JsonDeserializer<?> createContextual(DeserializationContext ctxt,
BeanProperty property) throws JsonMappingException
{
ObjectIdReader oir = _objectIdReader;
String[] ignorals = null;
// First: may have an override for Object Id:
final AnnotationIntrospector intr = ctxt.getAnnotationIntrospector();
final AnnotatedMember accessor = (property == null || intr == null)
? null : property.getMember();
if (property != null && intr != null) {
ignorals = intr.findPropertiesToIgnore(accessor);
ObjectIdInfo objectIdInfo = intr.findObjectIdInfo(accessor);
if (objectIdInfo != null) { // some code duplication here as well (from BeanDeserializerFactory)
// 2.1: allow modifications by "id ref" annotations as well:
objectIdInfo = intr.findObjectReferenceInfo(accessor, objectIdInfo);
Class<?> implClass = objectIdInfo.getGeneratorType();
// Property-based generator is trickier
JavaType idType;
SettableBeanProperty idProp;
ObjectIdGenerator<?> idGen;
if (implClass == ObjectIdGenerators.PropertyGenerator.class) {
String propName = objectIdInfo.getPropertyName();
idProp = findProperty(propName);
if (idProp == null) {
throw new IllegalArgumentException("Invalid Object Id definition for "
+getBeanClass().getName()+": can not find property with name '"+propName+"'");
}
idType = idProp.getType();
idGen = new PropertyBasedObjectIdGenerator(objectIdInfo.getScope());
} else { // other types need to be simpler
JavaType type = ctxt.constructType(implClass);
idType = ctxt.getTypeFactory().findTypeParameters(type, ObjectIdGenerator.class)[0];
idProp = null;
idGen = ctxt.objectIdGeneratorInstance(accessor, objectIdInfo);
}
JsonDeserializer<?> deser = ctxt.findRootValueDeserializer(idType);
oir = ObjectIdReader.construct(idType, objectIdInfo.getPropertyName(),
idGen, deser, idProp);
}
}
// either way, need to resolve serializer:
BeanDeserializerBase contextual = this;
if (oir != null && oir != _objectIdReader) {
contextual = contextual.withObjectIdReader(oir);
}
// And possibly add more properties to ignore
if (ignorals != null && ignorals.length != 0) {
HashSet<String> newIgnored = ArrayBuilders.setAndArray(contextual._ignorableProps, ignorals);
contextual = contextual.withIgnorableProperties(newIgnored);
}
// One more thing: are we asked to serialize POJO as array?
JsonFormat.Shape shape = null;
if (accessor != null) {
JsonFormat.Value format = intr.findFormat((Annotated) accessor);
if (format != null) {
shape = format.getShape();
}
}
if (shape == null) {
shape = _serializationShape;
}
if (shape == JsonFormat.Shape.ARRAY) {
contextual = contextual.asArrayDeserializer();
}
return contextual;
}