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

The following examples show how to use com.fasterxml.jackson.databind.annotation.JsonSerialize. 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: Results.java    From usergrid with 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 #2
Source File: Results.java    From usergrid with 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 #3
Source File: KubernetesCoreTypeAnnotator.java    From kubernetes-client with 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 #4
Source File: Results.java    From usergrid with 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 #5
Source File: ServiceInstanceLastOperation.java    From spring-boot-cf-service-broker with 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 #6
Source File: Interpretation.java    From dhis2-core with 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 #7
Source File: Map.java    From dhis2-core with 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 #8
Source File: PublicKeyContainer.java    From peer-os with 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 #9
Source File: ReferenceTypeSerializer.java    From lams with 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 #10
Source File: JsonWebKey.java    From azure-keyvault-java with 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 #11
Source File: ProgramStage.java    From dhis2-core with 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 #12
Source File: DashboardItem.java    From dhis2-core with 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 #13
Source File: Program.java    From dhis2-core with 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 #14
Source File: ProgramInstance.java    From dhis2-core with 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 #15
Source File: TrackedEntityInstance.java    From dhis2-core with 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 #16
Source File: MapView.java    From dhis2-core with 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 #17
Source File: ValidationResult.java    From dhis2-core with 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 #18
Source File: Interpretation.java    From dhis2-core with 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 #19
Source File: ProgramStageSection.java    From dhis2-core with 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 #20
Source File: ProgramStage.java    From dhis2-core with 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 #21
Source File: ProgramRuleVariable.java    From dhis2-core with 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 #22
Source File: Interpretation.java    From dhis2-core with 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 #23
Source File: User.java    From dhis2-core with 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 #24
Source File: Message.java    From dhis2-core with 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 #25
Source File: Recipients.java    From dhis2-core with 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 #26
Source File: ProgramStageInstance.java    From dhis2-core with 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 #27
Source File: NodePortTuple.java    From floodlight_with_topoguard with Apache License 2.0 4 votes vote down vote up
@JsonProperty("switch")
@JsonSerialize(using=DPIDSerializer.class)
public long getNodeId() {
    return nodeId;
}
 
Example #28
Source File: Role.java    From usergrid with Apache License 2.0 4 votes vote down vote up
@JsonSerialize(include = Inclusion.NON_NULL)
public List<UUID> getUsers() {
    return users;
}
 
Example #29
Source File: Candidate.java    From sdk-rest with MIT License 4 votes vote down vote up
@JsonProperty("customObject5s")
@JsonSerialize(using = RestOneToManySerializer.class)
@JsonInclude(JsonInclude.Include.NON_NULL)
public OneToMany<PersonCustomObjectInstance5> getCustomObject5s() {
    return customObject5s;
}
 
Example #30
Source File: ClientCorporation.java    From sdk-rest with MIT License 4 votes vote down vote up
@JsonProperty("customObject2s")
@JsonSerialize(using = RestOneToManySerializer.class)
@JsonInclude(JsonInclude.Include.NON_NULL)
public OneToMany<ClientCorporationCustomObjectInstance2> getCustomObject2s() {
    return customObject2s;
}