public Temperature(double d, String u) { this.value = d; this.unit = UnitsTemperature.valueOf(u); }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((unit == null) ? 0 : unit.hashCode()); long temp; temp = Double.doubleToLongBits(value); result = prime * result + (int) (temp ^ (temp >>> 32)); return result; }
/** * FIXME: this should likely take a default so that locations which don't * want an exception can have * * log.warn("Using new PositiveFloat(1.0)!", e); return new * PositiveFloat(1.0); * * or similar. */ public static ome.units.quantity.Temperature convert(Temperature t) { if (t == null) { return null; } Double v = t.getValue(); // Use the code/symbol-mapping in the ome.model.enums files // to convert to the specification value. String u = ome.model.enums.UnitsTemperature.valueOf( t.getUnit().toString()).getSymbol(); ome.xml.model.enums.UnitsTemperature units = makeXMLUnit(u); ome.units.unit.Unit<ome.units.quantity.Temperature> units2 = ome.xml.model.enums.handlers.UnitsTemperatureEnumHandler .getBaseUnit(units); return new ome.units.quantity.Temperature(v, units2); }
public Temperature(double d, Unit<ome.units.quantity.Temperature> unit) { this(d, UnitsTemperature.bySymbol(unit.getSymbol())); }
public static Temperature convertTemperature(Temperature value, String target) { String source = value.getUnit().getSymbol(); if (target.equals(source)) { return value; } throw new RuntimeException(String.format( "%f %s cannot be converted to %s", value.getValue(), value.getUnit().getSymbol(), source)); }
/** * Copy constructor that converts the given {@link omero.model.Temperature} * based on the given ome.model enum */ public TemperatureI(double d, ome.model.enums.UnitsTemperature ul) { this(d, UnitsTemperature.valueOf(ul.toString())); }
public TemperatureI(double d, Unit<ome.units.quantity.Temperature> unit) { this(d, ome.model.enums.UnitsTemperature.bySymbol(unit.getSymbol())); }
/** * FIXME: this should likely take a default so that locations which don't * want an exception can have * * log.warn("Using new PositiveFloat(1.0)!", e); return new * PositiveFloat(1.0); * * or similar. */ public static ome.units.quantity.Temperature convertTemperature(Temperature t) { if (t == null) { return null; } Double v = t.getValue(); String u = t.getUnit().getSymbol(); ome.xml.model.enums.UnitsTemperature units = makeTemperatureUnitXML(u); ome.units.unit.Unit<ome.units.quantity.Temperature> units2 = ome.xml.model.enums.handlers.UnitsTemperatureEnumHandler .getBaseUnit(units); return new ome.units.quantity.Temperature(v, units2); }
@Override public void copyObject(Filterable model, ModelMapper mapper) { if (model instanceof ome.model.units.Temperature) { ome.model.units.Temperature t = (ome.model.units.Temperature) model; this.value = t.getValue(); this.unit = UnitsTemperature.valueOf(t.getUnit().toString()); } else { throw new IllegalArgumentException( "Temperature cannot copy from " + (model==null ? "null" : model.getClass().getName())); } }
public Temperature(ome.units.quantity.Temperature value) { this(value.value().doubleValue(), UnitsTemperature.bySymbol(value.unit().getSymbol())); }
@Override public Filterable fillObject(ReverseModelMapper mapper) { ome.model.enums.UnitsTemperature ut = ome.model.enums.UnitsTemperature.valueOf(getUnit().toString()); ome.model.units.Temperature t = new ome.model.units.Temperature(getValue(), ut); return t; }
/** * Convert a Bio-Formats {@link Length} to an OMERO Length. */ public TemperatureI(ome.units.quantity.Temperature value) { ome.model.enums.UnitsTemperature internal = ome.model.enums.UnitsTemperature.bySymbol(value.unit().getSymbol()); UnitsTemperature ul = UnitsTemperature.valueOf(internal.toString()); setValue(value.value().doubleValue()); setUnit(ul); }