1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package io.wcm.caravan.hal.docs.impl.model;
21
22 import java.util.ArrayList;
23 import java.util.Collection;
24 import java.util.List;
25 import java.util.SortedSet;
26 import java.util.TreeSet;
27
28 import org.apache.commons.lang3.StringUtils;
29
30
31
32
33 public class LinkRelation implements Comparable<LinkRelation> {
34
35 private String rel;
36 private String shortDescription;
37 private String descriptionMarkup;
38 private String jsonSchemaRef;
39 private List<ResourceRef> resourceRefs = new ArrayList<>();
40 private SortedSet<LinkRelationRef> linkRelationRefs = new TreeSet<>();
41
42 public String getRel() {
43 return this.rel;
44 }
45
46 public void setRel(String rel) {
47 this.rel = rel;
48 }
49
50 public String getShortDescription() {
51 return this.shortDescription;
52 }
53
54 public void setShortDescription(String shortDescription) {
55 this.shortDescription = shortDescription;
56 }
57
58 public String getDescriptionMarkup() {
59 return this.descriptionMarkup;
60 }
61
62 public void setDescriptionMarkup(String descriptionMarkup) {
63 this.descriptionMarkup = descriptionMarkup;
64 }
65
66 public String getJsonSchemaRef() {
67 return this.jsonSchemaRef;
68 }
69
70 public void setJsonSchemaRef(String jsonSchemaRef) {
71 this.jsonSchemaRef = jsonSchemaRef;
72 }
73
74
75
76
77 public Collection<ResourceRef> getResourceRefs() {
78 return resourceRefs;
79 }
80
81
82
83
84
85
86 public void addResourceRef(String refName, String refDescription, String refJsonSchemaRef) {
87 ResourceRef ref = new ResourceRef();
88 ref.setName(refName);
89 ref.setShortDescription(refDescription);
90 ref.setJsonSchemaRef(refJsonSchemaRef);
91 this.resourceRefs.add(ref);
92 }
93
94
95
96
97 public Collection<LinkRelationRef> getLinkRelationRefs() {
98 return linkRelationRefs;
99 }
100
101
102
103
104
105 public void addLinkRelationRef(String refRel, String refDescription) {
106 LinkRelationRef ref = new LinkRelationRef();
107 ref.setRel(refRel);
108 ref.setShortDescription(refDescription);
109 this.linkRelationRefs.add(ref);
110 }
111
112 @Override
113 public int hashCode() {
114 return rel.hashCode();
115 }
116
117 @Override
118 public boolean equals(Object obj) {
119 if (!(obj instanceof LinkRelation)) {
120 return false;
121 }
122 return StringUtils.equals(rel, ((LinkRelation)obj).rel);
123 }
124
125 @Override
126 public int compareTo(LinkRelation o) {
127 return StringUtils.defaultString(rel).compareTo(o.getRel());
128 }
129
130 }