#1038 - Update documentation and testing for ALPS.
Also make the ALPS types support deserialization using @JsonCreator-based private constructor calls.
This commit is contained in:
@@ -24,7 +24,9 @@ import org.springframework.hateoas.mediatype.alps.Descriptor.DescriptorBuilder;
|
||||
import org.springframework.hateoas.mediatype.alps.Doc.DocBuilder;
|
||||
import org.springframework.hateoas.mediatype.alps.Ext.ExtBuilder;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
|
||||
/**
|
||||
@@ -38,14 +40,23 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
*/
|
||||
@Value
|
||||
@Builder(builderMethodName = "alps")
|
||||
@JsonPropertyOrder({"version", "doc", "descriptor"})
|
||||
@JsonPropertyOrder({ "version", "doc", "descriptor" })
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class Alps {
|
||||
|
||||
private final String version = "1.0";
|
||||
private final String version;
|
||||
private final Doc doc;
|
||||
private final List<Descriptor> descriptor;
|
||||
|
||||
@JsonCreator
|
||||
private Alps(@JsonProperty("version") String version, @JsonProperty("doc") Doc doc,
|
||||
@JsonProperty("descriptor") List<Descriptor> descriptor) {
|
||||
|
||||
this.version = "1.0";
|
||||
this.doc = doc;
|
||||
this.descriptor = descriptor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a new {@link DescriptorBuilder}.
|
||||
*
|
||||
|
||||
@@ -20,7 +20,9 @@ import lombok.Value;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
|
||||
/**
|
||||
@@ -33,14 +35,32 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
*/
|
||||
@Value
|
||||
@Builder
|
||||
@JsonPropertyOrder({"id", "href", "name", "type", "doc", "descriptor", "ext"})
|
||||
@JsonPropertyOrder({ "id", "href", "name", "type", "doc", "descriptor", "ext" })
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class Descriptor {
|
||||
|
||||
private final String id, href, name;
|
||||
private final String id;
|
||||
private final String href;
|
||||
private final String name;
|
||||
private final Doc doc;
|
||||
private final Type type;
|
||||
private final Ext ext;
|
||||
private final String rt;
|
||||
private final List<Descriptor> descriptor;
|
||||
|
||||
@JsonCreator
|
||||
private Descriptor(@JsonProperty("id") String id, @JsonProperty("href") String href,
|
||||
@JsonProperty("name") String name, @JsonProperty("doc") Doc doc, @JsonProperty("type") Type type,
|
||||
@JsonProperty("ext") Ext ext, @JsonProperty("rt") String rt,
|
||||
@JsonProperty("descriptor") List<Descriptor> descriptor) {
|
||||
|
||||
this.id = id;
|
||||
this.href = href;
|
||||
this.name = name;
|
||||
this.doc = doc;
|
||||
this.type = type;
|
||||
this.ext = ext;
|
||||
this.rt = rt;
|
||||
this.descriptor = descriptor;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,13 +15,14 @@
|
||||
*/
|
||||
package org.springframework.hateoas.mediatype.alps;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Value;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
|
||||
/**
|
||||
@@ -34,12 +35,12 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
*/
|
||||
@Value
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@JsonPropertyOrder({"format", "href", "value"})
|
||||
@JsonPropertyOrder({ "format", "href", "value" })
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class Doc {
|
||||
|
||||
private final String href, value;
|
||||
private final String href;
|
||||
private final String value;
|
||||
private final Format format;
|
||||
|
||||
/**
|
||||
@@ -57,4 +58,13 @@ public class Doc {
|
||||
this.value = value;
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
@JsonCreator
|
||||
private Doc(@JsonProperty("href") String href, @JsonProperty("value") String value,
|
||||
@JsonProperty("format") Format format) {
|
||||
|
||||
this.href = href;
|
||||
this.value = value;
|
||||
this.format = format;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@ package org.springframework.hateoas.mediatype.alps;
|
||||
import lombok.Builder;
|
||||
import lombok.Value;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
|
||||
/**
|
||||
@@ -30,10 +32,18 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
||||
*/
|
||||
@Value
|
||||
@Builder
|
||||
@JsonPropertyOrder({"id", "href", "value"})
|
||||
@JsonPropertyOrder({ "id", "href", "value" })
|
||||
public class Ext {
|
||||
|
||||
private final String id;
|
||||
private final String href;
|
||||
private final String value;
|
||||
|
||||
@JsonCreator
|
||||
private Ext(@JsonProperty("id") String id, @JsonProperty("href") String href, @JsonProperty("value") String value) {
|
||||
|
||||
this.id = id;
|
||||
this.href = href;
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user