diff --git a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/config/builder/UnitXCTypeCompoundExponentBuilder.java b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/config/builder/UnitXCTypeCompoundExponentBuilder.java index 5162a5b..1d0fefb 100644 --- a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/config/builder/UnitXCTypeCompoundExponentBuilder.java +++ b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/config/builder/UnitXCTypeCompoundExponentBuilder.java @@ -49,6 +49,7 @@ public class UnitXCTypeCompoundExponentBuilder extends AbstractUnitXCBuilder {}); this.unitGroupId = unitGroupId; this.exponent = exponent; + UnitXCGroup model = parent.getValue(); parent.getValue().setTypeGenerator(new UnitXCTypeGenerator() { UnitXCGroup getGroup() { @@ -82,8 +83,24 @@ public class UnitXCTypeCompoundExponentBuilder extends AbstractUnitXCBuilder parameters) { + Validate.notNull(valueConvert2,"Can't convert null to number"); + Validate.notNull(fromType,"Can't convert from null unit type"); + Validate.notNull(toType,"Can't convert to null unit type"); + + + if (fromType.getAliasOfType() != null) { + fromType = Validate.notNull(manager.getUnitType(fromType.getAliasOfType()),"Coultn't resolve alias id: "+fromType.getAliasOfType()+" for: "+fromType.getId()); + } + if (toType.getAliasOfType() != null) { + toType = Validate.notNull(manager.getUnitType(toType.getAliasOfType()),"Coultn't resolve alias id: "+toType.getAliasOfType()+" for: "+toType.getId()); + } + double valueConvert = valueConvert2.doubleValue(); long startTime = System.currentTimeMillis(); MathContext mathContext = MathContext.DECIMAL128; @@ -178,7 +190,7 @@ public final class UnitXConverterEngine { step.runStep(this); long convertTime = System.currentTimeMillis()-startTime; - System.out.println("runStep: "+step+" res: "+step.getStepReasons()); +// System.out.println("runStep: "+step+" res: "+step.getStepReasons()); UnitXConverterResultStep resultStep = new UnitXConverterResultStep(); resultStep.setStartValue(valueOld); diff --git a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueNamedParameter.java b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueNamedParameter.java index 423cf4a..6c52411 100644 --- a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueNamedParameter.java +++ b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueNamedParameter.java @@ -52,13 +52,6 @@ public class UnitXConverterStepValueNamedParameter implements UnitXConverterStep return ctx.getNamedParameter(parameterName).valueRead(ctx); } - @Override - public UnitXConverterStepValueRead clone() { - UnitXConverterStepValueNamedParameter clone = new UnitXConverterStepValueNamedParameter(); - clone.setParameterName(getParameterName()); - return clone; - } - /** * @return the parameterName */ diff --git a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueNamedVariable.java b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueNamedVariable.java index 91e030f..9c7bdd4 100644 --- a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueNamedVariable.java +++ b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueNamedVariable.java @@ -58,14 +58,6 @@ public class UnitXConverterStepValueNamedVariable implements UnitXConverterStepV public void valueWrite(UnitXConverterStepContext ctx,Object value) { ctx.getNamedVariable(variableName).valueWrite(ctx,value); } - - @Override - public UnitXConverterStepValueReadWrite clone() { - UnitXConverterStepValueNamedVariable clone = new UnitXConverterStepValueNamedVariable(); - clone.setValueType(getValueType()); - clone.setVariableName(getVariableName()); - return clone; - } /** * @return the variableName diff --git a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueRead.java b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueRead.java index 9b7ceda..5e9964a 100644 --- a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueRead.java +++ b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueRead.java @@ -31,9 +31,7 @@ import net.forwardfire.unitxc.model.step.UnitXConverterStepContext; * @author Willem Cazander * @version 1.0 Apr 1, 2016 */ -public interface UnitXConverterStepValueRead extends Cloneable { +public interface UnitXConverterStepValueRead { Object valueRead(UnitXConverterStepContext ctx); - - UnitXConverterStepValueRead clone(); } diff --git a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueReadWrite.java b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueReadWrite.java index 31270a6..84edff3 100644 --- a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueReadWrite.java +++ b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueReadWrite.java @@ -34,6 +34,4 @@ import net.forwardfire.unitxc.model.step.UnitXConverterStepContext; public interface UnitXConverterStepValueReadWrite extends UnitXConverterStepValueRead { void valueWrite(UnitXConverterStepContext ctx,Object value); - - UnitXConverterStepValueReadWrite clone(); } diff --git a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueReferenceDouble.java b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueReferenceDouble.java index a529dfb..1aebf49 100644 --- a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueReferenceDouble.java +++ b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueReferenceDouble.java @@ -57,11 +57,6 @@ public class UnitXConverterStepValueReferenceDouble implements UnitXConverterSte this.value = Double.class.cast(value); } - @Override - public UnitXConverterStepValueReadWrite clone() { - return new UnitXConverterStepValueReferenceDouble(getValue()); - } - /** * @return the value */ diff --git a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueReferenceDoubleFraction.java b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueReferenceDoubleFraction.java index 29bd1d0..0988454 100644 --- a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueReferenceDoubleFraction.java +++ b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueReferenceDoubleFraction.java @@ -57,11 +57,6 @@ public class UnitXConverterStepValueReferenceDoubleFraction implements UnitXConv return (Double)(((Integer)numerator).doubleValue()/((Integer)denominator).doubleValue()); // FIXME } - @Override - public UnitXConverterStepValueRead clone() { - return new UnitXConverterStepValueReferenceDoubleFraction(getNumerator(),getDenominator()); - } - /** * @return the numerator */ diff --git a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueReferenceInteger.java b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueReferenceInteger.java index 52f1c8c..e4631da 100644 --- a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueReferenceInteger.java +++ b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueReferenceInteger.java @@ -57,11 +57,6 @@ public class UnitXConverterStepValueReferenceInteger implements UnitXConverterSt this.value = Integer.class.cast(value); } - @Override - public UnitXConverterStepValueReadWrite clone() { - return new UnitXConverterStepValueReferenceInteger(getValue()); - } - /** * @return the value */ diff --git a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueReferenceString.java b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueReferenceString.java index d3115a7..a1a6d81 100644 --- a/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueReferenceString.java +++ b/ff-unitxc-converter/src/main/java/net/forwardfire/unitxc/model/step/value/UnitXConverterStepValueReferenceString.java @@ -57,11 +57,6 @@ public class UnitXConverterStepValueReferenceString implements UnitXConverterSte this.value = String.class.cast(value); } - @Override - public UnitXConverterStepValueReadWrite clone() { - return new UnitXConverterStepValueReferenceString(getValue()); - } - /** * @return the value */ diff --git a/ff-unitxc-converter/src/test/java/net/forwardfire/unitxc/UnitXCManagerTest.java b/ff-unitxc-converter/src/test/java/net/forwardfire/unitxc/UnitXCManagerTest.java index 387a751..32e062a 100644 --- a/ff-unitxc-converter/src/test/java/net/forwardfire/unitxc/UnitXCManagerTest.java +++ b/ff-unitxc-converter/src/test/java/net/forwardfire/unitxc/UnitXCManagerTest.java @@ -1,6 +1,7 @@ package net.forwardfire.unitxc; import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertFalse; @@ -27,9 +28,9 @@ public class UnitXCManagerTest { assertNotNull(test.getUnitType(null)); } - @Test(expected=NullPointerException.class) + @Test public void testGetUnitTypeInvalid() { - assertNotNull(test.getUnitType(getClass().getName())); + assertNull(test.getUnitType(getClass().getName())); } @Test