24
24
import com .fasterxml .jackson .annotation .JsonInclude ;
25
25
import com .fasterxml .jackson .databind .annotation .JsonDeserialize ;
26
26
27
+ import jakarta .validation .constraints .NotBlank ;
28
+ import jakarta .validation .constraints .Pattern ;
29
+ import jakarta .validation .constraints .Size ;
27
30
import javax .jdo .annotations .Column ;
28
- import javax .jdo .annotations .Extension ;
29
31
import javax .jdo .annotations .IdGeneratorStrategy ;
30
- import javax .jdo .annotations .Order ;
32
+ import javax .jdo .annotations .Index ;
31
33
import javax .jdo .annotations .PersistenceCapable ;
32
34
import javax .jdo .annotations .Persistent ;
33
35
import javax .jdo .annotations .PrimaryKey ;
34
- import jakarta .validation .constraints .NotBlank ;
35
- import jakarta .validation .constraints .Pattern ;
36
- import jakarta .validation .constraints .Size ;
37
36
import java .io .Serializable ;
38
- import java .util .List ;
39
37
import java .util .Objects ;
38
+ import java .util .Set ;
40
39
41
40
/**
42
41
* Model for assigning tags to specific objects.
@@ -64,6 +63,7 @@ public Tag(final String name) {
64
63
65
64
@ Persistent
66
65
@ Column (name = "NAME" , allowsNull = "false" )
66
+ @ Index (name = "TAG_NAME_IDX" , unique = "true" )
67
67
@ NotBlank
68
68
@ Size (min = 1 , max = 255 )
69
69
@ JsonDeserialize (using = TrimmedStringDeserializer .class )
@@ -72,23 +72,19 @@ public Tag(final String name) {
72
72
73
73
@ Persistent
74
74
@ JsonIgnore
75
- @ Order (extensions = @ Extension (vendorName = "datanucleus" , key = "list-ordering" , value = "name ASC" ))
76
- private List <Policy > policies ;
75
+ private Set <Policy > policies ;
77
76
78
77
@ Persistent
79
78
@ JsonIgnore
80
- @ Order (extensions = @ Extension (vendorName = "datanucleus" , key = "list-ordering" , value = "name ASC" ))
81
- private List <Project > projects ;
79
+ private Set <Project > projects ;
82
80
83
81
@ Persistent
84
82
@ JsonIgnore
85
- @ Order (extensions = @ Extension (vendorName = "datanucleus" , key = "list-ordering" , value = "vulnId ASC" ))
86
- private List <Vulnerability > vulnerabilities ;
83
+ private Set <Vulnerability > vulnerabilities ;
87
84
88
85
@ Persistent
89
86
@ JsonIgnore
90
- @ Order (extensions = @ Extension (vendorName = "datanucleus" , key = "list-ordering" , value = "name ASC" ))
91
- private List <NotificationRule > notificationRules ;
87
+ private Set <NotificationRule > notificationRules ;
92
88
93
89
public long getId () {
94
90
return id ;
@@ -106,48 +102,48 @@ public void setName(String name) {
106
102
this .name = name ;
107
103
}
108
104
109
- public List <Policy > getPolicies () {
105
+ public Set <Policy > getPolicies () {
110
106
return policies ;
111
107
}
112
108
113
- public void setPolicies (List <Policy > policies ) {
109
+ public void setPolicies (Set <Policy > policies ) {
114
110
this .policies = policies ;
115
111
}
116
112
117
- public List <Project > getProjects () {
113
+ public Set <Project > getProjects () {
118
114
return projects ;
119
115
}
120
116
121
- public void setProjects (List <Project > projects ) {
117
+ public void setProjects (Set <Project > projects ) {
122
118
this .projects = projects ;
123
119
}
124
120
125
- public List <Vulnerability > getVulnerabilities () {
121
+ public Set <Vulnerability > getVulnerabilities () {
126
122
return vulnerabilities ;
127
123
}
128
124
129
- public void setVulnerabilities (List <Vulnerability > vulnerabilities ) {
125
+ public void setVulnerabilities (Set <Vulnerability > vulnerabilities ) {
130
126
this .vulnerabilities = vulnerabilities ;
131
127
}
132
128
133
- public List <NotificationRule > getNotificationRules () {
129
+ public Set <NotificationRule > getNotificationRules () {
134
130
return notificationRules ;
135
131
}
136
132
137
- public void setNotificationRules (final List <NotificationRule > notificationRules ) {
133
+ public void setNotificationRules (final Set <NotificationRule > notificationRules ) {
138
134
this .notificationRules = notificationRules ;
139
135
}
140
136
141
137
@ Override
142
- public boolean equals (Object object ) {
143
- if (object instanceof Tag ) {
144
- return this .id == (( Tag ) object ). id ;
138
+ public boolean equals (Object other ) {
139
+ if (other instanceof final Tag otherTag ) {
140
+ return Objects . equals ( this .name , otherTag . name ) ;
145
141
}
146
142
return false ;
147
143
}
148
144
149
145
@ Override
150
146
public int hashCode () {
151
- return Objects .hash (id );
147
+ return Objects .hash (name );
152
148
}
153
149
}
0 commit comments