Skip to content

Commit af4328a

Browse files
committed
Release build, fixed bnd descriptors, removed failing jacoco, added missing deps.
1 parent 4f5336d commit af4328a

File tree

20 files changed

+364
-108
lines changed

20 files changed

+364
-108
lines changed

calc/bnd.bnd

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,10 @@
33
osgi.core; version=6.0,\
44
osgi.cmpn; version=6.0
55

6-
-testpath: \
7-
${junit}
8-
96
javac.source: 1.8
107
javac.target: 1.8
118

12-
Automatic-Module-Name: org.javamoney.moneta.calc
13-
Bundle-Version: ${version}.${tstamp}
9+
Bundle-Version: ${project.version}.${tstamp}
1410
Bundle-Name: JavaMoney Moneta Calculations
1511
Bundle-SymbolicName: org.javamoney.moneta.calc
1612
Bundle-Description: JavaMoney - Calculation Library
@@ -21,8 +17,7 @@ Bundle-Vendor: Credit Suisse AG
2117
Bundle-DocURL: http://www.javamoney.org
2218
Import-Package: \
2319
javax.money,\
24-
javax.money.spi,\
25-
org.javamoney.moneta
20+
javax.money.spi
2621
Export-Package: \
2722
org.javamoney.calc,\
2823
org.javamoney.calc.banking,\

calc/pom.xml

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@
2222
<parent>
2323
<groupId>org.javamoney.lib</groupId>
2424
<artifactId>javamoney-lib</artifactId>
25-
<version>0.9-SNAPSHOT</version>
25+
<version>1.0</version>
2626
</parent>
2727

2828
<artifactId>javamoney-calc</artifactId>
2929
<name>Money and Currency - JavaMoney Calculations</name>
30-
<packaging>bundle</packaging>
30+
<packaging>jar</packaging>
3131
<!-- Try to find workaround for problem attaching sources to bundle, as
3232
of now manually switching to "jar" works -->
3333
<properties>
@@ -37,10 +37,6 @@
3737
</properties>
3838
<build>
3939
<plugins>
40-
<plugin>
41-
<groupId>org.apache.felix</groupId>
42-
<artifactId>maven-bundle-plugin</artifactId>
43-
</plugin>
4440
<plugin>
4541
<groupId>org.apache.maven.plugins</groupId>
4642
<artifactId>maven-source-plugin</artifactId>
@@ -53,6 +49,44 @@
5349
</execution>
5450
</executions>
5551
</plugin>
56-
</plugins>
52+
<plugin>
53+
<groupId>org.apache.maven.plugins</groupId>
54+
<artifactId>maven-compiler-plugin</artifactId>
55+
<version>3.7.0</version>
56+
<configuration>
57+
<source>9</source>
58+
<target>9</target>
59+
<excludes>
60+
<exclude>org.javamoney.calc/module-info.java</exclude>
61+
</excludes>
62+
</configuration>
63+
<executions>
64+
<execution>
65+
<id>default-compile</id>
66+
<configuration>
67+
<!-- compile everything to ensure module-info contains right entries -->
68+
<!-- required when JAVA_HOME is JDK 8 or below -->
69+
<jdkToolchain>
70+
<version>9</version>
71+
</jdkToolchain>
72+
<release>9</release>
73+
</configuration>
74+
</execution>
75+
<execution>
76+
<id>base-compile</id>
77+
<goals>
78+
<goal>compile</goal>
79+
</goals>
80+
<!-- recompile everything for target VM except the module-info.java -->
81+
<configuration>
82+
<excludes>
83+
<exclude>javax.money/module-info.java</exclude>
84+
</excludes>
85+
</configuration>
86+
</execution>
87+
</executions>
88+
89+
</plugin>
90+
</plugins>
5791
</build>
5892
</project>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* CREDIT SUISSE IS WILLING TO LICENSE THIS SPECIFICATION TO YOU ONLY UPON THE CONDITION THAT YOU
3+
* ACCEPT ALL OF THE TERMS CONTAINED IN THIS AGREEMENT. PLEASE READ THE TERMS AND CONDITIONS OF THIS
4+
* AGREEMENT CAREFULLY. BY DOWNLOADING THIS SPECIFICATION, YOU ACCEPT THE TERMS AND CONDITIONS OF
5+
* THE AGREEMENT. IF YOU ARE NOT WILLING TO BE BOUND BY IT, SELECT THE "DECLINE" BUTTON AT THE
6+
* BOTTOM OF THIS PAGE. Specification: JSR-354 Money and Currency API ("Specification") Copyright
7+
* (c) 2012-2013, Credit Suisse All rights reserved.
8+
*/
9+
module org.javamoney.calc {
10+
requires transitive java.money;
11+
requires transitive java.base;
12+
requires transitive java.logging;
13+
requires transitive java.annotation;
14+
exports org.javamoney.calc;
15+
exports org.javamoney.calc.common;
16+
exports org.javamoney.calc.banking;
17+
exports org.javamoney.calc.securities;
18+
}

calc/src/main/java/org/javamoney/calc/ValidatedAmount.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919

2020
import javax.money.MonetaryAmount;
2121

22-
import org.javamoney.moneta.Money;
23-
2422
import java.util.function.Predicate;
2523

2624

@@ -79,7 +77,7 @@ public static MonetaryAmount of(MonetaryAmount amount,
7977
private static final class UnsignedPredicate implements
8078
Predicate<MonetaryAmount> {
8179
public boolean test(MonetaryAmount amount) {
82-
return Money.from(amount).signum() >= 0;
80+
return amount.signum() >= 0;
8381
}
8482
}
8583
}

calc/src/main/java/org/javamoney/calc/ValidatedMoney.java

Lines changed: 69 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,7 @@
1717
*/
1818
package org.javamoney.calc;
1919

20-
import javax.money.CurrencyUnit;
21-
import javax.money.MonetaryAmount;
22-
import javax.money.MonetaryAmountFactory;
23-
import javax.money.MonetaryContext;
24-
import javax.money.MonetaryOperator;
25-
import javax.money.MonetaryQuery;
26-
import javax.money.NumberValue;
27-
28-
import org.javamoney.moneta.Money;
20+
import javax.money.*;
2921

3022
import java.util.function.Predicate;
3123

@@ -177,24 +169,6 @@ public ValidatedMoney plus() {
177169
return of(this.amount.plus(), predicate);
178170
}
179171

180-
/*
181-
* (non-Javadoc)
182-
*
183-
* @see javax.money.MonetaryAmount#subtract(javax.money.MonetaryAmount)
184-
*/
185-
public ValidatedMoney subtract(Money subtrahend) {
186-
return of(this.amount.subtract(subtrahend), predicate);
187-
}
188-
189-
// /*
190-
// * (non-Javadoc)
191-
// *
192-
// * @see javax.money.MonetaryAmount#ulp()
193-
// */
194-
// public ConstraintMoney ulp() {
195-
// return of(this.amount.ulp(), predicate);
196-
// }
197-
198172
/*
199173
* (non-Javadoc)
200174
*
@@ -417,13 +391,79 @@ public ValidatedMoney stripTrailingZeros() {
417391

418392
@Override
419393
public MonetaryAmountFactory<ValidatedMoney> getFactory() {
420-
return null;
421-
// return new ConstraintMoneyFactory(this);
394+
return new ValidatedAmountFactory(this);
422395
}
423396

424397
@Override
425398
public int compareTo(MonetaryAmount o) {
426399
return this.amount.compareTo(o);
427400
}
428401

402+
/**
403+
* Amount factory, which validates the amount created, based on the default amount factory.
404+
*/
405+
private final class ValidatedAmountFactory implements MonetaryAmountFactory<ValidatedMoney>{
406+
private Predicate<MonetaryAmount> predicate;
407+
private MonetaryAmountFactory<?> factory = Monetary.getDefaultAmountFactory();
408+
409+
public ValidatedAmountFactory(ValidatedMoney amount){
410+
this.predicate = amount.predicate;
411+
}
412+
413+
@Override
414+
public Class<? extends MonetaryAmount> getAmountType() {
415+
return ValidatedMoney.class;
416+
}
417+
418+
@Override
419+
public MonetaryAmountFactory setCurrency(CurrencyUnit currency) {
420+
factory.setCurrency(currency);
421+
return this;
422+
}
423+
424+
@Override
425+
public MonetaryAmountFactory setNumber(double number) {
426+
factory.setNumber(number);
427+
return this;
428+
}
429+
430+
@Override
431+
public MonetaryAmountFactory setNumber(long number) {
432+
factory.setNumber(number);
433+
return this;
434+
}
435+
436+
@Override
437+
public MonetaryAmountFactory setNumber(Number number) {
438+
factory.setNumber(number);
439+
return this;
440+
}
441+
442+
@Override
443+
public NumberValue getMaxNumber() {
444+
return factory.getMaxNumber();
445+
}
446+
447+
@Override
448+
public NumberValue getMinNumber() {
449+
return factory.getMinNumber();
450+
}
451+
452+
@Override
453+
public MonetaryAmountFactory setContext(MonetaryContext monetaryContext) {
454+
factory.setContext(monetaryContext);
455+
return this;
456+
}
457+
458+
@Override
459+
public ValidatedMoney create() {
460+
return new ValidatedMoney(factory.create(), predicate);
461+
}
462+
463+
@Override
464+
public MonetaryContext getDefaultMonetaryContext() {
465+
return factory.getDefaultMonetaryContext();
466+
}
467+
}
468+
429469
}

calc/src/main/java/org/javamoney/calc/common/AverageCollectionPeriod.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
package org.javamoney.calc.common;
1919

2020
import org.javamoney.calc.CalculationContext;
21-
import org.javamoney.moneta.spi.MoneyUtils;
2221

2322
import javax.money.MonetaryAmount;
2423
import javax.money.MonetaryQuery;
@@ -67,7 +66,7 @@ public BigDecimal getAvgAccountsReceivable() {
6766
*/
6867
public static BigDecimal calculate(Number receivablesTurnover) {
6968
return new BigDecimal(365, CalculationContext.mathContext())
70-
.divide(MoneyUtils.getBigDecimal(receivablesTurnover), CalculationContext.mathContext());
69+
.divide(new BigDecimal(receivablesTurnover.toString()), CalculationContext.mathContext());
7170
}
7271

7372
/**
@@ -77,7 +76,7 @@ public static BigDecimal calculate(Number receivablesTurnover) {
7776
* @return the receivables turnover, never null.
7877
*/
7978
public static BigDecimal receivablesTurnover(MonetaryAmount revenue, Number avgAccountsReceivable){
80-
return MoneyUtils.getBigDecimal(avgAccountsReceivable).divide(
79+
return new BigDecimal(avgAccountsReceivable.toString()).divide(
8180
revenue.getNumber().numberValue(BigDecimal.class), MathContext.DECIMAL64);
8281
}
8382

calc/src/main/java/org/javamoney/calc/common/BasisPoint.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
import javax.money.MonetaryAmount;
2525

2626
import org.javamoney.calc.CalculationContext;
27-
import org.javamoney.moneta.Money;
28-
import org.javamoney.moneta.spi.MoneyUtils;
2927

3028

3129
/**
@@ -69,7 +67,7 @@ public static BasisPoint of(Number number) {
6967
*/
7068
@Override
7169
public MonetaryAmount apply(MonetaryAmount amount) {
72-
return Money.from(amount).multiply(basisPointValue);
70+
return amount.multiply(basisPointValue);
7371
}
7472

7573
/*
@@ -111,7 +109,7 @@ public static MonetaryAmount calculate(MonetaryAmount amount, Number basisPoints
111109
* the basis points number, 10'000-ends.
112110
*/
113111
private static BigDecimal calcBasisPoint(Number number) {
114-
return MoneyUtils.getBigDecimal(number).divide(
112+
return new BigDecimal(number.toString()).divide(
115113
ONE_TENTHOUSAND, CalculationContext.mathContext());
116114
}
117115

calc/src/main/java/org/javamoney/calc/common/FutureValueWithContinuousCompounding.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919

2020
import javax.money.MonetaryAmount;
2121

22-
import com.ibm.icu.math.BigDecimal;
23-
22+
import java.math.BigDecimal;
2423
import java.util.Objects;
2524

2625
/**

calc/src/main/java/org/javamoney/calc/common/Rate.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
*/
1818
package org.javamoney.calc.common;
1919

20-
import org.javamoney.moneta.spi.MoneyUtils;
21-
2220
import java.math.BigDecimal;
2321
import java.util.Objects;
2422
import java.util.function.Supplier;
@@ -85,7 +83,7 @@ public static Rate of(BigDecimal rate, String info) {
8583
* the rate, not {@code null}.
8684
*/
8785
public static Rate of(Number rate) {
88-
return new Rate(MoneyUtils.getBigDecimal(rate), null);
86+
return new Rate(new BigDecimal(rate.toString()), null);
8987
}
9088

9189
/**
@@ -95,7 +93,7 @@ public static Rate of(Number rate) {
9593
* the rate, not {@code null}.
9694
*/
9795
public static Rate of(Number rate, String info) {
98-
return new Rate(MoneyUtils.getBigDecimal(rate), info);
96+
return new Rate(new BigDecimal(rate.toString()), info);
9997
}
10098

10199
/*

exchange/exchange-rate-frb/bnd.bnd

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,11 @@
33
osgi.core; version=6.0,\
44
osgi.cmpn; version=6.0
55

6-
-testpath: \
7-
${junit}
8-
96
javac.source: 1.8
107
javac.target: 1.8
118

129
Automatic-Module-Name: org.javamoney.moneta.convert.frb
13-
Bundle-Version: ${version}.${tstamp}
10+
Bundle-Version: ${project.version}.${tstamp}
1411
Bundle-Name: JavaMoney Moneta FRB Conversion
1512
Bundle-Activator: org.javamoney.moneta.convert.internal.frb.OSGIActivator
1613
Bundle-SymbolicName: org.javamoney.moneta.convert.frb

exchange/exchange-rate-frb/pom.xml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,14 @@
6060
<scope>test</scope>
6161
</dependency>
6262
<dependency>
63-
<groupId>org.javamoney</groupId>
64-
<artifactId>moneta</artifactId>
63+
<groupId>org.javamoney.moneta</groupId>
64+
<artifactId>moneta-core</artifactId>
65+
<version>${ri.version}</version>
66+
</dependency>
67+
<dependency>
68+
<groupId>org.javamoney.moneta</groupId>
69+
<artifactId>moneta-convert</artifactId>
70+
<version>${ri.version}</version>
6571
</dependency>
6672
<!-- OSGI support -->
6773
<dependency>

exchange/exchange-rate-yahoo/bnd.bnd

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,11 @@
33
osgi.core; version=6.0,\
44
osgi.cmpn; version=6.0
55

6-
-testpath: \
7-
${junit}
8-
96
javac.source: 1.8
107
javac.target: 1.8
118

129
Automatic-Module-Name: org.javamoney.moneta.convert.yahoo
13-
Bundle-Version: ${version}.${tstamp}
10+
Bundle-Version: ${project.version}.${tstamp}
1411
Bundle-Name: JavaMoney Moneta Yahoo Conversion
1512
Bundle-Activator: org.javamoney.moneta.convert.internal.yahoo.OSGIActivator
1613
Bundle-SymbolicName: org.javamoney.moneta.convert.yahoo

0 commit comments

Comments
 (0)