Git Product home page Git Product logo

unit-ri's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar  avatar  avatar

unit-ri's Issues

Move OutputHelper to util

The OutputHelper class is currently in the "format" package. It is closer to logging/output than formatting and parsing, so it is advisable to move it to "util".

Consider using SPI in AbstractUnit

Maybe we could use ServiceProvider.current().getUnitFormatService().getUnitFormat() instead of SimpleUnitFormat.getInstance() in relevant parts of:
https://github.com/unitsofmeasurement/unit-ri/blob/master/src/main/java/tec/units/ri/AbstractUnit.java

It would make it a little more implementation-neutral although SimpleUnitFormat exists in all major implementations. And allow to use a UnitFormat of your choice if e.g. an extension or application overrides the default. Then e.g. MyUnitFormat instead of SimpleUnitFormat could be used. Where this is not overriden, the default would still apply.

TransformedUnit constructor with symbol should use it

The constructor TransformedUnit(String symbol, Unit<Q> parentUnit, UnitConverter unitConverter) currently does not use the symbol, but should use it. Unlike those without a symbol argument.

Also change JavaDoc

is there a UnitFactory Class available?

I am curious if there is a factory available that will return Units based on their standard string names

e.g

if it is "m" it should return Units.METRE
if it is "km" it should return MetricPrefix.KILO(Units.METRE)

UnitFactory.getUnit("m") => Units.METRE

Thanks!

Multiples of units need to be explicitely labeled, too

At the moment, UnitFormat.label() helps format units in most cases where the symbol may not be available or a different display character is required for a particular unit.
As examples like https://github.com/unitsofmeasurement/uom-demos/blob/master/domain/energy/src/main/java/tec/uom/demo/energy/DemoUnitSystem.java show, this right now has to be done for all known (or used) multiples and submultiples of a unit, too. E.g.

 SimpleUnitFormat.getInstance().label(WATTHOUR, "Wh");
 SimpleUnitFormat.getInstance().label(KILO(WATTHOUR), "KWh");

Even with SimpleUnitFormat known multiples and sub-multiples (like those defined by MetricPrefix of a unit should ideally be formatted automatically, so "Wh" becomes "KWh", "MWh", "mWh" etc. when KILO, MEGA or MILLI are applied.

Consider a new name for a (future) RI

Given most JSRs have more or less fancy and "divine" code names for Reference Implementations like

  • Moneta (JSR 354)
  • Soteria (JSR 375)
  • Diana / Artemis (Eclipse JNoSQL, not a JSR yet)
    I wanted to raise the question of a code name for this RI if the JSR progresses (likely with a new number)

Two mythological names both related to senses or measurement are:

  • Indriya - the Sanskrit and Pali term for physical strength or ability in general, and for the senses more specifically
  • Thoth or Djehuti - Ancient Egyptian God of Knowledge, the Moon, Measurement, Wisdom,...
  • Seshat - Companion/daughter of Thoth

Small fix: Transformed units symbol

Hi

When working with alternate unites like Feet, Fahrenheit and so on, a custom symbol can be used, but in the TransformedUnit constructor, the symbol is being ignored:

  public TransformedUnit(String symbol, Unit<Q> parentUnit, UnitConverter unitConverter) {
    this(null, parentUnit, parentUnit.getSystemUnit(), unitConverter);
  }

A simple change would really help out:

  public TransformedUnit(String symbol, Unit<Q> parentUnit, UnitConverter unitConverter) {
    this(symbol, parentUnit, parentUnit.getSystemUnit(), unitConverter);
  }

Thanks and regards

Getting rid of Serializable

To improve ME/SE interoperability, all parts of the RI that do not explicitely require it should not use Serializable.

Do we need AbstractMeasurement in RI?

The Measurement interface is the general abstraction of a Quantity. Allowing even non-numeric or complex type values (e.g. Image or Video) in certain use cases. However, Quantity specializes, thus extends Measurement, so abstract base types like AbstractQuantity and everything extending it also implements Measurement.

Do we want to keep a base class like AbstractMeasurement in the RI or leave it to 3rd party libraries, either at unitsofmeasurement.org or elsewhere?

Right-scale RI class versions

While API classes and interfaces are generally in the ~1 or below range (representing the maturity of some interfaces like Unit or Quantity that seems appropriate) some 4.x or 5.x numbers in the RI (driven by JScience or other implementations) seem a bit high.

As a rule of thumb, if a version was 5.4, we'll down-scale it to 0.4, if it was 5.0, on a case by case basis the overall RI version sounds best.

Refactor concrete classes

Related to #14 how about the following suggestion:
Except for Abstract* classes

  • move BaseQuantity and BaseMeasurement into a "quantity" package
    (it's a bit of a pickle for *Measurement, but we could think of something if it's a real problem)
  • move all concrete Unit implementations to a new sub-package like "unit"
    The "model" package could be renamed "dimension", but that has a lower priority, optional if we feel this is a better name. Other than that the concrete classes are already in their package for Dimension.

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.