Coder Social home page Coder Social logo

uom-lib's People

Contributors

aontas avatar bantu avatar daniel-dos avatar daniel-shuy avatar duckasteroid avatar glimmerveen avatar gregjohnstewart avatar keilw avatar krichter722 avatar sanjaymsh avatar teobais avatar waffle-iron avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

uom-lib's Issues

Change groupId of Domain modules

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.

Fix JavaDoc in Versioned

Functional interface Versioned has JavaDoc saying

whose functional method is {@link #getId()}
should be
whose functional method is {@link #getVersion()}

Remove Waffle reference from README

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.

Provide a Measurement/Quantity List structure

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.

Investigate why Jackson build fails with Java 10+11 after module-info added but passes everywhere else?

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.

Fix the checkstyle problem

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.

Latest v2.0 POM not deployed to Maven Central

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.

Jackson deserialization for `Quantity` interface does not exist

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)
  • Is this expected?
  • Am I using correctly the library?

DELETE ME

I would like to delete this issue.

Support JavaBeans XML serialization for Quantities

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

Split Domain Lib and Domain Impl

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.

Disable or kill-off Travis CI

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.

Get rid of crappy Travis

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.

Serialization of units with "per square" content

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));
    }

}

Add SI module

Move concrete quantity types from RI or SE implementation.
Reusable SI type library

Add Reporter for Unit System

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.