unitsofmeasurement / uom-lib Goto Github PK
View Code? Open in Web Editor NEWUnits of Measurement Libraries
License: Other
Units of Measurement Libraries
License: Other
Safecast (http://blog.safecast.org/) is a community-driven Sensor Network started after the Fukushima nuclear desaster. It provides an extensive API: https://api.safecast.org/en-US/home
Try to adjust artifact naming (e.g. health) to si-units or uom-systems.
Add a Jakarta JSON library similar to Jackson
While the repository may still be here, it's worth considering a change from the "tec.uom.lib" namespace to "tec.uom.domain" with libraries for "health", etc.
Similar to https://github.com/unitsofmeasurement/uom-systems/tree/master/docs there should be a project page for this repository, too.
Similar to Zalando's Bean Validation module for JSR 354: https://github.com/zalando/money-validation
Something along the lines for JSR 363 looks like a good library.
This may help comparing numbers:
http://stackoverflow.com/questions/2683202/comparing-the-values-of-two-generic-numbers
This (not so recently updated) initiative for Measure Microformats could be interesting: http://microformats.org/wiki/measure Especially for HTML5, though there is a rudimentary "measure like" tag there, too.
Apply Maven Plugin for AssertJ Generator to key elements like Unit, Quantity, etc.
https://github.com/joel-costigliola/assertj-assertions-generator-maven-plugin
Waffle is closing down. While a few aspects like dependencies between issues do not seem covered by GitHub tracker itself, the Kanban board is now available on an organization level with GitHub Projects, thus we do not really need Waffle any more.
All related badges in README files need to be removed as soon as possible.
Add a common library reusable across implementations
While it probably won't be more than an optional type in a module like "util" (similar to others like Range) how do you consider a "List Pattern" similar to Unicode CLDR:
http://cldr.unicode.org/index/downloads/cldr-24#TOC-Enhanced-units-structure
A new element specifies patterns for time durations involving combinations of hours, minutes, and seconds, such as "Video >length: 93:45".
or
These are intended to be used for constructing formats such as "2 hours, 5 minutes", "2 hrs, 5 mins", or "2h 5m"
Essentially it is similar to TemporalAmount: http://docs.oracle.com/javase/8/docs/api/java/time/temporal/TemporalAmount.html
in JSR 310, but unlike 310 there is no structural "array" of units in ICU4J.
Instead, e.g. MeasureFormat: http://icu-project.org/apiref/icu4j/com/ibm/icu/text/MeasureFormat.html allows formatting more than one measurement:
MeasureFormat fmtEn = MeasureFormat.getInstance(ULocale.ENGLISH, FormatWidth.WIDE);
// Output: 1 inch, 2 feet
fmtEn.formatMeasures(
new Measure(1, MeasureUnit.INCH),
new Measure(2, MeasureUnit.FOOT));
So it could be handled by Formatting/Parsing similar to ICU4J, where at most an array or collection of individual measurements is used, or via a structural type similar to JSR 310. I don't think we should overcomplicate the Measurement/Quantity type similar to TemporalAmount, but as with Range it could be provided in an optional module (or even just on RI level) if there's value to it.
There is a strange bug which might be in the JDK or Maven, see https://www.mail-archive.com/[email protected]&q=subject:%22%5C%5Bjira%5C%5D+%5C%5BCommented%5C%5D+%5C%28NETBEANS%5C-2397%5C%29+Java%27s+provide+...+with+NOT+working+in+maven+projects%22&o=newest&f=1
Only Java 10 and 11 fail with a very similar problem
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project uom-lib-jackson: Execution default-compile of goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile failed: Unsupported major.minor version 56.0 -> [Help 1]
but all the other Java versions 8, 9 and 12-14 pass without problems.
For now we simply exclude them from the Travis build as it has no effect on the runtime for all we know.
Yet weird, if anybody knows what causes it, help is appreciated.
While the intention was good with #47 the way it got applied broke the build. And I am not comfortable with a dependency that consists of a Checkstyle XML file only. If there are was a need for this kind of reusable Checkstyle rule, then it belongs to an updated https://github.com/unitsofmeasurement/uom-tools. Otherwise there might be a solution that works on the file system without such a build only dependency.
Move interfaces like Nameable from implementations to common-lib
The latest v2.0 POM file (tech.uom.lib:uom-lib:2.0) was not deployed to Maven Central. It is the parent POM for the Common Library (tech.uom.lib:uom-lib-common:2.0), making the maven resolution failed.
I have recently discovered and started to use all the Units of Measurement library echosystem.
Now I wanted to serialize/deserialize some Quantity
's instances, but I have realised that is not possible to deserialize them.
The following JUnit 5 (with pojo class included)
class ChargeDeserializationTest
{
static final ObjectMapper mapper = new ObjectMapper();
static
{
mapper.registerModule(new UnitJacksonModule())
.registerModules(new JavaTimeModule());
}
@Test
public void roundtrip() throws Exception
{
Charge charge = new Charge();
charge.setWhen(Instant.ofEpochMilli(nextLong()));
charge.setRunAlong(Quantities.getQuantity(nextLong(), Units.METRE));
charge.setWith(Quantities.getQuantity(nextLong(), Units.CUBIC_METRE));
String serialization = mapper.writeValueAsString(charge);
Charge deserialization = mapper.readValue(serialization, Charge.class);
}
static class Charge
{
private Instant when;
private Quantity<Length> runAlong;
private Quantity<Volume> with;
public Instant getWhen()
{
return when;
}
public void setWhen(final Instant when)
{
this.when = when;
}
public Quantity<Length> getRunAlong()
{
return runAlong;
}
public void setRunAlong(final Quantity<Length> runAlong)
{
this.runAlong = runAlong;
}
public Quantity<Volume> getWith()
{
return with;
}
public void setWith(final Quantity<Volume> with)
{
this.with = with;
}
}
}
throws the exception,
Cannot construct instance of `javax.measure.Quantity` (no Creators, like default construct, exist): abstract types either need to be mapped to concrete types, have custom deserializer, or contain additional type information
at [Source: (String)"{"when":4484040231309519.872000000,"runAlong":{"unit":"m","scale":"ABSOLUTE","value":3535414706998429696},"with":{"unit":"m3","scale":"ABSOLUTE","value":6316882200111963136}}"; line: 1, column: 47] (through reference chain: com.github.lucasvc.uom.lib.jackson.quantity.deserialize.ChargeDeserializationTest$Charge["runAlong"])
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `javax.measure.Quantity` (no Creators, like default construct, exist): abstract types either need to be mapped to concrete types, have custom deserializer, or contain additional type information
at [Source: (String)"{"when":4484040231309519.872000000,"runAlong":{"unit":"m","scale":"ABSOLUTE","value":3535414706998429696},"with":{"unit":"m3","scale":"ABSOLUTE","value":6316882200111963136}}"; line: 1, column: 47] (through reference chain: com.github.lucasvc.uom.lib.jackson.quantity.deserialize.ChargeDeserializationTest$Charge["runAlong"])
at com.fasterxml.jackson.databind.exc.InvalidDefinitionException.from(InvalidDefinitionException.java:67)
at com.fasterxml.jackson.databind.DeserializationContext.reportBadDefinition(DeserializationContext.java:1589)
at com.fasterxml.jackson.databind.DeserializationContext.handleMissingInstantiator(DeserializationContext.java:1055)
at com.fasterxml.jackson.databind.deser.AbstractDeserializer.deserialize(AbstractDeserializer.java:265)
at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:129)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:288)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4202)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3205)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3173)
at com.github.lucasvc.uom.lib.jackson.quantity.deserialize.ChargeDeserializationTest.roundtrip(ChargeDeserializationTest.java:40)
....
at java.lang.Thread.run(Thread.java:748)
I would like to delete this issue.
When checking available versions of the assertJ library, version 2.0 is not available at maven central, or jcenter.
For example check the following URL at maven central search: https://search.maven.org/artifact/tech.uom.lib/uom-lib-assertj
Add a Coded
or Codeable
interface to the function package similar to Identifiable
public interface Codeable<T> {
T getCode();
}
Or a different name e.g. CodeSupplier
.
Hello all! I'm using the UOM-SE library in a simulation project, and am running into a bit of trouble when trying to serialize objects containing ComparableQuantity objects via XMLEncoder. A minimal sample codebase that exhibits the problem (with most of the original classes involved intact) can be found in this gist. The SimulationParameter objects export, but due to exceptions thrown trying to export the UOM objects, no values show up in the XML output. Errors I am seeing are:
java.lang.InstantiationException: tec.uom.se.quantity.NumberQuantity
Continuing ...
java.lang.RuntimeException: failed to evaluate: <unbound>=Class.new();
Continuing ...
java.lang.InstantiationException: tec.uom.se.quantity.DoubleQuantity
Continuing ...
java.lang.RuntimeException: failed to evaluate: <unbound>=Class.new();
Continuing ...
(repeated several times)
I tried to register a DefaultPersistenceDelegate on the XMLEncoder to handle ComparableQuantity by converting the quantity to a string but it is never getting called - and neither does one registered for NumberQuantity. Apparently the DoubleQuantity class is package private so I cannot register a DefaultPersistenceDelegate for it to test. Any suggestions as to how I can get this to work?
Thanks!
-R
AssertJ support for JSR 363 looks quite interesting
Allowing something like
assertThat(quantity1).hasUnit(METRE)
or similar.
To improve dependency resolution, reusable Domain libraries should stay in uom-lib (either in tec.uom.lib or tec.uom.lib.domain) while "implementations" for RI, SE, Android, etc. should move to a separate repository and groupId under tec.uom.domain.
Add index with option to show during SOU report
Similar to DescriptionSupplier, a common LabelSupplier is also beneficial and found in several downstream APIs (e.g. Fitbit)
Starting last night there are massive problems on TravisCI only due to its own infrastructure it seems.
The main Circle-CI build works perfectly fine.
If this isn't fixed within a few hours or days, we better disable it for now because it creates too much noise and spam especially in my mailbox.
I am unable to find tech.uom.lib:uom-lib-jackson:2.0 in maven central
Travis-CI is a total mess, while Circle-CI works perfectly fine with the new Sonatype repositories Travis-CI keeps failing all the builds because it still tries to look for Indriya 2.1.1-SNAPSHOT where none is defined.
Killing it, because it will get much slower anyway.
The following minimum example displays:
"m2"
"m/s"
"V2/Ohm"
"Ohm/V"
However, I'd expect something like:
"m2"
"m/s2"
"V2/Ohm"
"Ohm/V2"
It seems like this issue only happens for units with a negative exponent. Units like square meter seem to work fine.
Our dependencies:
<dependency>
<groupId>tech.units</groupId>
<artifactId>indriya</artifactId>
<version>2.0.4</version>
</dependency>
<dependency>
<groupId>tech.uom.lib</groupId>
<artifactId>uom-lib-jackson</artifactId>
<version>2.0.1</version>
</dependency>
Sample code:
import javax.measure.Unit;
import javax.measure.quantity.Acceleration;
import javax.measure.quantity.Area;
import org.junit.Test;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import tech.units.indriya.unit.Units;
import tech.uom.lib.jackson.UnitJacksonModule;
public class TempTest {
@Test
public void test() throws JsonProcessingException {
Unit<Area> areaUnit = Units.SQUARE_METRE;
Unit<Acceleration> accelUnit = Units.METRE_PER_SQUARE_SECOND;
Unit<?> composedUnit = Units.VOLT.pow(2).divide(Units.OHM);
Unit<?> composedUnitInverted = composedUnit.inverse();
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new UnitJacksonModule());
System.out.println(mapper.writeValueAsString(areaUnit));
System.out.println(mapper.writeValueAsString(accelUnit));
System.out.println(mapper.writeValueAsString(composedUnit));
System.out.println(mapper.writeValueAsString(composedUnitInverted));
}
}
CI_DEPLOY_PASSWORD
for Sonatype/OSSHAlthough the API has a prefix()
method in Unit
, we should add a @FunctionalInterface like PrefixOperator
to commons-lib.
Move concrete quantity types from RI or SE implementation.
Reusable SI type library
Factor out
private static void testSoU(final SystemOfUnits sou) {
System.out.println("Testing " + sou.getName());
for (Unit<?> u : sou.getUnits()) {
System.out.println(u.getName() + "; " + u.getSymbol() + "; " + u);
}
}
into a SystemOfUnitsReporter utility class.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.