Search in sources :

Example 21 with JsonProperty

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonProperty in project hono by eclipse.

the class TrustedCertificateAuthority method setCertificate.

/**
 * Sets the trusted certificate authority.
 *
 * @param certificate The DER encoded X.509 certificate.
 * @return A reference to this for fluent use.
 * @throws CertificateException if the byte array cannot be deserialized into an X.509 certificate.
 */
@JsonProperty(TenantConstants.FIELD_PAYLOAD_CERT)
public final TrustedCertificateAuthority setCertificate(final byte[] certificate) throws CertificateException {
    final CertificateFactory factory = CertificateFactory.getInstance("X.509");
    cert = (X509Certificate) factory.generateCertificate(new ByteArrayInputStream(certificate));
    return this;
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) CertificateFactory(java.security.cert.CertificateFactory) JsonProperty(com.fasterxml.jackson.annotation.JsonProperty)

Example 22 with JsonProperty

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonProperty in project knime-core by knime.

the class SubnodeContainerExecutionResult method setWorkflowExecutionResult.

/**
 * Sets inner execution result.
 * @param workflowExecutionResult To be set, must have correct baseID.
 * @throws IllegalArgumentException If the id prefix is invalid or argument is null
 */
@JsonProperty("workflowExecResult")
public void setWorkflowExecutionResult(final WorkflowExecutionResult workflowExecutionResult) {
    m_workflowExecutionResult = CheckUtils.checkArgumentNotNull(workflowExecutionResult, "Arg must not be null");
    CheckUtils.checkArgument(new NodeID(m_baseID, 0).equals(m_workflowExecutionResult.getBaseID()), "Unexpected ID of inner wfm result, expected %s but got %s", new NodeID(m_baseID, 0), m_workflowExecutionResult.getBaseID());
    m_workflowExecutionResult = workflowExecutionResult;
}
Also used : NodeID(org.knime.core.node.workflow.NodeID) JsonProperty(com.fasterxml.jackson.annotation.JsonProperty)

Example 23 with JsonProperty

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonProperty in project POL-POM-5 by PhoenicisOrg.

the class LocalisationHelper method fetchParameterName.

private String fetchParameterName(Parameter parameter) {
    final JsonProperty jsonAnnotation = parameter.getAnnotation(JsonProperty.class);
    final ParameterName parameterNameAnnotation = parameter.getAnnotation(ParameterName.class);
    if (parameterNameAnnotation != null) {
        return parameterNameAnnotation.value();
    }
    if (jsonAnnotation != null) {
        return jsonAnnotation.value();
    }
    return parameter.getName();
}
Also used : JsonProperty(com.fasterxml.jackson.annotation.JsonProperty)

Example 24 with JsonProperty

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonProperty in project autorest-clientruntime-for-java by Azure.

the class AdditionalPropertiesDeserializer method getModule.

/**
 * Gets a module wrapping this serializer as an adapter for the Jackson
 * ObjectMapper.
 *
 * @param mapper the object mapper for default deserializations
 * @return a simple module to be plugged onto Jackson ObjectMapper.
 */
public static SimpleModule getModule(final ObjectMapper mapper) {
    SimpleModule module = new SimpleModule();
    module.setDeserializerModifier(new BeanDeserializerModifier() {

        @Override
        public JsonDeserializer<?> modifyDeserializer(DeserializationConfig config, BeanDescription beanDesc, JsonDeserializer<?> deserializer) {
            for (Class<?> c : TypeToken.of(beanDesc.getBeanClass()).getTypes().classes().rawTypes()) {
                Field[] fields = c.getDeclaredFields();
                for (Field field : fields) {
                    if ("additionalProperties".equalsIgnoreCase(field.getName())) {
                        JsonProperty property = field.getAnnotation(JsonProperty.class);
                        if (property != null && property.value().isEmpty()) {
                            return new AdditionalPropertiesDeserializer(beanDesc.getBeanClass(), deserializer, mapper);
                        }
                    }
                }
            }
            return deserializer;
        }
    });
    return module;
}
Also used : BeanDeserializerModifier(com.fasterxml.jackson.databind.deser.BeanDeserializerModifier) Field(java.lang.reflect.Field) JsonProperty(com.fasterxml.jackson.annotation.JsonProperty) BeanDescription(com.fasterxml.jackson.databind.BeanDescription) DeserializationConfig(com.fasterxml.jackson.databind.DeserializationConfig) JsonDeserializer(com.fasterxml.jackson.databind.JsonDeserializer) SimpleModule(com.fasterxml.jackson.databind.module.SimpleModule)

Example 25 with JsonProperty

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonProperty in project autorest-clientruntime-for-java by Azure.

the class FlatteningDeserializer method handleFlatteningForField.

/**
 * Given a field of a POJO class and JsonNode corresponds to the same POJO class,
 * check field's {@link JsonProperty} has flattening dots in it if so
 * flatten the nested child JsonNode corresponds to the field in the given JsonNode.
 *
 * @param classField the field in a POJO class
 * @param jsonNode the json node corresponds to POJO class that field belongs to
 */
@SuppressWarnings("unchecked")
private static void handleFlatteningForField(Field classField, JsonNode jsonNode) {
    final JsonProperty jsonProperty = classField.getAnnotation(JsonProperty.class);
    if (jsonProperty != null) {
        final String jsonPropValue = jsonProperty.value();
        if (jsonNode.has(jsonPropValue)) {
            // There is an additional property with it's key conflicting with the
            // JsonProperty value, escape this additional property's key.
            final String escapedJsonPropValue = jsonPropValue.replace(".", "\\.");
            ((ObjectNode) jsonNode).set(escapedJsonPropValue, jsonNode.get(jsonPropValue));
        }
        if (containsFlatteningDots(jsonPropValue)) {
            // The jsonProperty value contains flattening dots, uplift the nested
            // json node that this value resolving to the current level.
            JsonNode childJsonNode = findNestedNode(jsonNode, jsonPropValue);
            ((ObjectNode) jsonNode).set(jsonPropValue, childJsonNode);
        }
    }
}
Also used : JsonProperty(com.fasterxml.jackson.annotation.JsonProperty) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Aggregations

JsonProperty (com.fasterxml.jackson.annotation.JsonProperty)45 Field (java.lang.reflect.Field)12 ArrayList (java.util.ArrayList)10 Annotation (java.lang.annotation.Annotation)8 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)6 NamedType (com.fasterxml.jackson.databind.jsontype.NamedType)6 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)6 Method (java.lang.reflect.Method)6 Type (java.lang.reflect.Type)6 BeanDescription (com.fasterxml.jackson.databind.BeanDescription)5 JsonNode (com.fasterxml.jackson.databind.JsonNode)5 HashMap (java.util.HashMap)5 Map (java.util.Map)5 JsonCreator (com.fasterxml.jackson.annotation.JsonCreator)4 JavaType (com.fasterxml.jackson.databind.JavaType)4 AnnotatedClass (com.fasterxml.jackson.databind.introspect.AnnotatedClass)4 JsonSchema (com.fasterxml.jackson.module.jsonSchema.JsonSchema)4 JsonSchemaGenerator (com.fasterxml.jackson.module.jsonSchema.JsonSchemaGenerator)4 List (java.util.List)4 JsonIdentityInfo (com.fasterxml.jackson.annotation.JsonIdentityInfo)3