jsr363

Jackson module signature prevents addings serializers for self-referencing generic types

♀尐吖头ヾ 提交于 2020-01-11 08:22:40
问题 I want to add a custom serializer and deserializer for JSR 363 javax.measure.Quantity<Q extends Quantity<Q>> , which basically encapsulates a "value" and a "unit". Creating the serializer ( extends JsonSerializer<Quantity<?>> ) and the deserializer ( extends StdDeserializer<Quantity<?>> ) is easy. But it's not easy to register them. For deserializers, it's OK; look at the signature: SimpleModule.addDeserializer(Class<T> type, JsonDeserializer<? extends T> deser) Notice that the deserializer

JSR 363 : formating a volume unit in decilitre

微笑、不失礼 提交于 2019-12-11 01:53:36
问题 Formatting a volume unit works correctly in millilitres and centilitres but fails for decilitres. import static tec.units.ri.unit.Units.LITRE; import javax.measure.Unit; import javax.measure.format.UnitFormat; import javax.measure.quantity.Volume; import javax.measure.spi.ServiceProvider; import static tec.units.ri.unit.MetricPrefix.*; public class Example { public static void main(String[] args) { final UnitFormat unitFormat = ServiceProvider.current().getUnitFormatService().getUnitFormat();

JSR 363 adding new units

﹥>﹥吖頭↗ 提交于 2019-12-08 18:18:56
问题 I am using the reference implementation of JSR 363: Units of Measurement API from maven (tec.units:unit-ri). Now I have to add a few units like teaspoon, fluid ounce and so on. Im extending the Units class to add a new unit like this: public static final Unit<Volume> TEASPOON = addUnit(new TransformedUnit<Volume>("tsp", CUBIC_METRE, new MultiplyConverter(0.000005))); This seems to work for converting but "tsp" is not parsing, so how do I add it to the parser? And Im having trouble adding

UCUM UnitFormat for JSR 363

浪子不回头ぞ 提交于 2019-12-02 11:45:17
问题 I'm using JSR 363 "Units of Measurement" with the latest reference implementation: <dependency> <groupId>javax.measure</groupId> <artifactId>unit-api</artifactId> <version>1.0</version> </dependency> <dependency> <groupId>tec.units</groupId> <artifactId>unit-ri</artifactId> <version>1.0.2</version> </dependency> I want to print out "milliliters" in UCUM format, i.e. "mL": final UnitFormat unitFormat = ServiceProvider.current().getUnitFormatService().getUnitFormat(); final Unit<?> unit = MILLI

UCUM UnitFormat for JSR 363

喜你入骨 提交于 2019-12-02 07:52:15
I'm using JSR 363 "Units of Measurement" with the latest reference implementation: <dependency> <groupId>javax.measure</groupId> <artifactId>unit-api</artifactId> <version>1.0</version> </dependency> <dependency> <groupId>tec.units</groupId> <artifactId>unit-ri</artifactId> <version>1.0.2</version> </dependency> I want to print out "milliliters" in UCUM format, i.e. "mL": final UnitFormat unitFormat = ServiceProvider.current().getUnitFormatService().getUnitFormat(); final Unit<?> unit = MILLI(LITRE); final String unitString=unitFormat.format(unit); Unfortunately this gives me "ml", not "mL"