com.fasterxml.jackson.annotation.JsonUnwrapped Java Examples

The following examples show how to use com.fasterxml.jackson.annotation.JsonUnwrapped. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IstioTypeAnnotator.java    From istio-java-api with Apache License 2.0 6 votes vote down vote up
@Override
public void propertyField(JFieldVar field, JDefinedClass clazz, String propertyName, JsonNode propertyNode) {
    propertyName = propertyName.equals("deprecatedAllowOrigin") ? "allowOrigin" : propertyName;
    super.propertyField(field, clazz, propertyName, propertyNode);
    if (propertyNode.hasNonNull(IS_INTERFACE_FIELD)) {
        field.annotate(JsonUnwrapped.class);

        // todo: fix me, this won't work if a type has several fields using interfaces
        String interfaceFQN = propertyNode.get(EXISTING_JAVA_TYPE_FIELD).asText();

        // create interface if we haven't done it yet
        try {
            final JDefinedClass fieldInterface = clazz._interface(interfaceFQN.substring(interfaceFQN.lastIndexOf('.') + 1));
            fieldInterface._extends(Serializable.class);
        } catch (JClassAlreadyExistsException e) {
            throw new RuntimeException(e);
        }
        annotateIfNotDone(clazz, ClassWithInterfaceFieldsDeserializer.class);
    }
}
 
Example #2
Source File: Attachment.java    From roboslack with Apache License 2.0 5 votes vote down vote up
/**
 * The {@link Color} to display on the sidebar next to the {@link Attachment}.
 *
 * @return an {@link Optional} containing a {@link Color}
 * @see Color
 */
@Value.Default
@Nullable
@JsonUnwrapped
public Color color() {
    return null;
}
 
Example #3
Source File: Attachment.java    From roboslack with Apache License 2.0 5 votes vote down vote up
/**
 * The {@link Author} for this {@link Attachment}. It is displayed in a small grayed-out section at the top
 * before the main {@link Attachment} body.
 *
 * @return an {@link Optional} containing the {@link Author}
 */
@Value.Default
@Nullable
@JsonUnwrapped
public Author author() {
    return null;
}
 
Example #4
Source File: Attachment.java    From roboslack with Apache License 2.0 5 votes vote down vote up
/**
 * The {@link Title} for this {@link Attachment}. It is displayed as larger, bold text near the top before the main
 * {@link Attachment} body.
 *
 * @return an {@link Optional} containing the {@link Title}
 */
@Value.Default
@Nullable
@JsonUnwrapped
public Title title() {
    return null;
}
 
Example #5
Source File: Attachment.java    From roboslack with Apache License 2.0 5 votes vote down vote up
/**
 * The {@link Footer} for this {@link Attachment}. This will appear below the body of the main message
 * {@link Attachment} in smaller, grayed-out text.
 *
 * @return an {@link Optional} containing the {@link Footer}
 */
@Value.Default
@Nullable
@JsonUnwrapped
public Footer footer() {
    return null;
}
 
Example #6
Source File: SchemaPropertyGenerator.java    From rest-schemagen with Apache License 2.0 5 votes vote down vote up
private void addFieldToMap(Field field, ObjectContext objectContext,
                           Map<Field, ObjectContext> fieldContextMap, Set<Type> unwrappedTypes,
                           SchemaPropertyContext context) {
    if (objectContext.isApplicable(field, context)) {
        if (field.getAnnotation(JsonUnwrapped.class) != null) {
            fieldContextMap.putAll(getUnwrappedFieldsMap(field, objectContext, unwrappedTypes,
                    context));
        } else {
            fieldContextMap.put(field, objectContext);
        }
    }
}
 
Example #7
Source File: NestedContentResource.java    From restdocs-wiremock with Apache License 2.0 4 votes vote down vote up
@JsonUnwrapped
public Resources<T> getNested() {
	return this.nested;
}
 
Example #8
Source File: JsonLayout.java    From logging-log4j2 with Apache License 2.0 4 votes vote down vote up
@Override
@JsonUnwrapped
@JsonSerialize(as = LogEvent.class)
public LogEvent getLogEvent() {
    return super.getLogEvent();
}
 
Example #9
Source File: AbstractJacksonLayout.java    From logging-log4j2 with Apache License 2.0 4 votes vote down vote up
@JsonUnwrapped
public Object getLogEvent() {
    return logEvent;
}
 
Example #10
Source File: YamlLayout.java    From logging-log4j2 with Apache License 2.0 4 votes vote down vote up
@Override
@JsonUnwrapped
@JsonSerialize(as = LogEvent.class)
public LogEvent getLogEvent() {
    return super.getLogEvent();
}
 
Example #11
Source File: ScriptProviderDescriptor.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@JsonUnwrapped
@JsonGetter
public Map<String, List<ScriptProviderMetadata>> getProviders() {
    return providers;
}
 
Example #12
Source File: UnconfiguredTargetNodeWithDeps.java    From buck with Apache License 2.0 4 votes vote down vote up
@JsonUnwrapped
UnconfiguredTargetNode getUnconfiguredTargetNode();
 
Example #13
Source File: PropertyProcessor.java    From gwt-jackson with Apache License 2.0 4 votes vote down vote up
private static Optional<PropertyInfo> processProperty( RebindConfiguration configuration, TreeLogger logger, JacksonTypeOracle
        typeOracle, PropertyAccessors propertyAccessors, BeanInfo beanInfo, boolean samePackage ) throws UnableToCompleteException {

    boolean getterAutoDetected = isGetterAutoDetected( configuration, propertyAccessors, beanInfo );
    boolean setterAutoDetected = isSetterAutoDetected( configuration, propertyAccessors, beanInfo );
    boolean fieldAutoDetected = isFieldAutoDetected( configuration, propertyAccessors, beanInfo );

    if ( !getterAutoDetected && !setterAutoDetected && !fieldAutoDetected && !propertyAccessors.getParameter().isPresent() ) {
        // none of the field have been auto-detected, we ignore the field
        return Optional.absent();
    }

    final String propertyName = propertyAccessors.getPropertyName();
    final JType type = findType( logger, propertyAccessors, typeOracle, getterAutoDetected, setterAutoDetected, fieldAutoDetected );

    PropertyInfoBuilder builder = new PropertyInfoBuilder( propertyName, type );

    builder.setIgnored( isPropertyIgnored( configuration, propertyAccessors, beanInfo, type, propertyName ) );
    if ( builder.isIgnored() ) {
        return Optional.of( builder.build() );
    }

    Optional<JsonProperty> jsonProperty = propertyAccessors.getAnnotation( JsonProperty.class );
    builder.setRequired( jsonProperty.isPresent() && jsonProperty.get().required() );

    Optional<JsonManagedReference> jsonManagedReference = propertyAccessors.getAnnotation( JsonManagedReference.class );
    builder.setManagedReference( Optional.fromNullable( jsonManagedReference.isPresent() ? jsonManagedReference.get()
            .value() : null ) );

    Optional<JsonBackReference> jsonBackReference = propertyAccessors.getAnnotation( JsonBackReference.class );
    builder.setBackReference( Optional.fromNullable( jsonBackReference.isPresent() ? jsonBackReference.get().value() : null ) );

    if ( !builder.getBackReference().isPresent() ) {
        determineGetter( propertyAccessors, samePackage, getterAutoDetected, fieldAutoDetected, builder );

        Optional<JsonRawValue> jsonRawValue = propertyAccessors.getAnnotation( JsonRawValue.class );
        builder.setRawValue( jsonRawValue.isPresent() && jsonRawValue.get().value() );
    }
    determineSetter( propertyAccessors, samePackage, setterAutoDetected, fieldAutoDetected, builder );

    Optional<JsonValue> jsonValue = propertyAccessors.getAnnotation( JsonValue.class );
    if ( jsonValue.isPresent() && jsonValue.get().value() && builder.getGetterAccessor().isPresent() && builder.getGetterAccessor()
            .get().getMethod().isPresent() ) {
        builder.setValue( true );
    }

    Optional<JsonAnyGetter> jsonAnyGetter = propertyAccessors.getAnnotation( JsonAnyGetter.class );
    if ( jsonAnyGetter.isPresent() && builder.getGetterAccessor().isPresent() && builder.getGetterAccessor().get().getMethod()
            .isPresent() ) {
        builder.setAnyGetter( true );
    }

    Optional<JsonAnySetter> jsonAnySetter = propertyAccessors.getAnnotation( JsonAnySetter.class );
    if ( jsonAnySetter.isPresent() && builder.getSetterAccessor().isPresent() && builder.getSetterAccessor().get().getMethod()
            .isPresent() && builder.getSetterAccessor().get().getMethod().get().getParameterTypes().length == 2 ) {
        builder.setAnySetter( true );
    }

    Optional<JsonUnwrapped> jsonUnwrapped = propertyAccessors.getAnnotation( JsonUnwrapped.class );
    if ( jsonUnwrapped.isPresent() && jsonUnwrapped.get().enabled() ) {
        builder.setUnwrapped( true );
    }

    processBeanAnnotation( logger, typeOracle, configuration, type, propertyAccessors, builder );

    builder.setFormat( propertyAccessors.getAnnotation( JsonFormat.class ) );

    Optional<JsonInclude> jsonInclude = propertyAccessors.getAnnotation( JsonInclude.class );
    if ( jsonInclude.isPresent() ) {
        builder.setInclude( Optional.of( jsonInclude.get().value() ) );
    } else {
        builder.setInclude( beanInfo.getInclude() );
    }

    Optional<JsonIgnoreProperties> jsonIgnoreProperties = propertyAccessors.getAnnotation( JsonIgnoreProperties.class );
    if ( jsonIgnoreProperties.isPresent() ) {
        builder.setIgnoreUnknown( Optional.of( jsonIgnoreProperties.get().ignoreUnknown() ) );
        if ( null != jsonIgnoreProperties.get().value() && jsonIgnoreProperties.get().value().length > 0 ) {
            builder.setIgnoredProperties( Optional.of( jsonIgnoreProperties.get().value() ) );
        }
    }

    return Optional.of( builder.build() );
}
 
Example #14
Source File: ResourceWithUrl.java    From todo-backend-spring4-java8 with MIT License 4 votes vote down vote up
@JsonUnwrapped
@XmlAnyElement
public T getContent() {
    return content;
}
 
Example #15
Source File: JacksonResponseFieldSnippetTest.java    From spring-auto-restdocs with Apache License 2.0 4 votes vote down vote up
@JsonInclude(NON_EMPTY)
@JsonUnwrapped
public Resources<EmbeddedWrapper> getEmbeddedResources() {
    return new Resources(embedded);
}
 
Example #16
Source File: Departments.java    From weixin-sdk with Apache License 2.0 4 votes vote down vote up
@JsonProperty("department")
@JsonUnwrapped
public List<Department> getDepartments() {
    return departments;
}
 
Example #17
Source File: HateoasResource.java    From moserp with Apache License 2.0 4 votes vote down vote up
@JsonUnwrapped
public T getContent() {
    return content;
}
 
Example #18
Source File: Metric.java    From timely with Apache License 2.0 4 votes vote down vote up
@JsonUnwrapped
public Value getValue() {
    return value;
}
 
Example #19
Source File: UserForm.java    From dremio-oss with Apache License 2.0 4 votes vote down vote up
@JsonUnwrapped
public User getUserConfig() {
  return userConfig;
}
 
Example #20
Source File: BaseUnwrappedModel.java    From sctalk with Apache License 2.0 4 votes vote down vote up
/**
 * @param data the data to set
 */
@JsonUnwrapped
public void setData(T data) {
    this.data = data;
}
 
Example #21
Source File: BaseUnwrappedModel.java    From sctalk with Apache License 2.0 4 votes vote down vote up
/**
 * @return the data
 */
@JsonUnwrapped
public T getData() {
    return data;
}
 
Example #22
Source File: StackdriverJsonLayout.java    From curiostack with MIT License 4 votes vote down vote up
@Override
@JsonUnwrapped
@JsonIgnoreProperties("message")
public Object getLogEvent() {
  return super.getLogEvent();
}
 
Example #23
Source File: SourceSpec.java    From syndesis with Apache License 2.0 4 votes vote down vote up
@JsonUnwrapped
@Nullable
DataSpec getDataSpec();
 
Example #24
Source File: ResourceSpec.java    From syndesis with Apache License 2.0 4 votes vote down vote up
@JsonUnwrapped
@Nullable
DataSpec getDataSpec();