當前位置: 首頁>>代碼示例>>Java>>正文


Java ObjectIdGenerators類代碼示例

本文整理匯總了Java中com.fasterxml.jackson.annotation.ObjectIdGenerators的典型用法代碼示例。如果您正苦於以下問題:Java ObjectIdGenerators類的具體用法?Java ObjectIdGenerators怎麽用?Java ObjectIdGenerators使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ObjectIdGenerators類屬於com.fasterxml.jackson.annotation包,在下文中一共展示了ObjectIdGenerators類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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;
}
 
開發者ID:dhis2,項目名稱:dhis2-core,代碼行數:10,代碼來源:Option.java

示例2: getIdentityInfo

import com.fasterxml.jackson.annotation.ObjectIdGenerators; //導入依賴的package包/類
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();
    }
}
 
開發者ID:konsoletyper,項目名稱:teavm-flavour,代碼行數:25,代碼來源:ClassInformationProvider.java

示例3: getTurMLCategory

import com.fasterxml.jackson.annotation.ObjectIdGenerators; //導入依賴的package包/類
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
@JsonIdentityReference(alwaysAsId = true)
public TurMLCategory getTurMLCategory() {
	return this.turMLCategory;
}
 
開發者ID:openviglet,項目名稱:turing,代碼行數:6,代碼來源:TurDataGroupSentence.java

示例4: 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);
}
 
開發者ID:requery,項目名稱:requery,代碼行數:34,代碼來源:EntityAnnotationIntrospector.java

示例5: 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));
}
 
開發者ID:joyplus,項目名稱:joyplus-tv,代碼行數:35,代碼來源:BeanDeserializerFactory.java

示例6: b

import com.fasterxml.jackson.annotation.ObjectIdGenerators; //導入依賴的package包/類
@JsonIdentityReference(alwaysAsId = true)
@JsonIdentityInfo(
    resolver = ByidInstanceResolver.class,
    generator = ObjectIdGenerators.PropertyGenerator.class,
    property = "id")
Byid b();
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:7,代碼來源:ByIdProperty.java

示例7: IdParameterWrapper

import com.fasterxml.jackson.annotation.ObjectIdGenerators; //導入依賴的package包/類
public IdParameterWrapper( @JsonProperty( "node" ) @JsonIdentityInfo( generator = ObjectIdGenerators.IntSequenceGenerator.class,
        property = "@id" ) ValueParameterNode node ) {
    this.test = node;
}
 
開發者ID:nmorel,項目名稱:gwt-jackson,代碼行數:5,代碼來源:ObjectIdDeserializationTester.java

示例8: IdParameterWrapperExt

import com.fasterxml.jackson.annotation.ObjectIdGenerators; //導入依賴的package包/類
public IdParameterWrapperExt( @JsonProperty( "node" ) @JsonIdentityInfo( generator = ObjectIdGenerators.PropertyGenerator.class,
        property = "customId" ) ValueParameterNodeExt node ) {
    this.test = node;
}
 
開發者ID:nmorel,項目名稱:gwt-jackson,代碼行數:5,代碼來源:ObjectIdDeserializationTester.java

示例9: 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;
    }
 
開發者ID:joyplus,項目名稱:joyplus-tv,代碼行數:79,代碼來源:BeanDeserializerBase.java


注:本文中的com.fasterxml.jackson.annotation.ObjectIdGenerators類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。