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