View Javadoc
1   /*
2    * Copyright (C) 2022-2023 Dipl.-Inform. Kai Hofmann. All rights reserved!
3    */
4   package de.powerstat.validation.containers;
5   
6   
7   import java.util.Objects;
8   
9   
10  /**
11   * N-Tuple 15.
12   *
13   * @param <T1> Type 1
14   * @param <T2> Type 2 optional
15   * @param <T3> Type 3 optional
16   * @param <T4> Type 4 optional
17   * @param <T5> Type 5 optional
18   * @param <T6> Type 6 optional
19   * @param <T7> Type 7 optional
20   * @param <T8> Type 8 optional
21   * @param <T9> Type 9 optional
22   * @param <T10> Type 10 optional
23   * @param <T11> Type 11 optional
24   * @param <T12> Type 12 optional
25   * @param <T13> Type 13 optional
26   * @param <T14> Type 14 optional
27   * @param <T15> Type 15 optional
28   */
29  // @SuppressFBWarnings("CC_CYCLOMATIC_COMPLEXITY")
30  @SuppressWarnings({"checkstyle:ClassTypeParameterName", "checkstyle:MethodTypeParameterName", "checkstyle:NoWhitespaceBefore", "checkstyle:SeparatorWrap", "PMD.GenericsNaming", "PMD.CommentSize", "java:S3776", "java:S1541"})
31  public final class NTuple15<T1 extends Comparable<T1>, T2 extends Comparable<T2>, T3 extends Comparable<T3>, T4 extends Comparable<T4>, T5 extends Comparable<T5>, T6 extends Comparable<T6>, T7 extends Comparable<T7>, T8 extends Comparable<T8>, T9 extends Comparable<T9>, T10 extends Comparable<T10>, T11 extends Comparable<T11>, T12 extends Comparable<T12>, T13 extends Comparable<T13>, T14 extends Comparable<T14>, T15 extends Comparable<T15>> implements Comparable<NTuple15<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>>
32   {
33    /* *
34     * Cache for singletons.
35     */
36    // private static final Map<?, NTuple15<T1 extends Comparable<T1>, T2 extends Comparable<T2>, T3 extends Comparable<T3>, T4 extends Comparable<T4>, T5 extends Comparable<T5>, T6 extends Comparable<T6>, T7 extends Comparable<T7>, T8 extends Comparable<T8>, T9 extends Comparable<T9>, T10 extends Comparable<T10>, T11 extends Comparable<T11>, T12 extends Comparable<T12>, T13 extends Comparable<T13>, T14 extends Comparable<T14>, T15 extends Comparable<T15>>> CACHE = new ConcurrentHashMap<>();
37  
38    /**
39     * Object1 of type T1.
40     */
41    private final T1 object1;
42  
43    /**
44     * Object2 of type T2.
45     */
46    private final T2 object2;
47  
48    /**
49     * Object3 of type T3.
50     */
51    private final T3 object3;
52  
53    /**
54     * Object4 of type T4.
55     */
56    private final T4 object4;
57  
58    /**
59     * Object5 of type T5.
60     */
61    private final T5 object5;
62  
63    /**
64     * Object6 of type T6.
65     */
66    private final T6 object6;
67  
68    /**
69     * Object7 of type T7.
70     */
71    private final T7 object7;
72  
73    /**
74     * Object8 of type T8.
75     */
76    private final T8 object8;
77  
78    /**
79     * Object9 of type T9.
80     */
81    private final T9 object9;
82  
83    /**
84     * Object10 of type T10.
85     */
86    private final T10 object10;
87  
88    /**
89     * Object11 of type T11.
90     */
91    private final T11 object11;
92  
93    /**
94     * Object12 of type T12.
95     */
96    private final T12 object12;
97  
98    /**
99     * Object13 of type T13.
100    */
101   private final T13 object13;
102 
103   /**
104    * Object14 of type T14.
105    */
106   private final T14 object14;
107 
108   /**
109    * Object15 of type T15.
110    */
111   private final T15 object15;
112 
113 
114   /**
115    * Private constructor.
116    *
117    * @param obj1 Object 1 of type T1
118    * @param obj2 Object 2 of Type T2
119    * @param obj3 Object 3 of Type T3
120    * @param obj4 Object 4 of type T4
121    * @param obj5 Object 5 of Type T5
122    * @param obj6 Object 6 of Type T6
123    * @param obj7 Object 7 of type T7
124    * @param obj8 Object 8 of Type T8
125    * @param obj9 Object 9 of Type T9
126    * @param obj10 Object 10 of Type T10
127    * @param obj11 Object 11 of Type T11
128    * @param obj12 Object 12 of Type T12
129    * @param obj13 Object 13 of Type T13
130    * @param obj14 Object 14 of Type T14
131    * @param obj15 Object 15 of Type T15
132    */
133   private NTuple15(final T1 obj1, final T2 obj2, final T3 obj3, final T4 obj4, final T5 obj5, final T6 obj6, final T7 obj7, final T8 obj8, final T9 obj9, final T10 obj10, final T11 obj11, final T12 obj12, final T13 obj13, final T14 obj14, final T15 obj15)
134    {
135     super();
136     Objects.requireNonNull(obj1, "obj1 is null"); //$NON-NLS-1$
137     /*
138     Objects.requireNonNull(obj2, "obj2 is null"); //$NON-NLS-1$
139     Objects.requireNonNull(obj3, "obj3 is null"); //$NON-NLS-1$
140     Objects.requireNonNull(obj4, "obj4 is null"); //$NON-NLS-1$
141     Objects.requireNonNull(obj5, "obj5 is null"); //$NON-NLS-1$
142     Objects.requireNonNull(obj6, "obj6 is null"); //$NON-NLS-1$
143     Objects.requireNonNull(obj7, "obj7 is null"); //$NON-NLS-1$
144     Objects.requireNonNull(obj8, "obj8 is null"); //$NON-NLS-1$
145     Objects.requireNonNull(obj9, "obj9 is null"); //$NON-NLS-1$
146     Objects.requireNonNull(obj10, "obj10 is null"); //$NON-NLS-1$
147     Objects.requireNonNull(obj11, "obj11 is null"); //$NON-NLS-1$
148     Objects.requireNonNull(obj12, "obj12 is null"); //$NON-NLS-1$
149     Objects.requireNonNull(obj13, "obj13 is null"); //$NON-NLS-1$
150     Objects.requireNonNull(obj14, "obj14 is null"); //$NON-NLS-1$
151     Objects.requireNonNull(obj15, "obj15 is null"); //$NON-NLS-1$
152     */
153     this.object1 = obj1;
154     this.object2 = obj2;
155     this.object3 = obj3;
156     this.object4 = obj4;
157     this.object5 = obj5;
158     this.object6 = obj6;
159     this.object7 = obj7;
160     this.object8 = obj8;
161     this.object9 = obj9;
162     this.object10 = obj10;
163     this.object11 = obj11;
164     this.object12 = obj12;
165     this.object13 = obj13;
166     this.object14 = obj14;
167     this.object15 = obj15;
168    }
169 
170 
171   /**
172    * NTuple15 factory.
173    *
174    * @param <T1> Type 1
175    * @param <T2> Type 2 optional
176    * @param <T3> Type 3 optional
177    * @param <T4> Type 4 optional
178    * @param <T5> Type 5 optional
179    * @param <T6> Type 6 optional
180    * @param <T7> Type 7 optional
181    * @param <T8> Type 8 optional
182    * @param <T9> Type 9 optional
183    * @param <T10> Type 10 optional
184    * @param <T11> Type 11 optional
185    * @param <T12> Type 12 optional
186    * @param <T13> Type 13 optional
187    * @param <T14> Type 14 optional
188    * @param <T15> Type 15 optional
189    * @param obj1 Object 1 of type T1
190    * @param obj2 Object 2 of Type T2 optional
191    * @param obj3 Object 3 of Type T3 optional
192    * @param obj4 Object 1 of type T4 optional
193    * @param obj5 Object 2 of Type T5 optional
194    * @param obj6 Object 3 of Type T6 optional
195    * @param obj7 Object 1 of type T7 optional
196    * @param obj8 Object 2 of Type T8 optional
197    * @param obj9 Object 3 of Type T9 optional
198    * @param obj10 Object 10 of Type T10 optional
199    * @param obj11 Object 11 of Type T11 optional
200    * @param obj12 Object 12 of Type T12 optional
201    * @param obj13 Object 13 of Type T13 optional
202    * @param obj14 Object 14 of Type T14 optional
203    * @param obj15 Object 15 of Type T15 optional
204    * @return NTuple15 object
205    */
206   public static <T1 extends Comparable<T1>, T2 extends Comparable<T2>, T3 extends Comparable<T3>, T4 extends Comparable<T4>, T5 extends Comparable<T5>, T6 extends Comparable<T6>, T7 extends Comparable<T7>, T8 extends Comparable<T8>, T9 extends Comparable<T9>, T10 extends Comparable<T10>, T11 extends Comparable<T11>, T12 extends Comparable<T12>, T13 extends Comparable<T13>, T14 extends Comparable<T14>, T15 extends Comparable<T15>> NTuple15<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> of(final T1 obj1, final T2 obj2, final T3 obj3, final T4 obj4, final T5 obj5, final T6 obj6, final T7 obj7, final T8 obj8, final T9 obj9, final T10 obj10, final T11 obj11, final T12 obj12, final T13 obj13, final T14 obj14, final T15 obj15)
207    {
208     return new NTuple15<>(obj1, obj2, obj3, obj4, obj5, obj6, obj7, obj8, obj9, obj10, obj11, obj12, obj13, obj14, obj15);
209    }
210 
211 
212 
213   /**
214    * Returns the first value of this NTuple15 as a T1.
215    *
216    * @return The T1 value represented by this object.
217    */
218   public T1 t1Value()
219    {
220     return this.object1;
221    }
222 
223 
224   /**
225    * Returns the second value of this NTuple15 as a T2.
226    *
227    * @return The T2 value represented by this object.
228    */
229   public T2 t2Value()
230    {
231     return this.object2;
232    }
233 
234 
235   /**
236    * Returns the second value of this NTuple15 as a T3.
237    *
238    * @return The T3 value represented by this object.
239    */
240   public T3 t3Value()
241    {
242     return this.object3;
243    }
244 
245 
246   /**
247    * Returns the second value of this NTuple15 as a T4.
248    *
249    * @return The T4 value represented by this object.
250    */
251   public T4 t4Value()
252    {
253     return this.object4;
254    }
255 
256 
257   /**
258    * Returns the second value of this NTuple15 as a T5.
259    *
260    * @return The T5 value represented by this object.
261    */
262   public T5 t5Value()
263    {
264     return this.object5;
265    }
266 
267 
268   /**
269    * Returns the second value of this NTuple15 as a T6.
270    *
271    * @return The T6 value represented by this object.
272    */
273   public T6 t6Value()
274    {
275     return this.object6;
276    }
277 
278 
279   /**
280    * Returns the second value of this NTuple15 as a T7.
281    *
282    * @return The T7 value represented by this object.
283    */
284   public T7 t7Value()
285    {
286     return this.object7;
287    }
288 
289 
290   /**
291    * Returns the second value of this NTuple15 as a T8.
292    *
293    * @return The T8 value represented by this object.
294    */
295   public T8 t8Value()
296    {
297     return this.object8;
298    }
299 
300 
301   /**
302    * Returns the second value of this NTuple15 as a T9.
303    *
304    * @return The T9 value represented by this object.
305    */
306   public T9 t9Value()
307    {
308     return this.object9;
309    }
310 
311 
312   /**
313    * Returns the second value of this NTuple15 as a T10.
314    *
315    * @return The T10 value represented by this object.
316    */
317   public T10 t10Value()
318    {
319     return this.object10;
320    }
321 
322 
323   /**
324    * Returns the second value of this NTuple15 as a T11.
325    *
326    * @return The T11 value represented by this object.
327    */
328   public T11 t11Value()
329    {
330     return this.object11;
331    }
332 
333 
334   /**
335    * Returns the second value of this NTuple15 as a T12.
336    *
337    * @return The T12 value represented by this object.
338    */
339   public T12 t12Value()
340    {
341     return this.object12;
342    }
343 
344 
345   /**
346    * Returns the second value of this NTuple15 as a T13.
347    *
348    * @return The T13 value represented by this object.
349    */
350   public T13 t13Value()
351    {
352     return this.object13;
353    }
354 
355 
356   /**
357    * Returns the second value of this NTuple15 as a T14.
358    *
359    * @return The T14 value represented by this object.
360    */
361   public T14 t14Value()
362    {
363     return this.object14;
364    }
365 
366 
367   /**
368    * Returns the second value of this NTuple15 as a T15.
369    *
370    * @return The T15 value represented by this object.
371    */
372   public T15 t15Value()
373    {
374     return this.object15;
375    }
376 
377 
378   /**
379    * Calculate hash code.
380    *
381    * @return Hash
382    * @see java.lang.Object#hashCode()
383    */
384   @Override
385   public int hashCode()
386    {
387     return Objects.hash(this.object1, this.object2, this.object3, this.object4, this.object5, this.object6, this.object7, this.object8, this.object9, this.object10, this.object11, this.object12, this.object13, this.object14, this.object15);
388    }
389 
390 
391   /**
392    * Is equal with another object.
393    *
394    * @param obj Object
395    * @return true when equal, false otherwise
396    * @see java.lang.Object#equals(java.lang.Object)
397    */
398   @Override
399   public boolean equals(final Object obj)
400    {
401     if (this == obj)
402      {
403       return true;
404      }
405     if (!(obj instanceof NTuple15))
406      {
407       return false;
408      }
409     final NTuple15<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> other = (NTuple15<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15>)obj;
410     boolean result = this.object1.equals(other.object1);
411     if (result)
412      {
413 
414       result = (this.object2 == null) ? (other.object2 == null) : this.object2.equals(other.object2);
415       if (result)
416        {
417         result = (this.object3 == null) ? (other.object3 == null) : this.object3.equals(other.object3);
418         if (result)
419          {
420           result = (this.object4 == null) ? (other.object4 == null) : this.object4.equals(other.object4);
421           if (result)
422            {
423             result = (this.object5 == null) ? (other.object5 == null) : this.object5.equals(other.object5);
424             if (result)
425              {
426               result = (this.object6 == null) ? (other.object6 == null) : this.object6.equals(other.object6);
427               if (result)
428                {
429                 result = (this.object7 == null) ? (other.object7 == null) : this.object7.equals(other.object7);
430                 if (result)
431                  {
432                   result = (this.object8 == null) ? (other.object8 == null) : this.object8.equals(other.object8);
433                   if (result)
434                    {
435                     result = (this.object9 == null) ? (other.object9 == null) : this.object9.equals(other.object9);
436                     if (result)
437                      {
438                       result = (this.object10 == null) ? (other.object10 == null) : this.object10.equals(other.object10);
439                       if (result)
440                        {
441                         result = (this.object11 == null) ? (other.object11 == null) : this.object11.equals(other.object11);
442                         if (result)
443                          {
444                           result = (this.object12 == null) ? (other.object12 == null) : this.object12.equals(other.object12);
445                           if (result)
446                            {
447                             result = (this.object13 == null) ? (other.object13 == null) : this.object13.equals(other.object13);
448                             if (result)
449                              {
450                               result = (this.object14 == null) ? (other.object14 == null) : this.object14.equals(other.object14);
451                               if (result)
452                                {
453                                 result = (this.object15 == null) ? (other.object15 == null) : this.object15.equals(other.object15);
454                                }
455                              }
456                            }
457                          }
458                        }
459                      }
460                    }
461                  }
462                }
463              }
464            }
465          }
466        }
467      }
468     return result;
469    }
470 
471 
472   /**
473    * Returns the string representation of this NTuple15.
474    *
475    * The exact details of this representation are unspecified and subject to change, but the following may be regarded as typical:
476    *
477    * "NTuple15[object1=..., object2=..., object3=..., object34=..., object5=..., object6=..., object7=..., object8=..., object9=..., object10=..., object11=..., object12=..., object13=..., object14=..., object15=...]"
478    *
479    * @return String representation of this NTuple15
480    * @see java.lang.Object#toString()
481    */
482   @Override
483   public String toString()
484    {
485     final var builder = new StringBuilder(164);
486     builder.append("NTuple15[object1=").append(this.object1) //$NON-NLS-1$
487       .append(", object2=").append(this.object2) //$NON-NLS-1$
488       .append(", object3=").append(this.object3) //$NON-NLS-1$
489       .append(", object4=").append(this.object4) //$NON-NLS-1$
490       .append(", object5=").append(this.object5) //$NON-NLS-1$
491       .append(", object6=").append(this.object6) //$NON-NLS-1$
492       .append(", object7=").append(this.object7) //$NON-NLS-1$
493       .append(", object8=").append(this.object8) //$NON-NLS-1$
494       .append(", object9=").append(this.object9) //$NON-NLS-1$
495       .append(", object10=").append(this.object10) //$NON-NLS-1$
496       .append(", object11=").append(this.object11) //$NON-NLS-1$
497       .append(", object12=").append(this.object12) //$NON-NLS-1$
498       .append(", object13=").append(this.object13) //$NON-NLS-1$
499       .append(", object14=").append(this.object14) //$NON-NLS-1$
500       .append(", object15=").append(this.object15) //$NON-NLS-1$
501       .append(']');
502     return builder.toString();
503    }
504 
505 
506   /**
507    * Compare with another object.
508    *
509    * @param obj Object to compare with
510    * @return 0: equal; 1: greater; -1: smaller
511    * @see java.lang.Comparable#compareTo(java.lang.Object)
512    */
513   @Override
514   public int compareTo(final NTuple15<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> obj)
515    {
516     Objects.requireNonNull(obj, "obj"); //$NON-NLS-1$
517     int result = this.object1.compareTo(obj.object1);
518     if (result == 0)
519      {
520       result = (this.object2 == null) ? ((obj.object2 == null) ? 0 : -1) : ((obj.object2 == null) ? 1 : this.object2.compareTo(obj.object2));
521       if (result == 0)
522        {
523         result = (this.object3 == null) ? ((obj.object3 == null) ? 0 : -1) : ((obj.object3 == null) ? 1 : this.object3.compareTo(obj.object3));
524         if (result == 0)
525          {
526           result = (this.object4 == null) ? ((obj.object4 == null) ? 0 : -1) : ((obj.object4 == null) ? 1 : this.object4.compareTo(obj.object4));
527           if (result == 0)
528            {
529             result = (this.object5 == null) ? ((obj.object5 == null) ? 0 : -1) : ((obj.object5 == null) ? 1 : this.object5.compareTo(obj.object5));
530             if (result == 0)
531              {
532               result = (this.object6 == null) ? ((obj.object6 == null) ? 0 : -1) : ((obj.object6 == null) ? 1 : this.object6.compareTo(obj.object6));
533               if (result == 0)
534                {
535                 result = (this.object7 == null) ? ((obj.object7 == null) ? 0 : -1) : ((obj.object7 == null) ? 1 : this.object7.compareTo(obj.object7));
536                 if (result == 0)
537                  {
538                   result = (this.object8 == null) ? ((obj.object8 == null) ? 0 : -1) : ((obj.object8 == null) ? 1 : this.object8.compareTo(obj.object8));
539                   if (result == 0)
540                    {
541                     result = (this.object9 == null) ? ((obj.object9 == null) ? 0 : -1) : ((obj.object9 == null) ? 1 : this.object9.compareTo(obj.object9));
542                     if (result == 0)
543                      {
544                       result = (this.object10 == null) ? ((obj.object10 == null) ? 0 : -1) : ((obj.object10 == null) ? 1 : this.object10.compareTo(obj.object10));
545                       if (result == 0)
546                        {
547                         result = (this.object11 == null) ? ((obj.object11 == null) ? 0 : -1) : ((obj.object11 == null) ? 1 : this.object11.compareTo(obj.object11));
548                         if (result == 0)
549                          {
550                           result = (this.object12 == null) ? ((obj.object12 == null) ? 0 : -1) : ((obj.object12 == null) ? 1 : this.object12.compareTo(obj.object12));
551                           if (result == 0)
552                            {
553                             result = (this.object13 == null) ? ((obj.object13 == null) ? 0 : -1) : ((obj.object13 == null) ? 1 : this.object13.compareTo(obj.object13));
554                             if (result == 0)
555                              {
556                               result = (this.object14 == null) ? ((obj.object14 == null) ? 0 : -1) : ((obj.object14 == null) ? 1 : this.object14.compareTo(obj.object14));
557                               if (result == 0)
558                                {
559                                 result = (this.object15 == null) ? ((obj.object15 == null) ? 0 : -1) : ((obj.object15 == null) ? 1 : this.object15.compareTo(obj.object15));
560                                }
561                              }
562                            }
563                          }
564                        }
565                      }
566                    }
567                  }
568                }
569              }
570            }
571          }
572        }
573      }
574     return result;
575    }
576 
577  }