NTuple15.java

  1. /*
  2.  * Copyright (C) 2022-2023 Dipl.-Inform. Kai Hofmann. All rights reserved!
  3.  */
  4. package de.powerstat.validation.containers;


  5. import java.util.Objects;


  6. /**
  7.  * N-Tuple 15.
  8.  *
  9.  * @param <T1> Type 1
  10.  * @param <T2> Type 2 optional
  11.  * @param <T3> Type 3 optional
  12.  * @param <T4> Type 4 optional
  13.  * @param <T5> Type 5 optional
  14.  * @param <T6> Type 6 optional
  15.  * @param <T7> Type 7 optional
  16.  * @param <T8> Type 8 optional
  17.  * @param <T9> Type 9 optional
  18.  * @param <T10> Type 10 optional
  19.  * @param <T11> Type 11 optional
  20.  * @param <T12> Type 12 optional
  21.  * @param <T13> Type 13 optional
  22.  * @param <T14> Type 14 optional
  23.  * @param <T15> Type 15 optional
  24.  */
  25. // @SuppressFBWarnings("CC_CYCLOMATIC_COMPLEXITY")
  26. @SuppressWarnings({"checkstyle:ClassTypeParameterName", "checkstyle:MethodTypeParameterName", "checkstyle:NoWhitespaceBefore", "checkstyle:SeparatorWrap", "PMD.GenericsNaming", "PMD.CommentSize", "java:S3776", "java:S1541"})
  27. 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>>
  28.  {
  29.   /* *
  30.    * Cache for singletons.
  31.    */
  32.   // 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<>();

  33.   /**
  34.    * Object1 of type T1.
  35.    */
  36.   private final T1 object1;

  37.   /**
  38.    * Object2 of type T2.
  39.    */
  40.   private final T2 object2;

  41.   /**
  42.    * Object3 of type T3.
  43.    */
  44.   private final T3 object3;

  45.   /**
  46.    * Object4 of type T4.
  47.    */
  48.   private final T4 object4;

  49.   /**
  50.    * Object5 of type T5.
  51.    */
  52.   private final T5 object5;

  53.   /**
  54.    * Object6 of type T6.
  55.    */
  56.   private final T6 object6;

  57.   /**
  58.    * Object7 of type T7.
  59.    */
  60.   private final T7 object7;

  61.   /**
  62.    * Object8 of type T8.
  63.    */
  64.   private final T8 object8;

  65.   /**
  66.    * Object9 of type T9.
  67.    */
  68.   private final T9 object9;

  69.   /**
  70.    * Object10 of type T10.
  71.    */
  72.   private final T10 object10;

  73.   /**
  74.    * Object11 of type T11.
  75.    */
  76.   private final T11 object11;

  77.   /**
  78.    * Object12 of type T12.
  79.    */
  80.   private final T12 object12;

  81.   /**
  82.    * Object13 of type T13.
  83.    */
  84.   private final T13 object13;

  85.   /**
  86.    * Object14 of type T14.
  87.    */
  88.   private final T14 object14;

  89.   /**
  90.    * Object15 of type T15.
  91.    */
  92.   private final T15 object15;


  93.   /**
  94.    * Private constructor.
  95.    *
  96.    * @param obj1 Object 1 of type T1
  97.    * @param obj2 Object 2 of Type T2
  98.    * @param obj3 Object 3 of Type T3
  99.    * @param obj4 Object 4 of type T4
  100.    * @param obj5 Object 5 of Type T5
  101.    * @param obj6 Object 6 of Type T6
  102.    * @param obj7 Object 7 of type T7
  103.    * @param obj8 Object 8 of Type T8
  104.    * @param obj9 Object 9 of Type T9
  105.    * @param obj10 Object 10 of Type T10
  106.    * @param obj11 Object 11 of Type T11
  107.    * @param obj12 Object 12 of Type T12
  108.    * @param obj13 Object 13 of Type T13
  109.    * @param obj14 Object 14 of Type T14
  110.    * @param obj15 Object 15 of Type T15
  111.    */
  112.   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)
  113.    {
  114.     super();
  115.     Objects.requireNonNull(obj1, "obj1 is null"); //$NON-NLS-1$
  116.     /*
  117.     Objects.requireNonNull(obj2, "obj2 is null"); //$NON-NLS-1$
  118.     Objects.requireNonNull(obj3, "obj3 is null"); //$NON-NLS-1$
  119.     Objects.requireNonNull(obj4, "obj4 is null"); //$NON-NLS-1$
  120.     Objects.requireNonNull(obj5, "obj5 is null"); //$NON-NLS-1$
  121.     Objects.requireNonNull(obj6, "obj6 is null"); //$NON-NLS-1$
  122.     Objects.requireNonNull(obj7, "obj7 is null"); //$NON-NLS-1$
  123.     Objects.requireNonNull(obj8, "obj8 is null"); //$NON-NLS-1$
  124.     Objects.requireNonNull(obj9, "obj9 is null"); //$NON-NLS-1$
  125.     Objects.requireNonNull(obj10, "obj10 is null"); //$NON-NLS-1$
  126.     Objects.requireNonNull(obj11, "obj11 is null"); //$NON-NLS-1$
  127.     Objects.requireNonNull(obj12, "obj12 is null"); //$NON-NLS-1$
  128.     Objects.requireNonNull(obj13, "obj13 is null"); //$NON-NLS-1$
  129.     Objects.requireNonNull(obj14, "obj14 is null"); //$NON-NLS-1$
  130.     Objects.requireNonNull(obj15, "obj15 is null"); //$NON-NLS-1$
  131.     */
  132.     this.object1 = obj1;
  133.     this.object2 = obj2;
  134.     this.object3 = obj3;
  135.     this.object4 = obj4;
  136.     this.object5 = obj5;
  137.     this.object6 = obj6;
  138.     this.object7 = obj7;
  139.     this.object8 = obj8;
  140.     this.object9 = obj9;
  141.     this.object10 = obj10;
  142.     this.object11 = obj11;
  143.     this.object12 = obj12;
  144.     this.object13 = obj13;
  145.     this.object14 = obj14;
  146.     this.object15 = obj15;
  147.    }


  148.   /**
  149.    * NTuple15 factory.
  150.    *
  151.    * @param <T1> Type 1
  152.    * @param <T2> Type 2 optional
  153.    * @param <T3> Type 3 optional
  154.    * @param <T4> Type 4 optional
  155.    * @param <T5> Type 5 optional
  156.    * @param <T6> Type 6 optional
  157.    * @param <T7> Type 7 optional
  158.    * @param <T8> Type 8 optional
  159.    * @param <T9> Type 9 optional
  160.    * @param <T10> Type 10 optional
  161.    * @param <T11> Type 11 optional
  162.    * @param <T12> Type 12 optional
  163.    * @param <T13> Type 13 optional
  164.    * @param <T14> Type 14 optional
  165.    * @param <T15> Type 15 optional
  166.    * @param obj1 Object 1 of type T1
  167.    * @param obj2 Object 2 of Type T2 optional
  168.    * @param obj3 Object 3 of Type T3 optional
  169.    * @param obj4 Object 1 of type T4 optional
  170.    * @param obj5 Object 2 of Type T5 optional
  171.    * @param obj6 Object 3 of Type T6 optional
  172.    * @param obj7 Object 1 of type T7 optional
  173.    * @param obj8 Object 2 of Type T8 optional
  174.    * @param obj9 Object 3 of Type T9 optional
  175.    * @param obj10 Object 10 of Type T10 optional
  176.    * @param obj11 Object 11 of Type T11 optional
  177.    * @param obj12 Object 12 of Type T12 optional
  178.    * @param obj13 Object 13 of Type T13 optional
  179.    * @param obj14 Object 14 of Type T14 optional
  180.    * @param obj15 Object 15 of Type T15 optional
  181.    * @return NTuple15 object
  182.    */
  183.   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)
  184.    {
  185.     return new NTuple15<>(obj1, obj2, obj3, obj4, obj5, obj6, obj7, obj8, obj9, obj10, obj11, obj12, obj13, obj14, obj15);
  186.    }



  187.   /**
  188.    * Returns the first value of this NTuple15 as a T1.
  189.    *
  190.    * @return The T1 value represented by this object.
  191.    */
  192.   public T1 t1Value()
  193.    {
  194.     return this.object1;
  195.    }


  196.   /**
  197.    * Returns the second value of this NTuple15 as a T2.
  198.    *
  199.    * @return The T2 value represented by this object.
  200.    */
  201.   public T2 t2Value()
  202.    {
  203.     return this.object2;
  204.    }


  205.   /**
  206.    * Returns the second value of this NTuple15 as a T3.
  207.    *
  208.    * @return The T3 value represented by this object.
  209.    */
  210.   public T3 t3Value()
  211.    {
  212.     return this.object3;
  213.    }


  214.   /**
  215.    * Returns the second value of this NTuple15 as a T4.
  216.    *
  217.    * @return The T4 value represented by this object.
  218.    */
  219.   public T4 t4Value()
  220.    {
  221.     return this.object4;
  222.    }


  223.   /**
  224.    * Returns the second value of this NTuple15 as a T5.
  225.    *
  226.    * @return The T5 value represented by this object.
  227.    */
  228.   public T5 t5Value()
  229.    {
  230.     return this.object5;
  231.    }


  232.   /**
  233.    * Returns the second value of this NTuple15 as a T6.
  234.    *
  235.    * @return The T6 value represented by this object.
  236.    */
  237.   public T6 t6Value()
  238.    {
  239.     return this.object6;
  240.    }


  241.   /**
  242.    * Returns the second value of this NTuple15 as a T7.
  243.    *
  244.    * @return The T7 value represented by this object.
  245.    */
  246.   public T7 t7Value()
  247.    {
  248.     return this.object7;
  249.    }


  250.   /**
  251.    * Returns the second value of this NTuple15 as a T8.
  252.    *
  253.    * @return The T8 value represented by this object.
  254.    */
  255.   public T8 t8Value()
  256.    {
  257.     return this.object8;
  258.    }


  259.   /**
  260.    * Returns the second value of this NTuple15 as a T9.
  261.    *
  262.    * @return The T9 value represented by this object.
  263.    */
  264.   public T9 t9Value()
  265.    {
  266.     return this.object9;
  267.    }


  268.   /**
  269.    * Returns the second value of this NTuple15 as a T10.
  270.    *
  271.    * @return The T10 value represented by this object.
  272.    */
  273.   public T10 t10Value()
  274.    {
  275.     return this.object10;
  276.    }


  277.   /**
  278.    * Returns the second value of this NTuple15 as a T11.
  279.    *
  280.    * @return The T11 value represented by this object.
  281.    */
  282.   public T11 t11Value()
  283.    {
  284.     return this.object11;
  285.    }


  286.   /**
  287.    * Returns the second value of this NTuple15 as a T12.
  288.    *
  289.    * @return The T12 value represented by this object.
  290.    */
  291.   public T12 t12Value()
  292.    {
  293.     return this.object12;
  294.    }


  295.   /**
  296.    * Returns the second value of this NTuple15 as a T13.
  297.    *
  298.    * @return The T13 value represented by this object.
  299.    */
  300.   public T13 t13Value()
  301.    {
  302.     return this.object13;
  303.    }


  304.   /**
  305.    * Returns the second value of this NTuple15 as a T14.
  306.    *
  307.    * @return The T14 value represented by this object.
  308.    */
  309.   public T14 t14Value()
  310.    {
  311.     return this.object14;
  312.    }


  313.   /**
  314.    * Returns the second value of this NTuple15 as a T15.
  315.    *
  316.    * @return The T15 value represented by this object.
  317.    */
  318.   public T15 t15Value()
  319.    {
  320.     return this.object15;
  321.    }


  322.   /**
  323.    * Calculate hash code.
  324.    *
  325.    * @return Hash
  326.    * @see java.lang.Object#hashCode()
  327.    */
  328.   @Override
  329.   public int hashCode()
  330.    {
  331.     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);
  332.    }


  333.   /**
  334.    * Is equal with another object.
  335.    *
  336.    * @param obj Object
  337.    * @return true when equal, false otherwise
  338.    * @see java.lang.Object#equals(java.lang.Object)
  339.    */
  340.   @Override
  341.   public boolean equals(final Object obj)
  342.    {
  343.     if (this == obj)
  344.      {
  345.       return true;
  346.      }
  347.     if (!(obj instanceof NTuple15))
  348.      {
  349.       return false;
  350.      }
  351.     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;
  352.     boolean result = this.object1.equals(other.object1);
  353.     if (result)
  354.      {

  355.       result = (this.object2 == null) ? (other.object2 == null) : this.object2.equals(other.object2);
  356.       if (result)
  357.        {
  358.         result = (this.object3 == null) ? (other.object3 == null) : this.object3.equals(other.object3);
  359.         if (result)
  360.          {
  361.           result = (this.object4 == null) ? (other.object4 == null) : this.object4.equals(other.object4);
  362.           if (result)
  363.            {
  364.             result = (this.object5 == null) ? (other.object5 == null) : this.object5.equals(other.object5);
  365.             if (result)
  366.              {
  367.               result = (this.object6 == null) ? (other.object6 == null) : this.object6.equals(other.object6);
  368.               if (result)
  369.                {
  370.                 result = (this.object7 == null) ? (other.object7 == null) : this.object7.equals(other.object7);
  371.                 if (result)
  372.                  {
  373.                   result = (this.object8 == null) ? (other.object8 == null) : this.object8.equals(other.object8);
  374.                   if (result)
  375.                    {
  376.                     result = (this.object9 == null) ? (other.object9 == null) : this.object9.equals(other.object9);
  377.                     if (result)
  378.                      {
  379.                       result = (this.object10 == null) ? (other.object10 == null) : this.object10.equals(other.object10);
  380.                       if (result)
  381.                        {
  382.                         result = (this.object11 == null) ? (other.object11 == null) : this.object11.equals(other.object11);
  383.                         if (result)
  384.                          {
  385.                           result = (this.object12 == null) ? (other.object12 == null) : this.object12.equals(other.object12);
  386.                           if (result)
  387.                            {
  388.                             result = (this.object13 == null) ? (other.object13 == null) : this.object13.equals(other.object13);
  389.                             if (result)
  390.                              {
  391.                               result = (this.object14 == null) ? (other.object14 == null) : this.object14.equals(other.object14);
  392.                               if (result)
  393.                                {
  394.                                 result = (this.object15 == null) ? (other.object15 == null) : this.object15.equals(other.object15);
  395.                                }
  396.                              }
  397.                            }
  398.                          }
  399.                        }
  400.                      }
  401.                    }
  402.                  }
  403.                }
  404.              }
  405.            }
  406.          }
  407.        }
  408.      }
  409.     return result;
  410.    }


  411.   /**
  412.    * Returns the string representation of this NTuple15.
  413.    *
  414.    * The exact details of this representation are unspecified and subject to change, but the following may be regarded as typical:
  415.    *
  416.    * "NTuple15[object1=..., object2=..., object3=..., object34=..., object5=..., object6=..., object7=..., object8=..., object9=..., object10=..., object11=..., object12=..., object13=..., object14=..., object15=...]"
  417.    *
  418.    * @return String representation of this NTuple15
  419.    * @see java.lang.Object#toString()
  420.    */
  421.   @Override
  422.   public String toString()
  423.    {
  424.     final var builder = new StringBuilder(164);
  425.     builder.append("NTuple15[object1=").append(this.object1) //$NON-NLS-1$
  426.       .append(", object2=").append(this.object2) //$NON-NLS-1$
  427.       .append(", object3=").append(this.object3) //$NON-NLS-1$
  428.       .append(", object4=").append(this.object4) //$NON-NLS-1$
  429.       .append(", object5=").append(this.object5) //$NON-NLS-1$
  430.       .append(", object6=").append(this.object6) //$NON-NLS-1$
  431.       .append(", object7=").append(this.object7) //$NON-NLS-1$
  432.       .append(", object8=").append(this.object8) //$NON-NLS-1$
  433.       .append(", object9=").append(this.object9) //$NON-NLS-1$
  434.       .append(", object10=").append(this.object10) //$NON-NLS-1$
  435.       .append(", object11=").append(this.object11) //$NON-NLS-1$
  436.       .append(", object12=").append(this.object12) //$NON-NLS-1$
  437.       .append(", object13=").append(this.object13) //$NON-NLS-1$
  438.       .append(", object14=").append(this.object14) //$NON-NLS-1$
  439.       .append(", object15=").append(this.object15) //$NON-NLS-1$
  440.       .append(']');
  441.     return builder.toString();
  442.    }


  443.   /**
  444.    * Compare with another object.
  445.    *
  446.    * @param obj Object to compare with
  447.    * @return 0: equal; 1: greater; -1: smaller
  448.    * @see java.lang.Comparable#compareTo(java.lang.Object)
  449.    */
  450.   @Override
  451.   public int compareTo(final NTuple15<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15> obj)
  452.    {
  453.     Objects.requireNonNull(obj, "obj"); //$NON-NLS-1$
  454.     int result = this.object1.compareTo(obj.object1);
  455.     if (result == 0)
  456.      {
  457.       result = (this.object2 == null) ? ((obj.object2 == null) ? 0 : -1) : ((obj.object2 == null) ? 1 : this.object2.compareTo(obj.object2));
  458.       if (result == 0)
  459.        {
  460.         result = (this.object3 == null) ? ((obj.object3 == null) ? 0 : -1) : ((obj.object3 == null) ? 1 : this.object3.compareTo(obj.object3));
  461.         if (result == 0)
  462.          {
  463.           result = (this.object4 == null) ? ((obj.object4 == null) ? 0 : -1) : ((obj.object4 == null) ? 1 : this.object4.compareTo(obj.object4));
  464.           if (result == 0)
  465.            {
  466.             result = (this.object5 == null) ? ((obj.object5 == null) ? 0 : -1) : ((obj.object5 == null) ? 1 : this.object5.compareTo(obj.object5));
  467.             if (result == 0)
  468.              {
  469.               result = (this.object6 == null) ? ((obj.object6 == null) ? 0 : -1) : ((obj.object6 == null) ? 1 : this.object6.compareTo(obj.object6));
  470.               if (result == 0)
  471.                {
  472.                 result = (this.object7 == null) ? ((obj.object7 == null) ? 0 : -1) : ((obj.object7 == null) ? 1 : this.object7.compareTo(obj.object7));
  473.                 if (result == 0)
  474.                  {
  475.                   result = (this.object8 == null) ? ((obj.object8 == null) ? 0 : -1) : ((obj.object8 == null) ? 1 : this.object8.compareTo(obj.object8));
  476.                   if (result == 0)
  477.                    {
  478.                     result = (this.object9 == null) ? ((obj.object9 == null) ? 0 : -1) : ((obj.object9 == null) ? 1 : this.object9.compareTo(obj.object9));
  479.                     if (result == 0)
  480.                      {
  481.                       result = (this.object10 == null) ? ((obj.object10 == null) ? 0 : -1) : ((obj.object10 == null) ? 1 : this.object10.compareTo(obj.object10));
  482.                       if (result == 0)
  483.                        {
  484.                         result = (this.object11 == null) ? ((obj.object11 == null) ? 0 : -1) : ((obj.object11 == null) ? 1 : this.object11.compareTo(obj.object11));
  485.                         if (result == 0)
  486.                          {
  487.                           result = (this.object12 == null) ? ((obj.object12 == null) ? 0 : -1) : ((obj.object12 == null) ? 1 : this.object12.compareTo(obj.object12));
  488.                           if (result == 0)
  489.                            {
  490.                             result = (this.object13 == null) ? ((obj.object13 == null) ? 0 : -1) : ((obj.object13 == null) ? 1 : this.object13.compareTo(obj.object13));
  491.                             if (result == 0)
  492.                              {
  493.                               result = (this.object14 == null) ? ((obj.object14 == null) ? 0 : -1) : ((obj.object14 == null) ? 1 : this.object14.compareTo(obj.object14));
  494.                               if (result == 0)
  495.                                {
  496.                                 result = (this.object15 == null) ? ((obj.object15 == null) ? 0 : -1) : ((obj.object15 == null) ? 1 : this.object15.compareTo(obj.object15));
  497.                                }
  498.                              }
  499.                            }
  500.                          }
  501.                        }
  502.                      }
  503.                    }
  504.                  }
  505.                }
  506.              }
  507.            }
  508.          }
  509.        }
  510.      }
  511.     return result;
  512.    }

  513.  }