Reputation: 173
I wrote some code using javax.measure, and when I pulled updated code from our repository, I am getting a Bound Mismatch error whenever I try to use <Length>
from javax.measure.
Edit The Exact Error Is:
Bound mismatch: The type Length is not a valid substitute for the bounded parameter
<Q extends Quantity>
of the typeBaseUnit<Q>
I moved the code to a clean workspace and everything was just fine, but for some reason in my main workspace it isn't working.
Any ideas to why this is the case? I'm using eclipse and the code in question is below
import javax.measure.Measure;
import javax.measure.quantity.Length;
import javax.measure.unit.BaseUnit;
public class MyUnit{
BaseUnit<Length> unitType;
Measure<Length> unitValue;
public MyUnit(double value, String abbreviation) {
this.unitType = new BaseUnit<Length>(abbreviation);
this.unitValue = Measure.valueOf(value, unitType);
}
public double getValue() {
return (double)this.unitValue.getValue();
}
public String getUnit() {
return this.unitType.getSymbol();
}
}
Upvotes: 1
Views: 392
Reputation: 205885
Measure<V,Q extends Quantity>
requires two type parameters:
V
the type of the result returned by getValue()
.
Q
the Quantity
of the Unit
returned by getUnit()
.
As the MyUnit
constructor specifies double
, the declaration should be, for example,
Measure<Double, Length> unitValue;
Upvotes: 1