Java Code Examples for com.fasterxml.jackson.databind.annotation.JsonSerialize

The following examples show how to use com.fasterxml.jackson.databind.annotation.JsonSerialize. These examples are extracted from open source projects. 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 Project: usergrid   Author: apache   File: Results.java    License: Apache License 2.0 6 votes vote down vote up
@JsonSerialize(include = Inclusion.NON_NULL)
public String getObjectName() {
    if ( dataName != null ) {
        return dataName;
    }
    if ( entities != null ) {
        return "entities";
    }
    if ( ids != null ) {
        return "ids";
    }
    if ( entity != null ) {
        return "entity";
    }
    if ( id != null ) {
        return "id";
    }
    return null;
}
 
Example #2
Source Project: spring-boot-cf-service-broker   Author: cloudfoundry-community   File: ServiceInstanceLastOperation.java    License: Apache License 2.0 6 votes vote down vote up
@JsonSerialize
private void setState(String state) { 
	switch(state) { 
	case "in progress": 
		this.state = OperationState.IN_PROGRESS;
		break;
	case "succeeded": 
		this.state = OperationState.SUCCEEDED; 
		break; 
	case "failed":
		this.state = OperationState.FAILED;
		break; 
	default:
		assert(false);
		break;
	}
}
 
Example #3
Source Project: usergrid   Author: apache   File: Results.java    License: Apache License 2.0 6 votes vote down vote up
@JsonSerialize(include = Inclusion.NON_NULL)
public UUID getId() {
    if ( id != null ) {
        return id;
    }
    if ( entity != null ) {
        id = entity.getUuid();
        return id;
    }
    if ( ( ids != null ) && ( ids.size() > 0 ) ) {
        id = ids.get( 0 );
        return id;
    }
    if ( ( entities != null ) && ( entities.size() > 0 ) ) {
        entity = entities.get( 0 );
        id = entity.getUuid();
        return id;
    }
    if ( ( refs != null ) && ( refs.size() > 0 ) ) {
        EntityRef ref = refs.get( 0 );
        id = ref.getUuid();
    }
    return id;
}
 
Example #4
Source Project: usergrid   Author: apache   File: Results.java    License: Apache License 2.0 6 votes vote down vote up
@JsonSerialize(include = Inclusion.NON_NULL)
public List<Entity> getEntities() {
    mergeEntitiesWithMetadata();
    if ( entities != null ) {
        return entities;
    }
    /*
     * if (connectionTypeAndEntityTypeToEntityMap != null) { entities = new
     * ArrayList<Entity>(); Map<UUID, Entity> eMap = new LinkedHashMap<UUID,
     * Entity>(); for (String ctype :
     * connectionTypeAndEntityTypeToEntityMap.keySet()) { Map<String,
     * List<Entity>> m = connectionTypeAndEntityTypeToEntityMap .get(ctype);
     * for (String etype : m.keySet()) { List<Entity> l = m.get(etype); for
     * (Entity e : l) { if (!eMap.containsKey(e.getUuid())) { entities.add(e);
     * eMap.put(e.getUuid(), e); } } } } return entities; }
     */
    if ( entity != null ) {
        entities = new ArrayList<Entity>();
        entities.add( entity );
        return entities;
    }
    return new ArrayList<Entity>();
}
 
Example #5
Source Project: kubernetes-client   Author: fabric8io   File: KubernetesCoreTypeAnnotator.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void propertyInclusion(JDefinedClass clazz, JsonNode schema) {
  if (moduleName == null) {
    moduleName = schema.get("$module").textValue();
  }

  if (schema.has("serializer")) {
    annotateSerde(clazz, JsonSerialize.class, schema.get("serializer").asText());
  }

  if (schema.has("deserializer")) {
    annotateSerde(clazz, JsonDeserialize.class, schema.get("deserializer").asText());
  } else {
    clazz.annotate(JsonDeserialize.class).param("using", JsonDeserializer.None.class);
  }

  super.propertyInclusion(clazz, schema);
}
 
Example #6
Source Project: dhis2-core   Author: dhis2   File: Message.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@JsonProperty
@JsonSerialize( as = BaseIdentifiableObject.class )
@JacksonXmlProperty
public User getSender()
{
    return sender;
}
 
Example #7
Source Project: dhis2-core   Author: dhis2   File: Interpretation.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@JsonProperty
@JsonSerialize( as = BaseIdentifiableObject.class )
@JacksonXmlProperty( namespace = DXF_2_0 )
public OrganisationUnit getOrganisationUnit()
{
    return organisationUnit;
}
 
Example #8
Source Project: dhis2-core   Author: dhis2   File: ProgramRuleVariable.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@JsonProperty
@JsonSerialize( as = BaseIdentifiableObject.class )
@JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
public Program getProgram()
{
    return program;
}
 
Example #9
Source Project: dhis2-core   Author: dhis2   File: ProgramStageSection.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@JsonProperty
@JsonSerialize( contentAs = BaseIdentifiableObject.class )
@JacksonXmlElementWrapper( localName = "dataElements", namespace = DxfNamespaces.DXF_2_0 )
@JacksonXmlProperty( localName = "dataElement", namespace = DxfNamespaces.DXF_2_0 )
public List<DataElement> getDataElements()
{
    return dataElements;
}
 
Example #10
Source Project: dhis2-core   Author: dhis2   File: Interpretation.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@JsonProperty
@JsonSerialize( as = BaseIdentifiableObject.class )
@JacksonXmlProperty( namespace = DXF_2_0 )
public Visualization getVisualization()
{
    return visualization;
}
 
Example #11
Source Project: dhis2-core   Author: dhis2   File: MapView.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@JsonProperty
@JsonSerialize( as = BaseIdentifiableObject.class )
@JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
public OrganisationUnitGroupSet getOrganisationUnitGroupSet()
{
    return organisationUnitGroupSet;
}
 
Example #12
Source Project: dhis2-core   Author: dhis2   File: TrackedEntityInstance.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@JsonProperty
@JsonSerialize( as = BaseIdentifiableObject.class )
@JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
public OrganisationUnit getOrganisationUnit()
{
    return organisationUnit;
}
 
Example #13
Source Project: dhis2-core   Author: dhis2   File: ProgramInstance.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@JsonProperty
@JsonSerialize( as = BaseIdentifiableObject.class )
@JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
public Program getProgram()
{
    return program;
}
 
Example #14
Source Project: dhis2-core   Author: dhis2   File: Program.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@JsonProperty( "programStages" )
@JsonSerialize( contentAs = BaseIdentifiableObject.class )
@JacksonXmlElementWrapper( localName = "programStages", namespace = DxfNamespaces.DXF_2_0 )
@JacksonXmlProperty( localName = "programStage", namespace = DxfNamespaces.DXF_2_0 )
public Set<ProgramStage> getProgramStages()
{
    return programStages;
}
 
Example #15
Source Project: dhis2-core   Author: dhis2   File: Recipients.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@JsonProperty
@JsonSerialize( contentAs = BaseIdentifiableObject.class )
@JacksonXmlElementWrapper( localName = "organisationUnits", namespace = DxfNamespaces.DXF_2_0 )
@JacksonXmlProperty( localName = "organisationUnit", namespace = DxfNamespaces.DXF_2_0 )
public Set<OrganisationUnit> getOrganisationUnits()
{
    return organisationUnits;
}
 
Example #16
Source Project: dhis2-core   Author: dhis2   File: User.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@JsonProperty
@JsonSerialize( contentAs = BaseIdentifiableObject.class )
@JacksonXmlElementWrapper( localName = "organisationUnits", namespace = DxfNamespaces.DXF_2_0 )
@JacksonXmlProperty( localName = "organisationUnit", namespace = DxfNamespaces.DXF_2_0 )
public Set<OrganisationUnit> getOrganisationUnits()
{
    return organisationUnits;
}
 
Example #17
Source Project: lams   Author: lamsfoundation   File: ReferenceTypeSerializer.java    License: GNU General Public License v2.0 5 votes vote down vote up
protected boolean _useStatic(SerializerProvider provider, BeanProperty property,
        JavaType referredType)
{
    // First: no serializer for `Object.class`, must be dynamic
    if (referredType.isJavaLangObject()) {
        return false;
    }
    // but if type is final, might as well fetch
    if (referredType.isFinal()) { // or should we allow annotation override? (only if requested...)
        return true;
    }
    // also: if indicated by typing, should be considered static
    if (referredType.useStaticType()) {
        return true;
    }
    // if neither, maybe explicit annotation?
    AnnotationIntrospector intr = provider.getAnnotationIntrospector();
    if ((intr != null) && (property != null)) {
        Annotated ann = property.getMember();
        if (ann != null) {
            JsonSerialize.Typing t = intr.findSerializationTyping(property.getMember());
            if (t == JsonSerialize.Typing.STATIC) {
                return true;
            }
            if (t == JsonSerialize.Typing.DYNAMIC) {
                return false;
            }
        }
    }
    // and finally, may be forced by global static typing (unlikely...)
    return provider.isEnabled(MapperFeature.USE_STATIC_TYPING);
}
 
Example #18
Source Project: dhis2-core   Author: dhis2   File: ProgramStageInstance.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@JsonProperty
@JsonSerialize( contentAs = BaseIdentifiableObject.class )
@JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
public List<TrackedEntityComment> getComments()
{
    return comments;
}
 
Example #19
Source Project: dhis2-core   Author: dhis2   File: ProgramStage.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@JsonProperty( "programStageSections" )
@JsonSerialize( contentAs = BaseIdentifiableObject.class )
@JacksonXmlElementWrapper( localName = "programStageSections", namespace = DxfNamespaces.DXF_2_0 )
@JacksonXmlProperty( localName = "programStageSection", namespace = DxfNamespaces.DXF_2_0 )
public Set<ProgramStageSection> getProgramStageSections()
{
    return programStageSections;
}
 
Example #20
Source Project: azure-keyvault-java   Author: Azure   File: JsonWebKey.java    License: MIT License 5 votes vote down vote up
/**
 * Get the n value.
 *
 * @return the n value
 */
@JsonProperty("n")
@JsonSerialize(using = Base64UrlJsonSerializer.class)
@JsonDeserialize(using = Base64UrlJsonDeserializer.class)
public byte[] n() {
    return this.n;
}
 
Example #21
Source Project: dhis2-core   Author: dhis2   File: Map.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@JsonProperty
@JsonSerialize( contentAs = BaseIdentifiableObject.class )
@JacksonXmlElementWrapper( localName = "interpretations", namespace = DxfNamespaces.DXF_2_0 )
@JacksonXmlProperty( localName = "interpretation", namespace = DxfNamespaces.DXF_2_0 )
public Set<Interpretation> getInterpretations()
{
    return interpretations;
}
 
Example #22
Source Project: peer-os   Author: subutai-io   File: PublicKeyContainer.java    License: Apache License 2.0 5 votes vote down vote up
public PublicKeyContainer( @JsonProperty( "hostId" ) final String hostId,
                           @JsonSerialize( using = ByteArraySerializer.class ) @JsonProperty( "fingerprint" )
                           final byte[] fingerprint, @JsonProperty( "key" ) final String key )
{
    this.hostId = hostId;
    this.fingerprint = fingerprint;
    this.key = key;
}
 
Example #23
Source Project: dhis2-core   Author: dhis2   File: ProgramStage.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@JsonProperty( "notificationTemplates" )
@JsonSerialize( contentAs = BaseIdentifiableObject.class )
@JacksonXmlElementWrapper( localName = "notificationTemplates", namespace = DxfNamespaces.DXF_2_0 )
@JacksonXmlProperty( localName = "notificationTemplate", namespace = DxfNamespaces.DXF_2_0 )
public Set<ProgramNotificationTemplate> getNotificationTemplates()
{
    return notificationTemplates;
}
 
Example #24
Source Project: dhis2-core   Author: dhis2   File: DashboardItem.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@JsonProperty
@JsonSerialize( as = BaseIdentifiableObject.class )
@JacksonXmlProperty( namespace = DXF_2_0 )
public Map getMap()
{
    return map;
}
 
Example #25
Source Project: dhis2-core   Author: dhis2   File: ValidationResult.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@JsonProperty
@JsonSerialize( as = BaseIdentifiableObject.class )
@JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 )
public OrganisationUnit getOrganisationUnit()
{
    return organisationUnit;
}
 
Example #26
Source Project: dhis2-core   Author: dhis2   File: Interpretation.java    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@JsonProperty
@JsonSerialize( as = BaseIdentifiableObject.class )
@JacksonXmlProperty( namespace = DXF_2_0 )
public int getLikes()
{
    return likes;
}
 
Example #27
Source Project: usergrid   Author: apache   File: ApiResponse.java    License: Apache License 2.0 4 votes vote down vote up
@JsonSerialize( include = Inclusion.NON_NULL )
public String getUri() {
    return uri;
}
 
Example #28
Source Project: sdk-rest   Author: bullhorn   File: ClientCorporation.java    License: MIT License 4 votes vote down vote up
@JsonProperty("customObject12s")
@JsonSerialize(using = RestOneToManySerializer.class)
@JsonInclude(JsonInclude.Include.NON_NULL)
public OneToMany<ClientCorporationCustomObjectInstance12> getCustomObject12s() {
    return customObject12s;
}
 
Example #29
Source Project: james-project   Author: apache   File: SetMessagesError.java    License: Apache License 2.0 4 votes vote down vote up
@JsonSerialize
public List<BlobId> getAttachmentsNotFound() {
    return attachmentsNotFound;
}
 
Example #30
Source Project: usergrid   Author: apache   File: CredentialsInfo.java    License: Apache License 2.0 4 votes vote down vote up
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
public String getCipher() {
    return cipher;
}