moved common Json annotations out into an interface

This commit is contained in:
Ken Stevens 2020-03-12 13:36:34 -04:00
parent 9f725892d3
commit ecf5284c87
10 changed files with 24 additions and 49 deletions

View File

@ -0,0 +1,9 @@
package ca.uhn.fhir.model.api;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonInclude;
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonAutoDetect(creatorVisibility = JsonAutoDetect.Visibility.NONE, fieldVisibility = JsonAutoDetect.Visibility.NONE, getterVisibility = JsonAutoDetect.Visibility.NONE, isGetterVisibility = JsonAutoDetect.Visibility.NONE, setterVisibility = JsonAutoDetect.Visibility.NONE)
public interface IModelJson {
}

View File

@ -22,8 +22,7 @@ package ca.uhn.fhir.jpa.binstore;
import ca.uhn.fhir.jpa.util.JsonDateDeserializer; import ca.uhn.fhir.jpa.util.JsonDateDeserializer;
import ca.uhn.fhir.jpa.util.JsonDateSerializer; import ca.uhn.fhir.jpa.util.JsonDateSerializer;
import com.fasterxml.jackson.annotation.JsonAutoDetect; import ca.uhn.fhir.model.api.IModelJson;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize;
@ -33,9 +32,7 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import java.util.Date; import java.util.Date;
@JsonInclude(JsonInclude.Include.NON_NULL) public class StoredDetails implements IModelJson {
@JsonAutoDetect(creatorVisibility = JsonAutoDetect.Visibility.NONE, fieldVisibility = JsonAutoDetect.Visibility.NONE, getterVisibility = JsonAutoDetect.Visibility.NONE, isGetterVisibility = JsonAutoDetect.Visibility.NONE, setterVisibility = JsonAutoDetect.Visibility.NONE)
public class StoredDetails {
@JsonProperty("blobId") @JsonProperty("blobId")
private String myBlobId; private String myBlobId;

View File

@ -23,6 +23,7 @@ package ca.uhn.fhir.jpa.bulk;
import ca.uhn.fhir.jpa.util.JsonDateDeserializer; import ca.uhn.fhir.jpa.util.JsonDateDeserializer;
import ca.uhn.fhir.jpa.util.JsonDateSerializer; import ca.uhn.fhir.jpa.util.JsonDateSerializer;
import ca.uhn.fhir.model.api.IModelJson;
import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
@ -98,9 +99,7 @@ public class BulkExportResponseJson {
return retVal; return retVal;
} }
@JsonInclude(JsonInclude.Include.NON_NULL) public static class Output implements IModelJson {
@JsonAutoDetect(creatorVisibility = JsonAutoDetect.Visibility.NONE, fieldVisibility = JsonAutoDetect.Visibility.NONE, getterVisibility = JsonAutoDetect.Visibility.NONE, isGetterVisibility = JsonAutoDetect.Visibility.NONE, setterVisibility = JsonAutoDetect.Visibility.NONE)
public static class Output {
@JsonProperty("type") @JsonProperty("type")
private String myType; private String myType;

View File

@ -21,8 +21,7 @@ package ca.uhn.fhir.jpa.subscription.module;
*/ */
import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirContext;
import com.fasterxml.jackson.annotation.JsonAutoDetect; import ca.uhn.fhir.model.api.IModelJson;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder;
@ -39,9 +38,7 @@ import java.util.*;
import static org.apache.commons.lang3.StringUtils.isNotBlank; import static org.apache.commons.lang3.StringUtils.isNotBlank;
@JsonInclude(JsonInclude.Include.NON_NULL) public class CanonicalSubscription implements Serializable, Cloneable, IModelJson {
@JsonAutoDetect(creatorVisibility = JsonAutoDetect.Visibility.NONE, fieldVisibility = JsonAutoDetect.Visibility.NONE, getterVisibility = JsonAutoDetect.Visibility.NONE, isGetterVisibility = JsonAutoDetect.Visibility.NONE, setterVisibility = JsonAutoDetect.Visibility.NONE)
public class CanonicalSubscription implements Serializable, Cloneable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ -279,9 +276,7 @@ public class CanonicalSubscription implements Serializable, Cloneable {
} }
} }
@JsonInclude(JsonInclude.Include.NON_NULL) public static class EmailDetails implements IModelJson {
@JsonAutoDetect(creatorVisibility = JsonAutoDetect.Visibility.NONE, fieldVisibility = JsonAutoDetect.Visibility.NONE, getterVisibility = JsonAutoDetect.Visibility.NONE, isGetterVisibility = JsonAutoDetect.Visibility.NONE, setterVisibility = JsonAutoDetect.Visibility.NONE)
public static class EmailDetails {
@JsonProperty("from") @JsonProperty("from")
private String myFrom; private String myFrom;
@ -334,9 +329,7 @@ public class CanonicalSubscription implements Serializable, Cloneable {
} }
} }
@JsonInclude(JsonInclude.Include.NON_NULL) public static class RestHookDetails implements IModelJson {
@JsonAutoDetect(creatorVisibility = JsonAutoDetect.Visibility.NONE, fieldVisibility = JsonAutoDetect.Visibility.NONE, getterVisibility = JsonAutoDetect.Visibility.NONE, isGetterVisibility = JsonAutoDetect.Visibility.NONE, setterVisibility = JsonAutoDetect.Visibility.NONE)
public static class RestHookDetails {
@JsonProperty("stripVersionId") @JsonProperty("stripVersionId")
private boolean myStripVersionId; private boolean myStripVersionId;
@ -391,9 +384,7 @@ public class CanonicalSubscription implements Serializable, Cloneable {
} }
@JsonInclude(JsonInclude.Include.NON_NULL) public static class CanonicalEventDefinition implements IModelJson {
@JsonAutoDetect(creatorVisibility = JsonAutoDetect.Visibility.NONE, fieldVisibility = JsonAutoDetect.Visibility.NONE, getterVisibility = JsonAutoDetect.Visibility.NONE, isGetterVisibility = JsonAutoDetect.Visibility.NONE, setterVisibility = JsonAutoDetect.Visibility.NONE)
public static class CanonicalEventDefinition {
/** /**
* Constructor * Constructor

View File

@ -23,10 +23,9 @@ package ca.uhn.fhir.jpa.subscription.module;
import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.jpa.subscription.module.subscriber.BaseResourceMessage; import ca.uhn.fhir.jpa.subscription.module.subscriber.BaseResourceMessage;
import ca.uhn.fhir.jpa.subscription.module.subscriber.IResourceMessage; import ca.uhn.fhir.jpa.subscription.module.subscriber.IResourceMessage;
import ca.uhn.fhir.model.api.IModelJson;
import ca.uhn.fhir.util.ResourceReferenceInfo; import ca.uhn.fhir.util.ResourceReferenceInfo;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IBaseResource;
@ -37,9 +36,7 @@ import java.util.List;
import static org.apache.commons.lang3.StringUtils.isBlank; import static org.apache.commons.lang3.StringUtils.isBlank;
import static org.apache.commons.lang3.StringUtils.isNotBlank; import static org.apache.commons.lang3.StringUtils.isNotBlank;
@JsonInclude(JsonInclude.Include.NON_NULL) public class ResourceModifiedMessage extends BaseResourceMessage implements IResourceMessage, IModelJson {
@JsonAutoDetect(creatorVisibility = JsonAutoDetect.Visibility.NONE, fieldVisibility = JsonAutoDetect.Visibility.NONE, getterVisibility = JsonAutoDetect.Visibility.NONE, isGetterVisibility = JsonAutoDetect.Visibility.NONE, setterVisibility = JsonAutoDetect.Visibility.NONE)
public class ResourceModifiedMessage extends BaseResourceMessage implements IResourceMessage {
@JsonProperty("resourceId") @JsonProperty("resourceId")
private String myId; private String myId;

View File

@ -20,15 +20,12 @@ package ca.uhn.fhir.jpa.subscription.module.subscriber;
* #L% * #L%
*/ */
import com.fasterxml.jackson.annotation.JsonAutoDetect; import ca.uhn.fhir.model.api.IModelJson;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import org.springframework.messaging.Message; import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHeaders; import org.springframework.messaging.MessageHeaders;
@JsonInclude(JsonInclude.Include.NON_NULL) public abstract class BaseJsonMessage<T> implements Message<T>, IModelJson {
@JsonAutoDetect(creatorVisibility = JsonAutoDetect.Visibility.NONE, fieldVisibility = JsonAutoDetect.Visibility.NONE, getterVisibility = JsonAutoDetect.Visibility.NONE, isGetterVisibility = JsonAutoDetect.Visibility.NONE, setterVisibility = JsonAutoDetect.Visibility.NONE)
public abstract class BaseJsonMessage<T> implements Message<T> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@JsonProperty("headers") @JsonProperty("headers")

View File

@ -20,8 +20,7 @@ package ca.uhn.fhir.jpa.subscription.module.subscriber;
* #L% * #L%
*/ */
import com.fasterxml.jackson.annotation.JsonAutoDetect; import ca.uhn.fhir.model.api.IModelJson;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.commons.lang3.Validate; import org.apache.commons.lang3.Validate;
@ -30,9 +29,7 @@ import java.util.Map;
import java.util.Optional; import java.util.Optional;
@SuppressWarnings("WeakerAccess") @SuppressWarnings("WeakerAccess")
@JsonInclude(JsonInclude.Include.NON_NULL) public abstract class BaseResourceMessage implements IResourceMessage, IModelJson {
@JsonAutoDetect(creatorVisibility = JsonAutoDetect.Visibility.NONE, fieldVisibility = JsonAutoDetect.Visibility.NONE, getterVisibility = JsonAutoDetect.Visibility.NONE, isGetterVisibility = JsonAutoDetect.Visibility.NONE, setterVisibility = JsonAutoDetect.Visibility.NONE)
public abstract class BaseResourceMessage implements IResourceMessage {
@JsonProperty("attributes") @JsonProperty("attributes")
private Map<String, String> myAttributes; private Map<String, String> myAttributes;

View File

@ -20,13 +20,9 @@ package ca.uhn.fhir.jpa.subscription.module.subscriber;
* #L% * #L%
*/ */
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonAutoDetect(creatorVisibility = JsonAutoDetect.Visibility.NONE, fieldVisibility = JsonAutoDetect.Visibility.NONE, getterVisibility = JsonAutoDetect.Visibility.NONE, isGetterVisibility = JsonAutoDetect.Visibility.NONE, setterVisibility = JsonAutoDetect.Visibility.NONE)
public class ResourceDeliveryJsonMessage extends BaseJsonMessage<ResourceDeliveryMessage> { public class ResourceDeliveryJsonMessage extends BaseJsonMessage<ResourceDeliveryMessage> {
@JsonProperty("payload") @JsonProperty("payload")

View File

@ -24,9 +24,7 @@ import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.jpa.subscription.module.CanonicalSubscription; import ca.uhn.fhir.jpa.subscription.module.CanonicalSubscription;
import ca.uhn.fhir.jpa.subscription.module.ResourceModifiedMessage; import ca.uhn.fhir.jpa.subscription.module.ResourceModifiedMessage;
import ca.uhn.fhir.rest.api.EncodingEnum; import ca.uhn.fhir.rest.api.EncodingEnum;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IBaseResource;
@ -35,8 +33,6 @@ import org.hl7.fhir.instance.model.api.IIdType;
import static org.apache.commons.lang3.StringUtils.isNotBlank; import static org.apache.commons.lang3.StringUtils.isNotBlank;
@SuppressWarnings("WeakerAccess") @SuppressWarnings("WeakerAccess")
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonAutoDetect(creatorVisibility = JsonAutoDetect.Visibility.NONE, fieldVisibility = JsonAutoDetect.Visibility.NONE, getterVisibility = JsonAutoDetect.Visibility.NONE, isGetterVisibility = JsonAutoDetect.Visibility.NONE, setterVisibility = JsonAutoDetect.Visibility.NONE)
public class ResourceDeliveryMessage extends BaseResourceMessage implements IResourceMessage { public class ResourceDeliveryMessage extends BaseResourceMessage implements IResourceMessage {
@JsonProperty("canonicalSubscription") @JsonProperty("canonicalSubscription")

View File

@ -21,13 +21,9 @@ package ca.uhn.fhir.jpa.subscription.module.subscriber;
*/ */
import ca.uhn.fhir.jpa.subscription.module.ResourceModifiedMessage; import ca.uhn.fhir.jpa.subscription.module.ResourceModifiedMessage;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonAutoDetect(creatorVisibility = JsonAutoDetect.Visibility.NONE, fieldVisibility = JsonAutoDetect.Visibility.NONE, getterVisibility = JsonAutoDetect.Visibility.NONE, isGetterVisibility = JsonAutoDetect.Visibility.NONE, setterVisibility = JsonAutoDetect.Visibility.NONE)
public class ResourceModifiedJsonMessage extends BaseJsonMessage<ResourceModifiedMessage> { public class ResourceModifiedJsonMessage extends BaseJsonMessage<ResourceModifiedMessage> {
@JsonProperty("payload") @JsonProperty("payload")