Skip to content

Commit 160005e

Browse files
committed
Added some more class level documentation
1 parent f77aeea commit 160005e

File tree

6 files changed

+26
-6
lines changed

6 files changed

+26
-6
lines changed

src/main/java/io/openapitools/jackson/dataformat/hal/annotation/Curie.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77

88
/**
99
* Annotation specifying a CURIE for use with links. As defined by W3C in
10-
* <a href="https://www.w3.org/TR/2010/NOTE-curie-20101216/">CURIE Syntax 1.0</a>.
10+
* <a href="https://www.w3.org/TR/2010/NOTE-curie-20101216/">CURIE Syntax 1.0</a>. Note that in
11+
* the context of HAL the only substitution done to the template URI of a curie is the
12+
* <code>{rel}</code> place holder.
1113
*/
1214
@Target({ElementType.TYPE })
1315
@Retention(RetentionPolicy.RUNTIME)

src/main/java/io/openapitools/jackson/dataformat/hal/annotation/Curies.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import java.lang.annotation.Target;
77

88
/**
9-
* Annotation specifying a CURIE for use with links
9+
* Annotation specifying an array of curies to be used in defining link relations.
1010
*/
1111
@Target({ElementType.TYPE })
1212
@Retention(RetentionPolicy.RUNTIME)

src/main/java/io/openapitools/jackson/dataformat/hal/annotation/Link.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
String value() default "";
1919

2020
/**
21-
* CURIE name - if not set then no CURIE will be associated.
21+
* CURIE prefix - if not set then no CURIE will be associated.
2222
* @return name of the CURIE intended to be used with this link.
2323
*/
2424
String curie() default "";

src/main/java/io/openapitools/jackson/dataformat/hal/deser/HALBeanDeserializer.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
import java.util.stream.StreamSupport;
2020

2121
/**
22-
* Deserializer to handle incoming application/hal+json.
22+
* Deserializer to handle incoming application/hal+json. The de-serializer is responsible for intercepting
23+
* the reserved properties (<code>_links</code> and <code>_embedded</code>) and mapping the properties of these
24+
* objects in the incoming json to the uniquely assigned properties of the POJO class.
2325
*/
2426
public class HALBeanDeserializer extends DelegatingDeserializer {
2527

@@ -28,7 +30,7 @@ public HALBeanDeserializer(BeanDeserializerBase delegate) {
2830
}
2931

3032
@Override
31-
public Object deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException {
33+
public Object deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
3234
TreeNode tn = p.getCodec().readTree(p);
3335
if (tn.isObject()) {
3436
ObjectNode root = (ObjectNode) tn;

src/main/java/io/openapitools/jackson/dataformat/hal/deser/HALBeanDeserializerModifier.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717

1818
/**
1919
* Modify the deserialization of classes annotated with {@link Resource}. Deserialization will handle the reserved
20-
* properties <code>_links</code> and <code>_embedded</code>.
20+
* properties <code>_links</code> and <code>_embedded</code> by assigning a unique property name to each of the
21+
* properties that are part of these sections.
2122
*/
2223
public class HALBeanDeserializerModifier extends BeanDeserializerModifier {
2324

src/main/java/io/openapitools/jackson/dataformat/hal/deser/ReservedProperty.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ public String getPropertyName() {
3737
return name;
3838
}
3939

40+
/**
41+
* Assign an alternate name to POJO property that is unique outside of the the reserved
42+
* object - if it is a link or embedded property.
43+
*
44+
* @param bpd The property to process.
45+
* @param map Curie map applying to properties of <code>_links</code> section.
46+
* @return An alternate name if relevant otherwise the original name is maintained.
47+
*/
4048
public String alternateName(BeanPropertyDefinition bpd, CurieMap map) {
4149
String originalName = bpd.getName();
4250

@@ -69,6 +77,13 @@ public String alternateName(BeanPropertyDefinition bpd, CurieMap map) {
6977
return alternateName(name);
7078
}
7179

80+
/**
81+
* Given a property that should belong to this reserved object instance a name is assigned which will
82+
* be unique outside of the reserved property.
83+
*
84+
* @param originalName Property name within this reserved object that should be unique outside.
85+
* @return Alternate name for the given original name.
86+
*/
7287
public String alternateName(String originalName) {
7388
return prefix.toString() + ":" + originalName;
7489
}

0 commit comments

Comments
 (0)