Repository: commons-numbers Updated Branches: refs/heads/fraction__NUMBERS-6 ffe11d9d8 -> 16352312b
NUMBERS-6: Remove Field classes and references to same Project: http://git-wip-us.apache.org/repos/asf/commons-numbers/repo Commit: http://git-wip-us.apache.org/repos/asf/commons-numbers/commit/16352312 Tree: http://git-wip-us.apache.org/repos/asf/commons-numbers/tree/16352312 Diff: http://git-wip-us.apache.org/repos/asf/commons-numbers/diff/16352312 Branch: refs/heads/fraction__NUMBERS-6 Commit: 16352312bac6661d4facd234f6d00dd4ed37ff58 Parents: ffe11d9 Author: Ray DeCampo <r...@decampo.org> Authored: Thu Feb 2 18:04:19 2017 -0500 Committer: Ray DeCampo <r...@decampo.org> Committed: Thu Feb 2 18:04:19 2017 -0500 ---------------------------------------------------------------------- .../commons/numbers/fraction/BigFraction.java | 6 +- .../numbers/fraction/BigFractionField.java | 82 -------------------- .../commons/numbers/fraction/Fraction.java | 7 +- .../commons/numbers/fraction/FractionField.java | 81 ------------------- .../numbers/fraction/BigFractionFieldTest.java | 43 ---------- .../numbers/fraction/FractionFieldTest.java | 43 ---------- 6 files changed, 2 insertions(+), 260 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/16352312/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/BigFraction.java ---------------------------------------------------------------------- diff --git a/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/BigFraction.java b/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/BigFraction.java index 9d653b1..eae82ea 100644 --- a/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/BigFraction.java +++ b/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/BigFraction.java @@ -27,7 +27,7 @@ import org.apache.commons.numbers.core.ArithmeticUtils; */ public class BigFraction extends Number - implements /*FieldElement<BigFraction>, */Comparable<BigFraction>, Serializable { + implements Comparable<BigFraction>, Serializable { /** A fraction representing "2 / 1". */ public static final BigFraction TWO = new BigFraction(2); @@ -1179,10 +1179,6 @@ public class BigFraction return str; } - public BigFractionField getField() { - return BigFractionField.getInstance(); - } - private static void checkNotNull(Object arg, String argName) { if (arg == null) { throw new NullPointerException(argName); http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/16352312/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/BigFractionField.java ---------------------------------------------------------------------- diff --git a/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/BigFractionField.java b/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/BigFractionField.java deleted file mode 100644 index 7430eaa..0000000 --- a/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/BigFractionField.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF 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 - * - * http://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.apache.commons.numbers.fraction; - -import java.io.Serializable; - - -/** - * Representation of the fractional numbers without any overflow field. - * <p> - * This class is a singleton. - * </p> - * @see Fraction - */ -public class BigFractionField implements /*Field<BigFraction>, */Serializable { - - /** Serializable version identifier */ - private static final long serialVersionUID = -1699294557189741703L; - - /** Private constructor for the singleton. - */ - private BigFractionField() { - } - - /** Get the unique instance. - * @return the unique instance - */ - public static BigFractionField getInstance() { - return LazyHolder.INSTANCE; - } - - /** {@inheritDoc} */ - public BigFraction getOne() { - return BigFraction.ONE; - } - - /** {@inheritDoc} */ - public BigFraction getZero() { - return BigFraction.ZERO; - } - - /** {@inheritDoc} */ -/* - @Override - public Class<? extends FieldElement<BigFraction>> getRuntimeClass() { - return BigFraction.class; - } -*/ - // CHECKSTYLE: stop HideUtilityClassConstructor - /** Holder for the instance. - * <p>We use here the Initialization On Demand Holder Idiom.</p> - */ - private static class LazyHolder { - /** Cached field instance. */ - private static final BigFractionField INSTANCE = new BigFractionField(); - } - // CHECKSTYLE: resume HideUtilityClassConstructor - - /** Handle deserialization of the singleton. - * @return the singleton instance - */ - private Object readResolve() { - // return the singleton instance - return LazyHolder.INSTANCE; - } - -} http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/16352312/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/Fraction.java ---------------------------------------------------------------------- diff --git a/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/Fraction.java b/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/Fraction.java index 1697d8d..93c84fa 100644 --- a/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/Fraction.java +++ b/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/Fraction.java @@ -27,7 +27,7 @@ import org.apache.commons.numbers.core.ArithmeticUtils; */ public class Fraction extends Number - implements /*FieldElement<Fraction>,*/ Comparable<Fraction>, Serializable { + implements Comparable<Fraction>, Serializable { /** A fraction representing "2 / 1". */ public static final Fraction TWO = new Fraction(2, 1); @@ -650,9 +650,4 @@ public class Fraction } return str; } - - /** {@inheritDoc} */ - public FractionField getField() { - return FractionField.getInstance(); - } } http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/16352312/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/FractionField.java ---------------------------------------------------------------------- diff --git a/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/FractionField.java b/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/FractionField.java deleted file mode 100644 index 58a3d68..0000000 --- a/commons-numbers-fraction/src/main/java/org/apache/commons/numbers/fraction/FractionField.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF 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 - * - * http://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.apache.commons.numbers.fraction; - -import java.io.Serializable; - -/** - * Representation of the fractional numbers field. - * <p> - * This class is a singleton. - * </p> - * @see Fraction - */ -public class FractionField implements /*Field<Fraction>, */Serializable { - - /** Serializable version identifier */ - private static final long serialVersionUID = -1257768487499119313L; - - /** Private constructor for the singleton. - */ - private FractionField() { - } - - /** Get the unique instance. - * @return the unique instance - */ - public static FractionField getInstance() { - return LazyHolder.INSTANCE; - } - - /** {@inheritDoc} */ - public Fraction getOne() { - return Fraction.ONE; - } - - /** {@inheritDoc} */ - public Fraction getZero() { - return Fraction.ZERO; - } - - /** {@inheritDoc} */ -/* - @Override - public Class<? extends FieldElement<Fraction>> getRuntimeClass() { - return Fraction.class; - } -*/ - // CHECKSTYLE: stop HideUtilityClassConstructor - /** Holder for the instance. - * <p>We use here the Initialization On Demand Holder Idiom.</p> - */ - private static class LazyHolder { - /** Cached field instance. */ - private static final FractionField INSTANCE = new FractionField(); - } - // CHECKSTYLE: resume HideUtilityClassConstructor - - /** Handle deserialization of the singleton. - * @return the singleton instance - */ - private Object readResolve() { - // return the singleton instance - return LazyHolder.INSTANCE; - } - -} http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/16352312/commons-numbers-fraction/src/test/java/org/apache/commons/numbers/fraction/BigFractionFieldTest.java ---------------------------------------------------------------------- diff --git a/commons-numbers-fraction/src/test/java/org/apache/commons/numbers/fraction/BigFractionFieldTest.java b/commons-numbers-fraction/src/test/java/org/apache/commons/numbers/fraction/BigFractionFieldTest.java deleted file mode 100644 index 53f1dee..0000000 --- a/commons-numbers-fraction/src/test/java/org/apache/commons/numbers/fraction/BigFractionFieldTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF 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 - * - * http://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.apache.commons.numbers.fraction; - - -import org.apache.commons.numbers.core.TestUtils; -import org.junit.Assert; -import org.junit.Test; - -public class BigFractionFieldTest { - - @Test - public void testZero() { - Assert.assertEquals(BigFraction.ZERO, BigFractionField.getInstance().getZero()); - } - - @Test - public void testOne() { - Assert.assertEquals(BigFraction.ONE, BigFractionField.getInstance().getOne()); - } - - @Test - public void testSerial() { - // deserializing the singleton should give the singleton itself back - BigFractionField field = BigFractionField.getInstance(); - Assert.assertTrue(field == TestUtils.serializeAndRecover(field)); - } - -} http://git-wip-us.apache.org/repos/asf/commons-numbers/blob/16352312/commons-numbers-fraction/src/test/java/org/apache/commons/numbers/fraction/FractionFieldTest.java ---------------------------------------------------------------------- diff --git a/commons-numbers-fraction/src/test/java/org/apache/commons/numbers/fraction/FractionFieldTest.java b/commons-numbers-fraction/src/test/java/org/apache/commons/numbers/fraction/FractionFieldTest.java deleted file mode 100644 index f33209a..0000000 --- a/commons-numbers-fraction/src/test/java/org/apache/commons/numbers/fraction/FractionFieldTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF 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 - * - * http://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.apache.commons.numbers.fraction; - - -import org.apache.commons.numbers.core.TestUtils; -import org.junit.Assert; -import org.junit.Test; - -public class FractionFieldTest { - - @Test - public void testZero() { - Assert.assertEquals(Fraction.ZERO, FractionField.getInstance().getZero()); - } - - @Test - public void testOne() { - Assert.assertEquals(Fraction.ONE, FractionField.getInstance().getOne()); - } - - @Test - public void testSerial() { - // deserializing the singleton should give the singleton itself back - FractionField field = FractionField.getInstance(); - Assert.assertTrue(field == TestUtils.serializeAndRecover(field)); - } - -}