Package com.barchart.util.values.provider

Source Code of com.barchart.util.values.provider.BaseDecimal

/**
* Copyright (C) 2011-2013 Barchart, Inc. <http://www.barchart.com/>
*
* All rights reserved. Licensed under the OSI BSD License.
*
* http://www.opensource.org/licenses/bsd-license.php
*/
package com.barchart.util.values.provider;

import static com.barchart.util.values.provider.ValueBuilder.*;
import static com.barchart.util.values.provider.ValueConst.*;

import com.barchart.util.anno.NotMutable;
import com.barchart.util.values.api.DecimalValue;
import com.barchart.util.values.lang.ScaledDecimalValue;

@NotMutable
abstract class BaseDecimal extends
    ScaledDecimalValue<DecimalValue, DecimalValue> implements DecimalValue {

  @Override
  protected DecimalValue result(final long mantissa, final int exponent) {
    return newDecimal(mantissa, exponent);
  }

  @Override
  public final boolean isNull() {
    return this == NULL_DECIMAL;
  }

  @Override
  public final boolean equals(final Object thatValue) {
    if (thatValue instanceof DecimalValue) {
      DecimalValue that = (DecimalValue) thatValue;
      return this.compareTo(that) == 0;
    }
    return false;
  }
 
  @Override
  public final double asDouble() {
    return mantissa() * Math.pow(10, exponent());
  }

}
TOP

Related Classes of com.barchart.util.values.provider.BaseDecimal

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.