/** * Constructs from a Factor and an exponent. * * @param factor * The factor. * @param exponent * The exponent. */ public Factor(final Factor factor, final int exponent) { this(factor.getBase(), exponent); }
/** * Constructs from a Factor and an exponent. * * @param factor * The factor. * @param exponent * The exponent. */ public Factor(final Factor factor, final int exponent) { this(factor.getBase(), exponent); }
/** * Returns the identifier of the Base entity. * * @return The identifier of the Base entity (symbol or name). */ public String getID() { return getBase().getID(); }
/** * Returns the identifier of the Base entity. * * @return The identifier of the Base entity (symbol or name). */ public String getID() { return getBase().getID(); }
/** * Indicates if this Factor is the reciprocal of another Factor. * * @param that * The other factor. * @return <code>true</code> if and only if this Factor is the reciprocal of * <code>that</code>. */ public boolean isReciprocalOf(final Factor that) { return getBase().equals(that.getBase()) && getExponent() == -that.getExponent(); }
/** * Returns the hash code of this instance. * * @return The hash code of this instance. */ @Override public int hashCode() { return getExponent() == 0 ? getClass().hashCode() : getExponent() ^ getBase().hashCode(); }
/** * Returns the hash code of this instance. * * @return The hash code of this instance. */ @Override public int hashCode() { return getExponent() == 0 ? getClass().hashCode() : getExponent() ^ getBase().hashCode(); }
/** * Indicates if this Factor is the reciprocal of another Factor. * * @param that * The other factor. * @return <code>true</code> if and only if this Factor is the reciprocal of * <code>that</code>. */ public boolean isReciprocalOf(final Factor that) { return getBase().equals(that.getBase()) && getExponent() == -that.getExponent(); }
private boolean isUnknownUnit(ucar.units.DerivedUnit du) { UnitDimension dim = du.getDimension(); for (Factor f : dim.getFactors()) { if (f.getBase() instanceof ucar.units.UnknownUnit) return true; } return false; }
private boolean isUnknownUnit(ucar.units.DerivedUnit du) { UnitDimension dim = du.getDimension(); for (Factor f : dim.getFactors()) { if (f.getBase() instanceof ucar.units.UnknownUnit) return true; } return false; }
/** * Raises this Factor to a power. * * @param power * The power by which to raise this Factor. * @return The Factor resulting from raising this Factor to the given power. */ public Factor pow(final int power) { return new Factor(getBase(), getExponent() * power); }
/** * Indicates if this factor is dimensionless. A Factor is dimensionless if * and only if the exponent is zero or the Base entity is dimensionless. * * @return <code>true</code> if and only if this Factor is dimensionless. */ public boolean isDimensionless() { return getExponent() == 0 || getBase().isDimensionless(); } }
/** * Raises this Factor to a power. * * @param power * The power by which to raise this Factor. * @return The Factor resulting from raising this Factor to the given power. */ public Factor pow(final int power) { return new Factor(getBase(), getExponent() * power); }
private boolean isUnknownUnit(ucar.units.DerivedUnit du) { UnitDimension dim = du.getDimension(); for (Factor f : dim.getFactors()) { if (f.getBase() instanceof ucar.units.UnknownUnit) return true; } return false; }
/** * Indicates if this factor is dimensionless. A Factor is dimensionless if * and only if the exponent is zero or the Base entity is dimensionless. * * @return <code>true</code> if and only if this Factor is dimensionless. */ public boolean isDimensionless() { return getExponent() == 0 || getBase().isDimensionless(); } }
/** * Indicates if this Factor is semantically identical to another object. * * @param object * The object. * @return <code>true</code> if and only if this Factor is semantically * identical to <code>object< * /code>. */ @Override public boolean equals(final Object object) { boolean equals; if (this == object) { equals = true; } else if (!(object instanceof Factor)) { equals = false; } else { final Factor that = (Factor) object; equals = getExponent() != that.getExponent() ? false : getExponent() == 0 || getBase().equals(that.getBase()); } return equals; }
/** * Returns the corresponding quantity dimension. * @return The quantity dimension corresponding to this * unit dimension. */ public QuantityDimension getQuantityDimension() { Factor[] factors = getFactors(); for (int i = factors.length; --i >= 0; ) { Factor factor = factors[i]; factors[i] = new Factor( ((BaseUnit)factor.getBase()).getBaseQuantity(), factor.getExponent()); } return new QuantityDimension(factors); }
/** * Returns the corresponding quantity dimension. * @return The quantity dimension corresponding to this * unit dimension. */ public QuantityDimension getQuantityDimension() { Factor[] factors = getFactors(); for (int i = factors.length; --i >= 0; ) { Factor factor = factors[i]; factors[i] = new Factor( ((BaseUnit)factor.getBase()).getBaseQuantity(), factor.getExponent()); } return new QuantityDimension(factors); }