ASSIGNED - bug 422300: Make all quantity amounts implement quantity type
https://bugs.eclipse.org/bugs/show_bug.cgi?id=422300
diff --git a/bundles/org.eclipse.uomo.core/src/main/java/org/eclipse/uomo/core/ICode.java b/bundles/org.eclipse.uomo.core/src/main/java/org/eclipse/uomo/core/ICode.java
index 0be2260..ac578e0 100644
--- a/bundles/org.eclipse.uomo.core/src/main/java/org/eclipse/uomo/core/ICode.java
+++ b/bundles/org.eclipse.uomo.core/src/main/java/org/eclipse/uomo/core/ICode.java
@@ -1,5 +1,5 @@
/******************************************************************************
- * Copyright (c) 1996, 2010, Werner Keil, Creative Arts & Technologies.
+ * Copyright (c) 1996, 2014, Werner Keil, Creative Arts & Technologies.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -17,6 +17,6 @@
* @version $Id: ICode.java 63 2010-07-19 10:35:31Z werner.keil $
* @author <a href="mailto:uomo@catmedia.us">Werner Keil</a>
*/
-public interface ICode {
- String getCode();
+public interface ICode<C> {
+ C getCode();
}
\ No newline at end of file
diff --git a/bundles/org.eclipse.uomo.core/src/main/java/org/eclipse/uomo/core/INumericValue.java b/bundles/org.eclipse.uomo.core/src/main/java/org/eclipse/uomo/core/IValue.java
similarity index 77%
rename from bundles/org.eclipse.uomo.core/src/main/java/org/eclipse/uomo/core/INumericValue.java
rename to bundles/org.eclipse.uomo.core/src/main/java/org/eclipse/uomo/core/IValue.java
index e6fbc89..98de649 100644
--- a/bundles/org.eclipse.uomo.core/src/main/java/org/eclipse/uomo/core/INumericValue.java
+++ b/bundles/org.eclipse.uomo.core/src/main/java/org/eclipse/uomo/core/IValue.java
@@ -1,5 +1,5 @@
/******************************************************************************
- * Copyright (c) 2011, 2013 Werner Keil, Creative Arts & Technologies.
+ * Copyright (c) 2011, 2014 Werner Keil, Creative Arts & Technologies.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -12,11 +12,11 @@
package org.eclipse.uomo.core;
/**
- * Denote entity that has a numeric value.
+ * Denote entity that has a {@code V} value.
*
- * @version 0.2
+ * @version 0.3
* @author <a href="mailto:uomo@catmedia.us">Werner Keil</a>
*/
-public interface INumericValue {
- Number getValue();
+public interface IValue<V> {
+ V getValue();
}
\ No newline at end of file
diff --git a/bundles/org.eclipse.uomo.core/src/main/java/org/eclipse/uomo/core/impl/Pair.java b/bundles/org.eclipse.uomo.core/src/main/java/org/eclipse/uomo/core/impl/CodeValuePair.java
similarity index 78%
rename from bundles/org.eclipse.uomo.core/src/main/java/org/eclipse/uomo/core/impl/Pair.java
rename to bundles/org.eclipse.uomo.core/src/main/java/org/eclipse/uomo/core/impl/CodeValuePair.java
index 1dee3c4..7f8669a 100644
--- a/bundles/org.eclipse.uomo.core/src/main/java/org/eclipse/uomo/core/impl/Pair.java
+++ b/bundles/org.eclipse.uomo.core/src/main/java/org/eclipse/uomo/core/impl/CodeValuePair.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Crown Copyright (c) 2006, 2013, Copyright (c) 2006, 2007 Jiva Medical.
+ * Crown Copyright (c) 2006, 2014, Copyright (c) 2006, 2007 Jiva Medical.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -11,13 +11,16 @@
package org.eclipse.uomo.core.impl;
+import org.eclipse.uomo.core.ICode;
+import org.eclipse.uomo.core.IValue;
+
/**
* @author Werner Keil
*
* @param <V>
* @param <C>
*/
-public class Pair<V, C> {
+public class CodeValuePair<V, C> implements ICode<C>, IValue<V> {
private V value;
private C code;
@@ -25,7 +28,7 @@
* @param value
* @param code
*/
- public Pair(V value, C code) {
+ public CodeValuePair(V value, C code) {
super();
this.value = value;
this.code = code;
diff --git a/bundles/org.eclipse.uomo.ucum/src/main/java/org/eclipse/uomo/ucum/UcumService.java b/bundles/org.eclipse.uomo.ucum/src/main/java/org/eclipse/uomo/ucum/UcumService.java
index d9366b2..1d9b0fa 100644
--- a/bundles/org.eclipse.uomo.ucum/src/main/java/org/eclipse/uomo/ucum/UcumService.java
+++ b/bundles/org.eclipse.uomo.ucum/src/main/java/org/eclipse/uomo/ucum/UcumService.java
@@ -15,7 +15,7 @@
import java.util.List;
import java.util.Set;
-import org.eclipse.uomo.core.impl.Pair;
+import org.eclipse.uomo.core.impl.CodeValuePair;
import org.eclipse.uomo.core.IVersion;
import org.eclipse.uomo.core.UOMoRuntimeException;
import org.eclipse.uomo.ucum.model.Concept;
@@ -171,7 +171,7 @@
* @return
* @throws UOMoRuntimeException
*/
- public Pair<Number, String> getCanonicalForm(Pair<Number, String> value) throws UOMoRuntimeException;
+ public CodeValuePair<Number, String> getCanonicalForm(CodeValuePair<Number, String> value) throws UOMoRuntimeException;
/**
* given a value and source unit, return the value in the given dest unit
@@ -193,6 +193,6 @@
* @param o2
* @return
*/
- public Pair<Number, String> multiply(Pair<Number, String> o1, Pair<Number, String> o2);
+ public CodeValuePair<Number, String> multiply(CodeValuePair<Number, String> o1, CodeValuePair<Number, String> o2);
}
diff --git a/bundles/org.eclipse.uomo.ucum/src/main/java/org/eclipse/uomo/ucum/impl/UcumEssenceService.java b/bundles/org.eclipse.uomo.ucum/src/main/java/org/eclipse/uomo/ucum/impl/UcumEssenceService.java
index 14f4c7a..3305d2a 100644
--- a/bundles/org.eclipse.uomo.ucum/src/main/java/org/eclipse/uomo/ucum/impl/UcumEssenceService.java
+++ b/bundles/org.eclipse.uomo.ucum/src/main/java/org/eclipse/uomo/ucum/impl/UcumEssenceService.java
@@ -24,7 +24,7 @@
import java.util.Set;
import org.eclipse.uomo.core.UOMoRuntimeException;
-import org.eclipse.uomo.core.impl.Pair;
+import org.eclipse.uomo.core.impl.CodeValuePair;
import org.eclipse.uomo.ucum.UcumService;
import org.eclipse.uomo.ucum.expression.Symbol;
import org.eclipse.uomo.ucum.expression.Term;
@@ -304,7 +304,7 @@
* org.eclipse.ohf.ucum.UcumServiceEx#getCanonicalForm(org.eclipse.ohf.ucum
* .UcumEssenceService.Pair)
*/
- public Pair<Number, String> getCanonicalForm(Pair<Number, String> value)
+ public CodeValuePair<Number, String> getCanonicalForm(CodeValuePair<Number, String> value)
throws UOMoRuntimeException {
assert value != null : paramError("getCanonicalForm", "value",
"must not be null");
@@ -314,10 +314,10 @@
Term term = new ExpressionParser(model).parse(value.getCode());
Canonical c = new UcumConverter(model, handlers).convert(term);
if (value.getValue() == null)
- return new Pair<Number, String>(null,
+ return new CodeValuePair<Number, String>(null,
new ExpressionComposer().compose(c.getUnit()));
else
- return new Pair<Number, String>(
+ return new CodeValuePair<Number, String>(
((BigDecimal) value.getValue()).multiply(c.getValue()),
new ExpressionComposer().compose(c.getUnit()));
}
@@ -352,20 +352,21 @@
+ " as they do not have matching canonical forms (" + s
+ " and " + d + " respectively)");
final BigDecimal decValue = (BigDecimal) value;
- BigDecimal canValue = decValue.multiply(src.getValue());
+ final BigDecimal canValue = decValue.multiply(src.getValue());
+ final BigDecimal result = canValue.divide(dst.getValue(), new MathContext(25));
println(decValue.toPlainString() + sourceUnit + " =("
+ src.getValue().toPlainString() + ")= "
+ canValue.toPlainString() + s + " =("
+ dst.getValue().toPlainString() + ")= "
- + canValue.divide(dst.getValue()) + destUnit);
- return canValue.divide(dst.getValue(), new MathContext(25));
+ + result);
+ return result;
}
- public Pair<Number, String> multiply(Pair<Number, String> o1,
- Pair<Number, String> o2) {
+ public CodeValuePair<Number, String> multiply(CodeValuePair<Number, String> o1,
+ CodeValuePair<Number, String> o2) {
// Term term = new ExpressionParser(model).parse(o1.getCode());
// Canonical c = new Converter(model, handlers).convert(term);
- return new Pair<Number, String>(
+ return new CodeValuePair<Number, String>(
((BigDecimal) o1.getValue()).multiply((BigDecimal) o2
.getValue()),
// new ExpressionComposer().compose(c.getUnit()));
diff --git a/bundles/org.eclipse.uomo.ucum/src/main/java/org/eclipse/uomo/ucum/model/Concept.java b/bundles/org.eclipse.uomo.ucum/src/main/java/org/eclipse/uomo/ucum/model/Concept.java
index 633f76a..6db24b0 100644
--- a/bundles/org.eclipse.uomo.ucum/src/main/java/org/eclipse/uomo/ucum/model/Concept.java
+++ b/bundles/org.eclipse.uomo.ucum/src/main/java/org/eclipse/uomo/ucum/model/Concept.java
@@ -20,7 +20,7 @@
import org.eclipse.uomo.core.INames;
import org.eclipse.uomo.core.ISymbol;
-public class Concept implements ICode, IDescription, ISymbol, INames {
+public class Concept implements ICode<String>, IDescription, ISymbol, INames {
private final ConceptKind kind;
/**
diff --git a/bundles/org.eclipse.uomo.ucum/src/main/java/org/eclipse/uomo/ucum/special/SpecialUnitHandler.java b/bundles/org.eclipse.uomo.ucum/src/main/java/org/eclipse/uomo/ucum/special/SpecialUnitHandler.java
index a359366..37004a0 100644
--- a/bundles/org.eclipse.uomo.ucum/src/main/java/org/eclipse/uomo/ucum/special/SpecialUnitHandler.java
+++ b/bundles/org.eclipse.uomo.ucum/src/main/java/org/eclipse/uomo/ucum/special/SpecialUnitHandler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Crown Copyright (c) 2006, 2011, Copyright (c) 2006, 2008 Kestral Computing P/L.
+ * Crown Copyright (c) 2006, 2014, Copyright (c) 2006, 2008 Kestral Computing P/L.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -15,7 +15,7 @@
import org.eclipse.uomo.core.ICode;
import org.unitsofmeasurement.quantity.Quantity;
-public abstract class SpecialUnitHandler<Q extends Quantity<Q>> implements Quantity<Q>, ICode {
+public abstract class SpecialUnitHandler<Q extends Quantity<Q>> implements Quantity<Q>, ICode<String> {
/**
* Used to connect this handler with the case sensitive unit
diff --git a/bundles/org.eclipse.uomo.units/src/main/java/org/eclipse/uomo/units/impl/quantity/CatalyticActivityAmount.java b/bundles/org.eclipse.uomo.units/src/main/java/org/eclipse/uomo/units/impl/quantity/CatalyticActivityAmount.java
index f5d95cb..ced4ce2 100644
--- a/bundles/org.eclipse.uomo.units/src/main/java/org/eclipse/uomo/units/impl/quantity/CatalyticActivityAmount.java
+++ b/bundles/org.eclipse.uomo.units/src/main/java/org/eclipse/uomo/units/impl/quantity/CatalyticActivityAmount.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2005, 2013, Werner Keil, Ikayzo and others.
+ * Copyright (c) 2005, 2014, Werner Keil and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -20,9 +20,9 @@
*
* @author <a href="mailto:jean-marie@dautelle.com">Jean-Marie Dautelle</a>
* @author <a href="mailto:uomo@catmedia.us">Werner Keil</a>
- * @version 1.3, $Date: 2013-04-28 $
+ * @version 1.4, $Date: 2014-03-03 $
*/
-public final class CatalyticActivityAmount extends BaseAmount<CatalyticActivity> {
+public final class CatalyticActivityAmount extends BaseAmount<CatalyticActivity> implements CatalyticActivity {
public CatalyticActivityAmount(Number number, Unit<CatalyticActivity> unit) {
super(number, unit);
diff --git a/bundles/org.eclipse.uomo.units/src/main/java/org/eclipse/uomo/units/impl/quantity/RadioactiveAmount.java b/bundles/org.eclipse.uomo.units/src/main/java/org/eclipse/uomo/units/impl/quantity/RadioactiveAmount.java
deleted file mode 100644
index d8bab28..0000000
--- a/bundles/org.eclipse.uomo.units/src/main/java/org/eclipse/uomo/units/impl/quantity/RadioactiveAmount.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * Copyright (c) 2005, 2010, Werner Keil, Ikayzo and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Werner Keil, Ikayzo and others - initial API and implementation
- */
-package org.eclipse.uomo.units.impl.quantity;
-
-import org.eclipse.uomo.units.impl.BaseAmount;
-import org.unitsofmeasurement.quantity.RadioactiveActivity;
-import org.unitsofmeasurement.unit.Unit;
-
-/**
- * Represents a radioactive activity.
- * The metric system unit for this quantity is "Bq" (Becquerel).
- *
- * @author <a href="mailto:jean-marie@dautelle.com">Jean-Marie Dautelle</a>
- * @author <a href="mailto:uomo@catmedia.us">Werner Keil</a>
- * @version 1.1, $Date: 2010-09-13 23:50:44 +0200 (Mo, 13 Sep 2010) $
- */
-public class RadioactiveAmount extends BaseAmount<RadioactiveActivity> {
-
- public RadioactiveAmount(Number number, Unit<RadioactiveActivity> unit) {
- super(number, unit);
- }
-}
diff --git a/bundles/org.eclipse.uomo.units/src/main/java/org/eclipse/uomo/units/impl/quantity/RadioactivityAmount.java b/bundles/org.eclipse.uomo.units/src/main/java/org/eclipse/uomo/units/impl/quantity/RadioactivityAmount.java
new file mode 100644
index 0000000..d3169e9
--- /dev/null
+++ b/bundles/org.eclipse.uomo.units/src/main/java/org/eclipse/uomo/units/impl/quantity/RadioactivityAmount.java
@@ -0,0 +1,31 @@
+/**
+ * Copyright (c) 2005, 2014, Werner Keil and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Werner Keil, Ikayzo and others - initial API and implementation
+ */
+package org.eclipse.uomo.units.impl.quantity;
+
+import org.eclipse.uomo.units.impl.BaseAmount;
+import org.unitsofmeasurement.quantity.RadioactiveActivity;
+import org.unitsofmeasurement.unit.Unit;
+
+/**
+ * Represents radioactivity. The metric system unit for this quantity is "Bq"
+ * (Becquerel).
+ *
+ * @author <a href="mailto:jean-marie@dautelle.com">Jean-Marie Dautelle</a>
+ * @author <a href="mailto:uomo@catmedia.us">Werner Keil</a>
+ * @version 1.2, $Date: 2014-03-03 $
+ */
+public class RadioactivityAmount extends BaseAmount<RadioactiveActivity>
+ implements RadioactiveActivity {
+
+ public RadioactivityAmount(Number number, Unit<RadioactiveActivity> unit) {
+ super(number, unit);
+ }
+}
diff --git a/bundles/org.eclipse.uomo.util/src/main/java/org/eclipse/uomo/util/numbers/ISpellCode.java b/bundles/org.eclipse.uomo.util/src/main/java/org/eclipse/uomo/util/numbers/ISpellCode.java
index 0751724..af7c0e0 100644
--- a/bundles/org.eclipse.uomo.util/src/main/java/org/eclipse/uomo/util/numbers/ISpellCode.java
+++ b/bundles/org.eclipse.uomo.util/src/main/java/org/eclipse/uomo/util/numbers/ISpellCode.java
@@ -12,7 +12,7 @@
import org.eclipse.uomo.core.ICode;
import org.eclipse.uomo.core.IName;
-import org.eclipse.uomo.core.INumericValue;
+import org.eclipse.uomo.core.IValue;
/**
* In this project, we have used a unique way of encoding spelled number to a
@@ -49,5 +49,5 @@
* @see {@link SpellContext#encode(String)}
*
*/
-public interface ISpellCode extends IName, ICode, INumericValue {
+public interface ISpellCode extends IName, ICode<String>, IValue<Number> {
}