public Frequency(double d, String u) { this.value = d; this.unit = UnitsFrequency.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.Frequency convert(Frequency 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.UnitsFrequency.valueOf( t.getUnit().toString()).getSymbol(); ome.xml.model.enums.UnitsFrequency units = makeXMLUnit(u); ome.units.unit.Unit<ome.units.quantity.Frequency> units2 = ome.xml.model.enums.handlers.UnitsFrequencyEnumHandler .getBaseUnit(units); return new ome.units.quantity.Frequency(v, units2); }
public FrequencyI(double d, Unit<ome.units.quantity.Frequency> unit) { this(d, ome.model.enums.UnitsFrequency.bySymbol(unit.getSymbol())); }
public static Frequency convertFrequency(Frequency 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.Frequency} * based on the given ome.model enum */ public FrequencyI(double d, ome.model.enums.UnitsFrequency ul) { this(d, UnitsFrequency.valueOf(ul.toString())); }
public Frequency(double d, Unit<ome.units.quantity.Frequency> unit) { this(d, UnitsFrequency.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.Frequency convertFrequency(Frequency t) { if (t == null) { return null; } Double v = t.getValue(); String u = t.getUnit().getSymbol(); ome.xml.model.enums.UnitsFrequency units = makeFrequencyUnitXML(u); ome.units.unit.Unit<ome.units.quantity.Frequency> units2 = ome.xml.model.enums.handlers.UnitsFrequencyEnumHandler .getBaseUnit(units); return new ome.units.quantity.Frequency(v, units2); }
@Override public void copyObject(Filterable model, ModelMapper mapper) { if (model instanceof ome.model.units.Frequency) { ome.model.units.Frequency t = (ome.model.units.Frequency) model; this.value = t.getValue(); this.unit = UnitsFrequency.valueOf(t.getUnit().toString()); } else { throw new IllegalArgumentException( "Frequency cannot copy from " + (model==null ? "null" : model.getClass().getName())); } }
public Frequency(ome.units.quantity.Frequency value) { this(value.value().doubleValue(), UnitsFrequency.bySymbol(value.unit().getSymbol())); }
@Override public Filterable fillObject(ReverseModelMapper mapper) { ome.model.enums.UnitsFrequency ut = ome.model.enums.UnitsFrequency.valueOf(getUnit().toString()); ome.model.units.Frequency t = new ome.model.units.Frequency(getValue(), ut); return t; }
/** * Convert a Bio-Formats {@link Length} to an OMERO Length. */ public FrequencyI(ome.units.quantity.Frequency value) { ome.model.enums.UnitsFrequency internal = ome.model.enums.UnitsFrequency.bySymbol(value.unit().getSymbol()); UnitsFrequency ul = UnitsFrequency.valueOf(internal.toString()); setValue(value.value().doubleValue()); setUnit(ul); }