2222
2323package net .solarnetwork .central .user .datum .event .domain ;
2424
25+ import static net .solarnetwork .util .ObjectUtils .requireNonNullArgument ;
2526import java .io .Serial ;
2627import java .time .Instant ;
2728import java .util .Map ;
29+ import org .jspecify .annotations .Nullable ;
2830import com .fasterxml .jackson .annotation .JsonGetter ;
2931import com .fasterxml .jackson .annotation .JsonIgnore ;
3032import com .fasterxml .jackson .annotation .JsonPropertyOrder ;
@@ -47,12 +49,12 @@ public class UserNodeEventHookConfiguration extends BasicEntity<UserLongPK>
4749 @ Serial
4850 private static final long serialVersionUID = 3878313156603958081L ;
4951
50- private Long [] nodeIds ;
51- private String [] sourceIds ;
52- private String topic ;
5352 private String name ;
5453 private String serviceIdentifier ;
55- private Map <String , Object > serviceProps ;
54+ private Long @ Nullable [] nodeIds ;
55+ private String @ Nullable [] sourceIds ;
56+ private @ Nullable String topic ;
57+ private @ Nullable Map <String , Object > serviceProps ;
5658
5759 /**
5860 * Constructor.
@@ -61,9 +63,18 @@ public class UserNodeEventHookConfiguration extends BasicEntity<UserLongPK>
6163 * the ID
6264 * @param created
6365 * the creation date
66+ * @param name
67+ * the configuration name
68+ * @param serviceIdentifier
69+ * the service identifier
70+ * @throws IllegalArgumentException
71+ * if any argument is {@code null}
6472 */
65- public UserNodeEventHookConfiguration (UserLongPK id , Instant created ) {
66- super (id , created );
73+ public UserNodeEventHookConfiguration (UserLongPK id , Instant created , String name ,
74+ String serviceIdentifier ) {
75+ super (requireNonNullArgument (id , "id" ), requireNonNullArgument (created , "created" ));
76+ this .name = requireNonNullArgument (name , "name" );
77+ this .serviceIdentifier = requireNonNullArgument (serviceIdentifier , "serviceIdentifier" );
6778 }
6879
6980 /**
@@ -73,9 +84,16 @@ public UserNodeEventHookConfiguration(UserLongPK id, Instant created) {
7384 * the user ID
7485 * @param created
7586 * the creation date
87+ * @param name
88+ * the configuration name
89+ * @param serviceIdentifier
90+ * the service identifier
91+ * @throws IllegalArgumentException
92+ * if any argument is {@code null}
7693 */
77- public UserNodeEventHookConfiguration (Long userId , Instant created ) {
78- this (null , userId , created );
94+ public UserNodeEventHookConfiguration (Long userId , Instant created , String name ,
95+ String serviceIdentifier ) {
96+ this (null , userId , created , name , serviceIdentifier );
7997 }
8098
8199 /**
@@ -87,9 +105,17 @@ public UserNodeEventHookConfiguration(Long userId, Instant created) {
87105 * the user ID
88106 * @param created
89107 * the creation date
108+ * @param name
109+ * the configuration name
110+ * @param serviceIdentifier
111+ * the service identifier
112+ * @throws IllegalArgumentException
113+ * if any argument except {@code id} is {@code null}
90114 */
91- public UserNodeEventHookConfiguration (Long id , Long userId , Instant created ) {
92- this (new UserLongPK (userId , id ), created );
115+ public UserNodeEventHookConfiguration (@ Nullable Long id , Long userId , Instant created , String name ,
116+ String serviceIdentifier ) {
117+ this (new UserLongPK (requireNonNullArgument (userId , "userId" ), id ), created , name ,
118+ serviceIdentifier );
93119 }
94120
95121 /**
@@ -101,25 +127,22 @@ public UserNodeEventHookConfiguration(Long id, Long userId, Instant created) {
101127 */
102128 public UserNodeEventHookConfiguration withUserId (Long userId ) {
103129 UserNodeEventHookConfiguration copy = new UserNodeEventHookConfiguration (getConfigurationId (),
104- userId , getCreated ());
105- copy .setName (name );
130+ userId , created (), name , serviceIdentifier );
106131 copy .setNodeIds (nodeIds );
107- copy .setServiceIdentifier (serviceIdentifier );
108132 copy .setServiceProps (serviceProps );
109133 copy .setTopic (topic );
110134 return copy ;
111135 }
112136
113137 @ Override
114- public boolean hasId () {
138+ public final boolean hasId () {
115139 UserLongPK id = getId ();
116140 return (id != null && id .getId () != null && id .getUserId () != null );
117141 }
118142
119143 @ Override
120- public Long getUserId () {
121- final UserLongPK id = getId ();
122- return id != null ? id .getUserId () : null ;
144+ public final Long getUserId () {
145+ return id ().getUserId ();
123146 }
124147
125148 /**
@@ -129,17 +152,16 @@ public Long getUserId() {
129152 * @since 1.1
130153 */
131154 @ JsonGetter ("id" )
132- public Long getConfigurationId () {
133- final UserLongPK id = getId ();
134- return (id != null ? id .getId () : null );
155+ public final @ Nullable Long getConfigurationId () {
156+ return id ().getId ();
135157 }
136158
137159 /**
138160 * Get the node IDs.
139161 *
140162 * @return the node IDs, or {@code null} for any node
141163 */
142- public Long [] getNodeIds () {
164+ public final Long @ Nullable [] getNodeIds () {
143165 return nodeIds ;
144166 }
145167
@@ -149,7 +171,7 @@ public Long[] getNodeIds() {
149171 * @param nodeIds
150172 * the node IDs to set
151173 */
152- public void setNodeIds (Long [] nodeIds ) {
174+ public final void setNodeIds (Long @ Nullable [] nodeIds ) {
153175 this .nodeIds = nodeIds ;
154176 }
155177
@@ -162,7 +184,7 @@ public void setNodeIds(Long[] nodeIds) {
162184 *
163185 * @return the source IDs
164186 */
165- public String [] getSourceIds () {
187+ public final String @ Nullable [] getSourceIds () {
166188 return sourceIds ;
167189 }
168190
@@ -172,7 +194,7 @@ public String[] getSourceIds() {
172194 * @param sourceIds
173195 * the source IDs or source ID Ant-style patterns to set
174196 */
175- public void setSourceIds (String [] sourceIds ) {
197+ public final void setSourceIds (String @ Nullable [] sourceIds ) {
176198 this .sourceIds = sourceIds ;
177199 }
178200
@@ -181,7 +203,7 @@ public void setSourceIds(String[] sourceIds) {
181203 *
182204 * @return the topic
183205 */
184- public String getTopic () {
206+ public final @ Nullable String getTopic () {
185207 return topic ;
186208 }
187209
@@ -191,12 +213,12 @@ public String getTopic() {
191213 * @param topic
192214 * the topic to set
193215 */
194- public void setTopic (String topic ) {
216+ public final void setTopic (@ Nullable String topic ) {
195217 this .topic = topic ;
196218 }
197219
198220 @ Override
199- public String getName () {
221+ public final String getName () {
200222 return name ;
201223 }
202224
@@ -205,13 +227,15 @@ public String getName() {
205227 *
206228 * @param name
207229 * the name to use
230+ * @throws IllegalArgumentException
231+ * if any argument is {@code null}
208232 */
209- public void setName (String name ) {
210- this .name = name ;
233+ public final void setName (String name ) {
234+ this .name = requireNonNullArgument ( name , "name" ) ;
211235 }
212236
213237 @ Override
214- public String getServiceIdentifier () {
238+ public final String getServiceIdentifier () {
215239 return serviceIdentifier ;
216240 }
217241
@@ -221,24 +245,26 @@ public String getServiceIdentifier() {
221245 *
222246 * @param serviceIdentifier
223247 * the identifier of the service to use
248+ * @throws IllegalArgumentException
249+ * if any argument is {@code null}
224250 */
225- public void setServiceIdentifier (String serviceIdentifier ) {
226- this .serviceIdentifier = serviceIdentifier ;
251+ public final void setServiceIdentifier (String serviceIdentifier ) {
252+ this .serviceIdentifier = requireNonNullArgument ( serviceIdentifier , "serviceIdentifier" ) ;
227253 }
228254
229255 @ Override
230256 @ JsonIgnore
231- public Map <String , ?> getServiceProperties () {
257+ public final @ Nullable Map <String , ?> getServiceProperties () {
232258 return getServiceProps ();
233259 }
234260
235261 @ JsonGetter ("serviceProperties" )
236- public Map <String , Object > getServiceProps () {
262+ public final @ Nullable Map <String , Object > getServiceProps () {
237263 return serviceProps ;
238264 }
239265
240266 @ JsonSetter ("serviceProperties" )
241- public void setServiceProps (Map <String , Object > serviceProps ) {
267+ public final void setServiceProps (@ Nullable Map <String , Object > serviceProps ) {
242268 this .serviceProps = serviceProps ;
243269 }
244270
0 commit comments