
de.tsl2.nano.util.operation.OperableUnit Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tsl2.nano.operation Show documentation
Show all versions of tsl2.nano.operation Show documentation
TSL2 Framework Operation (abstract parser, conditioned functional or boolean operations - abstract structure for rule-engines)
/*
* File: $HeadURL$
* Id : $Id$
*
* created by: Thomas Schneider
* created on: Jul 20, 2012
*
* Copyright: (c) Thomas Schneider 2012, all rights reserved
*/
package de.tsl2.nano.util.operation;
/**
* usable to compare values with defined units. f.e., a bigdecimal working as currency.
*
* @author Thomas Schneider
* @version $Revision$
*/
public class OperableUnit, U> extends Operable implements IUnit {
/**
* constructor
*
* @param value
* @param converter
*/
public OperableUnit(T value, IConvertableUnit converter) {
super(value, converter);
}
/**
* {@inheritDoc}
*/
@Override
public U getUnit() {
return ((IConvertableUnit)converter).getUnit();
}
/**
* converts the own value to the given operableunit.
*
* @param convertableUnit new unit, to convert the own value to
* @return converted value
*/
public , U1> OperableUnit convert(IConvertableUnit convertableUnit) {
return new OperableUnit(convertableUnit.from(converter.to(value)), convertableUnit);
}
/**
* {@inheritDoc}
*/
@Override
public String toString() {
return getConversion() + " " + getUnit();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy