Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » UOMo » Generic Elements containing BaseAmount
Generic Elements containing BaseAmount [message #1691352] Mon, 06 April 2015 13:03
Nieves Salor is currently offline Nieves SalorFriend
Messages: 19
Registered: September 2013
Junior Member
Hi I want to create a java object which can be defined for multiple Dimensions and let the user choose the one he desires. As so I have created a new class which extends the BaseAmount class so the user can define an element of MassAmount or another of Temperature and then it can retrieve the values in an homogenised way.
My problem comes at compilation time, because the compiler is not raising any problem if for a MassAmount I use AMPERE units. Can someone shed a light on this? I am guessing I am doing something wrong
I put my code
import org.unitsofmeasurement.quantity.Quantity;
import  org.eclipse.uomo.units.impl.BaseAmount;
import org.unitsofmeasurement.unit.Unit;

@SuppressWarnings("rawtypes")
public class MeasurableElement<T extends BaseAmount> {

	 T  value;
		 
	public  MeasurableElement( T  typeAmount){
		 value = (T) typeAmount;
	 }
	
 
	@SuppressWarnings("unchecked")
	public <U extends Unit> void forceValue(double newVal, U  unit ) {
			value = (T) BaseAmount.valueOf(newVal, unit);
		}
}


and my testing code
MeasurableElement<MassAmount> me = new MeasurableElement(new MassAmount(1000, org.eclipse.uomo.units.SI.KILOGRAM));
me.forceValue(5.2, org.eclipse.uomo.units.SI.AMPERE);


Thanks in advance
Previous Topic:Which version of UOMo to use with Eclipse Luna
Next Topic:Wrong Prefixes in Unit Calculation
Goto Forum:
  


Current Time: Fri Apr 26 17:03:58 GMT 2024

Powered by FUDForum. Page generated in 0.02804 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top