Package com.fasterxml.jackson.databind.deser

Examples of com.fasterxml.jackson.databind.deser.SettableBeanProperty


        } else if (deserializer instanceof BeanDeserializerBase) {
            BeanDeserializerBase beanDeserializer = (BeanDeserializerBasedeserializer;
            ObjectNode fieldDefaults = config.getNodeFactory().objectNode();
            Iterator<SettableBeanProperty> propertyIterator = beanDeserializer.properties();
            while (propertyIterator.hasNext()) {
                SettableBeanProperty prop = propertyIterator.next();
                Class<?> declaringClass = prop.getMember().getDeclaringClass();
                String canonicalClassName = declaringClass.getCanonicalName();
                if ((canonicalClassName != null) && globalDefaults.hasPath(canonicalClassName)) {
                    Config declarerDefaults = globalDefaults.getConfig(canonicalClassName);
                    String propertyName = prop.getName();
                    if (declarerDefaults.hasPath(propertyName)) {
                        ConfigValue defaultValue = declarerDefaults.getValue(propertyName);
                        JsonNode fieldDefault = Jackson.configConverter(defaultValue);
                        fieldDefaults.set(propertyName, fieldDefault);
                    }
View Full Code Here


      final int bcount = _buckets.length;
        Bucket[] newBuckets = new Bucket[bcount];
        System.arraycopy(_buckets, 0, newBuckets, 0, bcount);
        final String propName = newProperty.getName();
        // and then see if it's add or replace:
      SettableBeanProperty oldProp = find(newProperty.getName());
      if (oldProp == null) { // add
          // first things first: add or replace?
          // can do a straight copy, since all additions are at the front
          // and then insert the new property:
          int index = propName.hashCode() & _hashMask;
View Full Code Here

            return this;
        }
        Iterator<SettableBeanProperty> it = iterator();
        ArrayList<SettableBeanProperty> newProps = new ArrayList<SettableBeanProperty>();
        while (it.hasNext()) {
            SettableBeanProperty prop = it.next();
            String newName = transformer.transform(prop.getName());
            prop = prop.withName(newName);
            JsonDeserializer<?> deser = prop.getValueDeserializer();
            if (deser != null) {
                @SuppressWarnings("unchecked")
                JsonDeserializer<Object> newDeser = (JsonDeserializer<Object>)
                    deser.unwrappingDeserializer(transformer);
                if (newDeser != deser) {
                    prop = prop.withValueDeserializer(newDeser);
                }
            }
            newProps.add(prop);
        }
        // should we try to re-index? Ordering probably changed but called probably doesn't want changes...
View Full Code Here

        _properties = new HashMap<String, SettableBeanProperty>();
        SettableBeanProperty[] propertiesWithInjectables = null;
        final int len = creatorProps.length;
        _propertyCount = len;
        for (int i = 0; i < len; ++i) {
            SettableBeanProperty prop = creatorProps[i];
            _properties.put(prop.getName(), prop);
            Object injectableValueId = prop.getInjectableValueId();
            if (injectableValueId != null) {
                if (propertiesWithInjectables == null) {
                    propertiesWithInjectables = new SettableBeanProperty[len];
                }
                propertiesWithInjectables[i] = prop;
View Full Code Here

                    continue;
                }
                // but not just one
                throw ctxt.mappingException("Missing external type id property '"+_properties[i].getTypePropertyName());
            } else if (_tokens[i] == null) {
                SettableBeanProperty prop = _properties[i].getProperty();
                throw ctxt.mappingException("Missing property '"+prop.getName()+"' for external type id '"+_properties[i].getTypePropertyName());
            }
            _deserializeAndSet(jp, ctxt, bean, i);
        }
        return bean;
    }
View Full Code Here

                    continue;
                }
                // but not just one
                throw ctxt.mappingException("Missing external type id property '"+_properties[i].getTypePropertyName());
            } else if (_tokens[i] == null) {
                SettableBeanProperty prop = _properties[i].getProperty();
                throw ctxt.mappingException("Missing property '"+prop.getName()+"' for external type id '"+_properties[i].getTypePropertyName());
            }
            values[i] = _deserialize(jp, ctxt, i);
        }
        // second: fill in creator properties:
        for (int i = 0; i < len; ++i) {
            SettableBeanProperty prop = _properties[i].getProperty();
            if (creator.findCreatorProperty(prop.getName()) != null) {
                buffer.assignParameter(prop.getCreatorIndex(), values[i]);
            }
        }
        Object bean = creator.build(ctxt, buffer);
        // third: assign non-creator properties
        for (int i = 0; i < len; ++i) {
            SettableBeanProperty prop = _properties[i].getProperty();
            if (creator.findCreatorProperty(prop.getName()) == null) {
                prop.set(bean, values[i]);
            }
        }
        return bean;
    }
View Full Code Here

    private void handleDefaultsAndRequiredAndNull(DeserializationContext ctxt, ObjectNode fieldValues)
            throws JsonMappingException {
        Iterator<SettableBeanProperty> propertyIterator = properties();
        while (propertyIterator.hasNext()) {
            SettableBeanProperty prop = propertyIterator.next();
            String propertyName = prop.getName();
            JsonNode fieldValue = fieldValues.path(propertyName);
            if (fieldValue.isMissingNode() || fieldValue.isNull()) {
                if (fieldDefaults.hasNonNull(propertyName)) {
                    fieldValue = fieldDefaults.get(propertyName).deepCopy();
                    fieldValues.set(propertyName, fieldValue);
                } else if (prop.isRequired()) {
                    throw MissingPropertyException.from(ctxt.getParser(), prop.getType().getRawClass(),
                                                        propertyName, getKnownPropertyNames());
                } else if (fieldValue.isNull()
                           && (prop.getType().isPrimitive() || (prop.getValueDeserializer().getNullValue() == null))) {
                    // don't overwrite possible hard-coded defaults/ values with nulls unless they are fancy
                    fieldValues.remove(propertyName);
                }
            }
            if (fieldValue.isTextual()) {
                try {
                    Time time = prop.getAnnotation(Time.class);
                    if (time != null) {
                        Duration dropWizardDuration = Duration.parse(fieldValue.asText());
                        long asLong = time.value().convert(dropWizardDuration.getQuantity(), dropWizardDuration.getUnit());
                        fieldValues.put(propertyName, asLong);
                    } else if (prop.getAnnotation(Bytes.class) != null) {
                        Size dropWizardSize = Size.parse(fieldValue.asText());
                        long asLong = dropWizardSize.toBytes();
                        fieldValues.put(propertyName, asLong);
                    }
                } catch (Throwable cause) {
                    throw JsonMappingException.wrapWithPath(cause, prop.getType().getRawClass(), propertyName);
                }
            }
        }
    }
View Full Code Here

            if ((deserializer instanceof BeanDeserializerBase) && (aliasDefaults.get("_primary") != null)) {
                BeanDeserializerBase beanDeserializer = (BeanDeserializerBase) deserializer;
                String primaryField = (String) aliasDefaults.get("_primary").unwrapped();
                if (!fieldValues.has(primaryField)) {
                    // user has not explicitly set a value where _primary points, see if _primary is a plugin type
                    SettableBeanProperty primaryProperty = beanDeserializer.findProperty(primaryField);
                    if ((primaryProperty != null) && primaryProperty.hasValueTypeDeserializer()) {
                        TypeDeserializer primaryTypeDeserializer = primaryProperty.getValueTypeDeserializer();
                        if (primaryTypeDeserializer instanceof CodecTypeDeserializer) {
                            CodecTypeIdResolver primaryPropertyTypeIdResolver =
                                    ((CodecTypeDeserializer) primaryTypeDeserializer).idRes;
                            String possibleInlinedPrimary = null;
                            Iterator<String> fieldNames = fieldValues.fieldNames();
View Full Code Here

      final int bcount = _buckets.length;
        Bucket[] newBuckets = new Bucket[bcount];
        System.arraycopy(_buckets, 0, newBuckets, 0, bcount);
        final String propName = newProperty.getName();
        // and then see if it's add or replace:
      SettableBeanProperty oldProp = find(newProperty.getName());
      if (oldProp == null) { // add
          // first things first: add or replace?
          // can do a straight copy, since all additions are at the front
          // and then insert the new property:
          int index = propName.hashCode() & _hashMask;
View Full Code Here

            return this;
        }
        Iterator<SettableBeanProperty> it = allProperties();
        ArrayList<SettableBeanProperty> newProps = new ArrayList<SettableBeanProperty>();
        while (it.hasNext()) {
            SettableBeanProperty prop = it.next();
            String newName = transformer.transform(prop.getName());
            prop = prop.withName(newName);
            JsonDeserializer<?> deser = prop.getValueDeserializer();
            if (deser != null) {
                @SuppressWarnings("unchecked")
                JsonDeserializer<Object> newDeser = (JsonDeserializer<Object>)
                    deser.unwrappingDeserializer(transformer);
                if (newDeser != deser) {
                    prop = prop.withValueDeserializer(newDeser);
                }
            }
            newProps.add(prop);
        }
        // should we try to re-index? Ordering probably changed but called probably doesn't want changes...
View Full Code Here

TOP

Related Classes of com.fasterxml.jackson.databind.deser.SettableBeanProperty

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.