Binary64Field.java

  1. /*
  2.  * Licensed to the Apache Software Foundation (ASF) under one or more
  3.  * contributor license agreements.  See the NOTICE file distributed with
  4.  * this work for additional information regarding copyright ownership.
  5.  * The ASF licenses this file to You under the Apache License, Version 2.0
  6.  * (the "License"); you may not use this file except in compliance with
  7.  * the License.  You may obtain a copy of the License at
  8.  *
  9.  *      https://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */

  17. /*
  18.  * This is not the original file distributed by the Apache Software Foundation
  19.  * It has been modified by the Hipparchus project
  20.  */
  21. package org.hipparchus.util;

  22. import java.io.Serializable;

  23. import org.hipparchus.Field;

  24. /**
  25.  * The field of {@link Binary64 double precision floating-point numbers}.
  26.  *
  27.  * @see Binary64
  28.  */
  29. public class Binary64Field implements Field<Binary64>, Serializable {

  30.     /** Serializable version identifier */
  31.     private static final long serialVersionUID = 20161219L;

  32.     /** Default constructor. */
  33.     private Binary64Field() {
  34.         // Do nothing
  35.     }

  36.     /**
  37.      * Returns the unique instance of this class.
  38.      *
  39.      * @return the unique instance of this class
  40.      */
  41.     public static Binary64Field getInstance() {
  42.         return LazyHolder.INSTANCE;
  43.     }

  44.     /** {@inheritDoc} */
  45.     @Override
  46.     public Binary64 getZero() {
  47.         return Binary64.ZERO;
  48.     }

  49.     /** {@inheritDoc} */
  50.     @Override
  51.     public Binary64 getOne() {
  52.         return Binary64.ONE;
  53.     }

  54.     /** {@inheritDoc} */
  55.     @Override
  56.     public Class<Binary64> getRuntimeClass() {
  57.         return Binary64.class;
  58.     }

  59.     /** {@inheritDoc} */
  60.     @Override
  61.     public boolean equals(final Object other) {
  62.         return this == other;
  63.     }

  64.     /** {@inheritDoc} */
  65.     @Override
  66.     public int hashCode() {
  67.         return 0x0a04d2bf;
  68.     }

  69.     // CHECKSTYLE: stop HideUtilityClassConstructor
  70.     /** Holder for the instance.
  71.      * <p>We use here the Initialization On Demand Holder Idiom.</p>
  72.      */
  73.     private static class LazyHolder {
  74.         /** Cached field instance. */
  75.         private static final Binary64Field INSTANCE = new Binary64Field();
  76.     }
  77.     // CHECKSTYLE: resume HideUtilityClassConstructor

  78.     /** Handle deserialization of the singleton.
  79.      * @return the singleton instance
  80.      */
  81.     private Object readResolve() {
  82.         // return the singleton instance
  83.         return LazyHolder.INSTANCE;
  84.     }

  85. }