Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
- uses: actions/checkout@v6
- name: Set up JDK 21
uses: actions/setup-java@v5
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'
cache: maven
- name: Build with Maven
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/release-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,20 @@ jobs:
exit 1

# Set up java with maven cache
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
- uses: actions/checkout@v6
- name: Set up JDK 21
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: '17'
java-version: '21'
cache: 'maven'

# import the secret key
- name: Set up Apache Maven Central
uses: actions/setup-java@v3
uses: actions/setup-java@v5
with: # running setup-java again overwrites the settings.xml
distribution: 'temurin'
java-version: '17'
java-version: '21'
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml
server-username: MAVEN_USERNAME # env variable for username in deploy
server-password: MAVEN_CENTRAL_TOKEN # env variable for token in deploy
Expand Down
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Add static factory methods `QuantityValue.of(value, unit)` with various value argument types that can be used to instantiate the
`BigDecimal` value used internally.

- Add dynamic factory methods in `Unit.quantityValue(value)` with various value argument types that can be used to instantiate the
`BigDecimal` value used internally.

- Add delegate methods for many `BigDecimal` methods to `QuantityValue` to allow for mathematical operations with
automatic unit conversion, for example:

```
QuantityValue mVal = Qudt.Units.M.quantityValue(20);
QuantityValue ftVal = Qudt.Units.FT.quantityValue(1);
QuantityValue mValResult = mVal.add(ftVal);
```

### Fixed

- Fix wrong definition of `Quantity`. It used to encapsulate a Set of `QuantityValue`, which never made sense. With
this change, it encapsulates a `QuantityValue` and a `QuantityKind`, conforming to the definition of the concept in QUDT.

- Upgrade various dependencies.

## [7.1.1] - 2025-10-09

## [7.1.0] - 2025-09-01
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Makes all conversions and related functionality defined by the excellent [QUDT o

The library offers
* 1745 units, such as second, Fahrenheit, or light year
* 881 quantityKinds, such as width, pressure ratio or currency
* 881 quantityKinds, such as width, pressure ratio, or currency
* 29 prefixes, such as mega, kibi, or atto

...all of which the library converts if possible.
Expand Down Expand Up @@ -46,7 +46,7 @@ The main Model classes are:
* `QuantityValue`: value and unit. Values are always `BigDecimal` (using `MathContext.DECIMAL128`) and there are no convenience methods allowing you
to provide other numeric types. This is intentiaonal so as not to mask any conversion problems. You'll be fine. (If you need a different `MathContext`, make an issue)

All units, quantityKinds and prefixes are avalable as constants:
All units, quantityKinds, and prefixes are avalable as constants:
* `Qudt.Units`: all units, such as `Qudt.Units.KiloM__PER__SEC`
* `Qudt.QuantityKinds:`: all quantityKinds, such as `Qudt.QuantityKinds.BloodGlucoseLevel`
* `Qudt.Prefixes`: all prefixes, such as `Qudt.Prefixes.Atto`
Expand Down
24 changes: 15 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<qudt.release.version>3.1.5</qudt.release.version>
<spotless.format.version>1.25.0</spotless.format.version>
<spotless.format.version>1.33.0</spotless.format.version>
</properties>

<scm>
Expand All @@ -65,35 +65,41 @@
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.9.1</version>
<version>6.1.0-M1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>4.0.0-M1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-reload4j</artifactId>
<version>2.0.3</version>
<version>2.1.0-alpha1</version>
</dependency>
<dependency>
<groupId>org.eclipse.rdf4j</groupId>
<artifactId>rdf4j-bom</artifactId>
<type>pom</type>
<version>4.2.0</version>
<version>5.3.0-M1</version>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.31</version>
<version>2.3.34</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<version>2.2</version>
<version>3.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.5.0-M2</version>
<version>4.5.0</version>
</dependency>
</dependencies>
</dependencyManagement>
Expand Down Expand Up @@ -162,7 +168,7 @@
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>2.44.0.BETA3</version>
<version>3.2.1</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
Expand Down Expand Up @@ -278,7 +284,7 @@
<plugin>
<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
<version>0.8.0</version>
<version>0.10.0</version>
<extensions>true</extensions>
<configuration>
<publishingServerId>ossrh</publishingServerId>
Expand Down
2 changes: 1 addition & 1 deletion qudtlib-main-rdf/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<version>7.1.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<name>qudtlib-main-rdf&gt;</name>
<name>qudtlib-main-rdf</name>
<artifactId>qudtlib-main-rdf</artifactId>
<packaging>pom</packaging>

Expand Down
10 changes: 10 additions & 0 deletions qudtlib-model/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,14 @@
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
<artifactId>qudtlib-model</artifactId>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,55 @@ public class DimensionVector {

private String dimensionVectorIri;

public static Builder builder() {
return new Builder();
}

public static class Builder {
private float[] values = new float[8];

public Builder() {}

public Builder amountOfSubstance(float exp) {
values[INDEX_AMOUNT_OF_SUBSTANCE] = exp;
return this;
}

public Builder electricCurrent(float exp) {
values[INDEX_ELECTRIC_CURRENT] = exp;
return this;
}

public Builder length(float exp) {
values[INDEX_LENGTH] = exp;
return this;
}

public Builder luminousIntensity(float exp) {
values[INDEX_LUMINOUS_INTENSITY] = exp;
return this;
}

public Builder mass(float exp) {
values[INDEX_MASS] = exp;
return this;
}

public Builder temperature(float exp) {
values[INDEX_TEMPERATURE] = exp;
return this;
}

public Builder time(float exp) {
values[INDEX_TIME] = exp;
return this;
}

public DimensionVector build() {
return new DimensionVector(values);
}
}

private final float[] values;

public static Optional<DimensionVector> of(String dimensionVectorIri) {
Expand Down
28 changes: 14 additions & 14 deletions qudtlib-model/src/main/java/io/github/qudtlib/model/Quantity.java
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
package io.github.qudtlib.model;

import java.util.Collections;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;

/**
* Represents a QUDT Quantity - a set of {@link QuantityValue}s.
* Represents a QUDT Quantity - A QuantityValue with a QuantityKind
*
* @author Florian Kleedorfer
* @version 1.0
*/
public class Quantity {
final Set<QuantityValue> quantityValues;
final QuantityValue quantityValue;

final QuantityKind quantityKind;

public Quantity(QuantityValue quantityValue, QuantityKind quantityKind) {
this.quantityValue = quantityValue;
this.quantityKind = quantityKind;
}

public Quantity(Set<QuantityValue> quantityValues) {
this.quantityValues = quantityValues;
public QuantityValue getQuantityValue() {
return quantityValue;
}

public Set<QuantityValue> getQuantityValues() {
return Collections.unmodifiableSet(quantityValues);
public QuantityKind getQuantityKind() {
return quantityKind;
}

@Override
public String toString() {
return "Quantity{"
+ quantityValues.stream().map(Objects::toString).collect(Collectors.joining(", "))
+ '}';
return quantityKind.toString() + " of " + quantityValue.toString();
}
}
Loading