org.decimal4j.factory.Factory7f Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of decimal4j Show documentation
Show all versions of decimal4j Show documentation
Java library for fast fixed precision arithmetics based on longs with support for up to 18 decimal places.
/**
* The MIT License (MIT)
*
* Copyright (c) 2015 decimal4j (tools4j), Marco Terzer
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.decimal4j.factory;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
import org.decimal4j.api.Decimal;
import org.decimal4j.immutable.Decimal7f;
import org.decimal4j.mutable.MutableDecimal7f;
import org.decimal4j.scale.Scale7f;
import org.decimal4j.scale.ScaleMetrics;
/**
* The factory for decimals with scale 7 creating {@link Decimal7f} and
* {@link MutableDecimal7f} instances.
*/
public enum Factory7f implements DecimalFactory {
/**
* Singleton factory instance for immutable and mutable decimals with scale 7.
*/
INSTANCE;
@Override
public final Scale7f getScaleMetrics() {
return Scale7f.INSTANCE;
}
@Override
public final int getScale() {
return Scale7f.SCALE;
}
@Override
public final Class immutableType() {
return Decimal7f.class;
}
@Override
public final Class mutableType() {
return MutableDecimal7f.class;
}
@Override
public final DecimalFactory> deriveFactory(int scale) {
return Factories.getDecimalFactory(scale);
}
@Override
public final DecimalFactory deriveFactory(S scaleMetrics) {
return Factories.getDecimalFactory(scaleMetrics);
}
@Override
public final Decimal7f valueOf(long value) {
return Decimal7f.valueOf(value);
}
@Override
public final Decimal7f valueOf(float value) {
return Decimal7f.valueOf(value);
}
@Override
public final Decimal7f valueOf(float value, RoundingMode roundingMode) {
return Decimal7f.valueOf(value, roundingMode);
}
@Override
public final Decimal7f valueOf(double value) {
return Decimal7f.valueOf(value);
}
@Override
public final Decimal7f valueOf(double value, RoundingMode roundingMode) {
return Decimal7f.valueOf(value, roundingMode);
}
@Override
public final Decimal7f valueOf(BigInteger value) {
return Decimal7f.valueOf(value);
}
@Override
public final Decimal7f valueOf(BigDecimal value) {
return Decimal7f.valueOf(value);
}
@Override
public final Decimal7f valueOf(BigDecimal value, RoundingMode roundingMode) {
return Decimal7f.valueOf(value, roundingMode);
}
@Override
public final Decimal7f valueOf(Decimal> value) {
return Decimal7f.valueOf(value);
}
@Override
public final Decimal7f valueOf(Decimal> value, RoundingMode roundingMode) {
return Decimal7f.valueOf(value, roundingMode);
}
@Override
public final Decimal7f parse(String value) {
return Decimal7f.valueOf(value);
}
@Override
public final Decimal7f parse(String value, RoundingMode roundingMode) {
return Decimal7f.valueOf(value, roundingMode);
}
@Override
public final Decimal7f valueOfUnscaled(long unscaledValue) {
return Decimal7f.valueOfUnscaled(unscaledValue);
}
@Override
public final Decimal7f valueOfUnscaled(long unscaledValue, int scale) {
return Decimal7f.valueOfUnscaled(unscaledValue, scale);
}
@Override
public final Decimal7f valueOfUnscaled(long unscaledValue, int scale, RoundingMode roundingMode) {
return Decimal7f.valueOfUnscaled(unscaledValue, scale, roundingMode);
}
@Override
public final Decimal7f[] newArray(int length) {
return new Decimal7f[length];
}
@Override
public final MutableDecimal7f newMutable() {
return new MutableDecimal7f();
}
@Override
public final MutableDecimal7f[] newMutableArray(int length) {
return new MutableDecimal7f[length];
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy