Repository: Hipparchus-Math/hipparchus (java)

Issue:
Make JacobiKey public in PolynomialsUtils
[JacobiKey](https://github.com/Hipparchus-Math/hipparchus/blob/6a43f8559814f3e52cf936d36eeb87a5770bd02f/hipparchus-core/src/main/java/org/hipparchus/analysis/polynomials/PolynomialsUtils.java#L270) is a private inner class of `PolynomialsUtils` class.

I suggest to make it public or extract it in a dedicated class, so that it can be used elsewhere.

See for example [this usage](https://gitlab.orekit.org/orekit/orekit/-/blob/develop/src/main/java/org/orekit/propagation/semianalytical/dsst/utilities/JacobiPolynomials.java?ref_type=heads#L172) in Orekit where the class had to be duplicated.


Pull request description:
#322: Extracted JacobiKey from PolynomialsUtils.
Closes #322

Patch:
diff --git a/hipparchus-core/src/changes/changes.xml b/hipparchus-core/src/changes/changes.xml
index 6628488a5..4f85634ff 100644
--- a/hipparchus-core/src/changes/changes.xml
+++ b/hipparchus-core/src/changes/changes.xml
@@ -50,6 +50,9 @@ If the output is not quite correct, check for invisible trailing spaces!
   </properties>
   <body>
     <release version="3.1" date="TBD" description="TBD.">
+      <action dev="maxime" type="update" issue="issues/322">
+        Extracted class JacobiKey from PolynomialsUtils.
+      </action>
       <action dev="serrof" type="update" issue="issues/302">
         Improved performance of Gradient.
       </action>
diff --git a/hipparchus-core/src/main/java/org/hipparchus/analysis/polynomials/JacobiKey.java b/hipparchus-core/src/main/java/org/hipparchus/analysis/polynomials/JacobiKey.java
new file mode 100644
index 000000000..fb00cbb30
--- /dev/null
+++ b/hipparchus-core/src/main/java/org/hipparchus/analysis/polynomials/JacobiKey.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Hipparchus project under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The Hipparchus project licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.hipparchus.analysis.polynomials;
+
+
+/** Class for handling Jacobi polynomials keys.
+ * @since 3.1
+ */
+public class JacobiKey {
+
+    /** First exponent. */
+    private final int v;
+
+    /** Second exponent. */
+    private final int w;
+
+    /** Simple constructor.
+     * @param v first exponent
+     * @param w second exponent
+     */
+    public JacobiKey(final int v, final int w) {
+        this.v = v;
+        this.w = w;
+    }
+
+    /** Get hash code.
+     * @return hash code
+     */
+    @Override
+    public int hashCode() {
+        return (v << 16) ^ w;
+    }
+
+    /** Check if the instance represent the same key as another instance.
+     * @param key other key
+     * @return true if the instance and the other key refer to the same polynomial
+     */
+    @Override
+    public boolean equals(final Object key) {
+
+        if (!(key instanceof JacobiKey)) {
+            return false;
+        }
+
+        final JacobiKey otherK = (JacobiKey) key;
+        return (v == otherK.v) && (w == otherK.w);
+    }
+}
diff --git a/hipparchus-core/src/main/java/org/hipparchus/analysis/polynomials/PolynomialsUtils.java b/hipparchus-core/src/main/java/org/hipparchus/analysis/polynomials/PolynomialsUtils.java
index 7e2ff461f..9a8213976 100644
--- a/hipparchus-core/src/main/java/org/hipparchus/analysis/polynomials/PolynomialsUtils.java
+++ b/hipparchus-core/src/main/java/org/hipparchus/analysis/polynomials/PolynomialsUtils.java
@@ -266,49 +266,6 @@ public class PolynomialsUtils {
 
     }
 
-    /** Inner class for Jacobi polynomials keys. */
-    private static class JacobiKey {
-
-        /** First exponent. */
-        private final int v;
-
-        /** Second exponent. */
-        private final int w;
-
-        /** Simple constructor.
-         * @param v first exponent
-         * @param w second exponent
-         */
-        JacobiKey(final int v, final int w) {
-            this.v = v;
-            this.w = w;
-        }
-
-        /** Get hash code.
-         * @return hash code
-         */
-        @Override
-        public int hashCode() {
-            return (v << 16) ^ w;
-        }
-
-        /** Check if the instance represent the same key as another instance.
-         * @param key other key
-         * @return true if the instance and the other key refer to the same polynomial
-         */
-        @Override
-        public boolean equals(final Object key) {
-
-            if ((key == null) || !(key instanceof JacobiKey)) {
-                return false;
-            }
-
-            final JacobiKey otherK = (JacobiKey) key;
-            return (v == otherK.v) && (w == otherK.w);
-
-        }
-    }
-
     /**
      * Compute the coefficients of the polynomial \(P_s(x)\)
      * whose values at point {@code x} will be the same as the those from the


Test patch:
diff --git a/hipparchus-core/src/test/java/org/hipparchus/analysis/polynomials/PolynomialsUtilsTest.java b/hipparchus-core/src/test/java/org/hipparchus/analysis/polynomials/PolynomialsUtilsTest.java
index f83af3c67..656146a42 100644
--- a/hipparchus-core/src/test/java/org/hipparchus/analysis/polynomials/PolynomialsUtilsTest.java
+++ b/hipparchus-core/src/test/java/org/hipparchus/analysis/polynomials/PolynomialsUtilsTest.java
@@ -327,6 +327,22 @@ public class PolynomialsUtilsTest {
         }
     }
 
+    /** {@link JacobiKey} coverage tests.
+     * @since 3.1
+     */
+    @Test
+    public void testJacobiKeyCoverage() {
+        
+        final JacobiKey key = new JacobiKey(3, 4);
+        
+        Assert.assertEquals(false, key.equals(null));
+        Assert.assertEquals(false, key.equals(new Object()));
+        Assert.assertEquals(false, key.equals(new JacobiKey(3, 5)));
+        Assert.assertEquals(false, key.equals(new JacobiKey(5, 4)));
+        Assert.assertEquals(false, key.equals(new JacobiKey(5, 5)));
+        Assert.assertEquals(true, key.equals(new JacobiKey(3, 4)));
+    }
+    
     @Test
     public void testShift() {
         // f1(x) = 1 + x + 2 x^2