Skip to content

Commit

Permalink
Release build, fixed bnd descriptors, removed failing jacoco, added m…
Browse files Browse the repository at this point in the history
…issing deps.
  • Loading branch information
atsticks committed Apr 10, 2018
1 parent 4f5336d commit af4328a
Show file tree
Hide file tree
Showing 20 changed files with 364 additions and 108 deletions.
9 changes: 2 additions & 7 deletions calc/bnd.bnd
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,10 @@
osgi.core; version=6.0,\
osgi.cmpn; version=6.0

-testpath: \
${junit}

javac.source: 1.8
javac.target: 1.8

Automatic-Module-Name: org.javamoney.moneta.calc
Bundle-Version: ${version}.${tstamp}
Bundle-Version: ${project.version}.${tstamp}
Bundle-Name: JavaMoney Moneta Calculations
Bundle-SymbolicName: org.javamoney.moneta.calc
Bundle-Description: JavaMoney - Calculation Library
Expand All @@ -21,8 +17,7 @@ Bundle-Vendor: Credit Suisse AG
Bundle-DocURL: http://www.javamoney.org
Import-Package: \
javax.money,\
javax.money.spi,\
org.javamoney.moneta
javax.money.spi
Export-Package: \
org.javamoney.calc,\
org.javamoney.calc.banking,\
Expand Down
48 changes: 41 additions & 7 deletions calc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
<parent>
<groupId>org.javamoney.lib</groupId>
<artifactId>javamoney-lib</artifactId>
<version>0.9-SNAPSHOT</version>
<version>1.0</version>
</parent>

<artifactId>javamoney-calc</artifactId>
<name>Money and Currency - JavaMoney Calculations</name>
<packaging>bundle</packaging>
<packaging>jar</packaging>
<!-- Try to find workaround for problem attaching sources to bundle, as
of now manually switching to "jar" works -->
<properties>
Expand All @@ -37,10 +37,6 @@
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
Expand All @@ -53,6 +49,44 @@
</execution>
</executions>
</plugin>
</plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>9</source>
<target>9</target>
<excludes>
<exclude>org.javamoney.calc/module-info.java</exclude>
</excludes>
</configuration>
<executions>
<execution>
<id>default-compile</id>
<configuration>
<!-- compile everything to ensure module-info contains right entries -->
<!-- required when JAVA_HOME is JDK 8 or below -->
<jdkToolchain>
<version>9</version>
</jdkToolchain>
<release>9</release>
</configuration>
</execution>
<execution>
<id>base-compile</id>
<goals>
<goal>compile</goal>
</goals>
<!-- recompile everything for target VM except the module-info.java -->
<configuration>
<excludes>
<exclude>javax.money/module-info.java</exclude>
</excludes>
</configuration>
</execution>
</executions>

</plugin>
</plugins>
</build>
</project>
18 changes: 18 additions & 0 deletions calc/src/main/java/org.javamoney.calc/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* CREDIT SUISSE IS WILLING TO LICENSE THIS SPECIFICATION TO YOU ONLY UPON THE CONDITION THAT YOU
* ACCEPT ALL OF THE TERMS CONTAINED IN THIS AGREEMENT. PLEASE READ THE TERMS AND CONDITIONS OF THIS
* AGREEMENT CAREFULLY. BY DOWNLOADING THIS SPECIFICATION, YOU ACCEPT THE TERMS AND CONDITIONS OF
* THE AGREEMENT. IF YOU ARE NOT WILLING TO BE BOUND BY IT, SELECT THE "DECLINE" BUTTON AT THE
* BOTTOM OF THIS PAGE. Specification: JSR-354 Money and Currency API ("Specification") Copyright
* (c) 2012-2013, Credit Suisse All rights reserved.
*/
module org.javamoney.calc {
requires transitive java.money;
requires transitive java.base;
requires transitive java.logging;
requires transitive java.annotation;
exports org.javamoney.calc;
exports org.javamoney.calc.common;
exports org.javamoney.calc.banking;
exports org.javamoney.calc.securities;
}
4 changes: 1 addition & 3 deletions calc/src/main/java/org/javamoney/calc/ValidatedAmount.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

import javax.money.MonetaryAmount;

import org.javamoney.moneta.Money;

import java.util.function.Predicate;


Expand Down Expand Up @@ -79,7 +77,7 @@ public static MonetaryAmount of(MonetaryAmount amount,
private static final class UnsignedPredicate implements
Predicate<MonetaryAmount> {
public boolean test(MonetaryAmount amount) {
return Money.from(amount).signum() >= 0;
return amount.signum() >= 0;
}
}
}
98 changes: 69 additions & 29 deletions calc/src/main/java/org/javamoney/calc/ValidatedMoney.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,7 @@
*/
package org.javamoney.calc;

import javax.money.CurrencyUnit;
import javax.money.MonetaryAmount;
import javax.money.MonetaryAmountFactory;
import javax.money.MonetaryContext;
import javax.money.MonetaryOperator;
import javax.money.MonetaryQuery;
import javax.money.NumberValue;

import org.javamoney.moneta.Money;
import javax.money.*;

import java.util.function.Predicate;

Expand Down Expand Up @@ -177,24 +169,6 @@ public ValidatedMoney plus() {
return of(this.amount.plus(), predicate);
}

/*
* (non-Javadoc)
*
* @see javax.money.MonetaryAmount#subtract(javax.money.MonetaryAmount)
*/
public ValidatedMoney subtract(Money subtrahend) {
return of(this.amount.subtract(subtrahend), predicate);
}

// /*
// * (non-Javadoc)
// *
// * @see javax.money.MonetaryAmount#ulp()
// */
// public ConstraintMoney ulp() {
// return of(this.amount.ulp(), predicate);
// }

/*
* (non-Javadoc)
*
Expand Down Expand Up @@ -417,13 +391,79 @@ public ValidatedMoney stripTrailingZeros() {

@Override
public MonetaryAmountFactory<ValidatedMoney> getFactory() {
return null;
// return new ConstraintMoneyFactory(this);
return new ValidatedAmountFactory(this);
}

@Override
public int compareTo(MonetaryAmount o) {
return this.amount.compareTo(o);
}

/**
* Amount factory, which validates the amount created, based on the default amount factory.
*/
private final class ValidatedAmountFactory implements MonetaryAmountFactory<ValidatedMoney>{
private Predicate<MonetaryAmount> predicate;
private MonetaryAmountFactory<?> factory = Monetary.getDefaultAmountFactory();

public ValidatedAmountFactory(ValidatedMoney amount){
this.predicate = amount.predicate;
}

@Override
public Class<? extends MonetaryAmount> getAmountType() {
return ValidatedMoney.class;
}

@Override
public MonetaryAmountFactory setCurrency(CurrencyUnit currency) {
factory.setCurrency(currency);
return this;
}

@Override
public MonetaryAmountFactory setNumber(double number) {
factory.setNumber(number);
return this;
}

@Override
public MonetaryAmountFactory setNumber(long number) {
factory.setNumber(number);
return this;
}

@Override
public MonetaryAmountFactory setNumber(Number number) {
factory.setNumber(number);
return this;
}

@Override
public NumberValue getMaxNumber() {
return factory.getMaxNumber();
}

@Override
public NumberValue getMinNumber() {
return factory.getMinNumber();
}

@Override
public MonetaryAmountFactory setContext(MonetaryContext monetaryContext) {
factory.setContext(monetaryContext);
return this;
}

@Override
public ValidatedMoney create() {
return new ValidatedMoney(factory.create(), predicate);
}

@Override
public MonetaryContext getDefaultMonetaryContext() {
return factory.getDefaultMonetaryContext();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package org.javamoney.calc.common;

import org.javamoney.calc.CalculationContext;
import org.javamoney.moneta.spi.MoneyUtils;

import javax.money.MonetaryAmount;
import javax.money.MonetaryQuery;
Expand Down Expand Up @@ -67,7 +66,7 @@ public BigDecimal getAvgAccountsReceivable() {
*/
public static BigDecimal calculate(Number receivablesTurnover) {
return new BigDecimal(365, CalculationContext.mathContext())
.divide(MoneyUtils.getBigDecimal(receivablesTurnover), CalculationContext.mathContext());
.divide(new BigDecimal(receivablesTurnover.toString()), CalculationContext.mathContext());
}

/**
Expand All @@ -77,7 +76,7 @@ public static BigDecimal calculate(Number receivablesTurnover) {
* @return the receivables turnover, never null.
*/
public static BigDecimal receivablesTurnover(MonetaryAmount revenue, Number avgAccountsReceivable){
return MoneyUtils.getBigDecimal(avgAccountsReceivable).divide(
return new BigDecimal(avgAccountsReceivable.toString()).divide(
revenue.getNumber().numberValue(BigDecimal.class), MathContext.DECIMAL64);
}

Expand Down
6 changes: 2 additions & 4 deletions calc/src/main/java/org/javamoney/calc/common/BasisPoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
import javax.money.MonetaryAmount;

import org.javamoney.calc.CalculationContext;
import org.javamoney.moneta.Money;
import org.javamoney.moneta.spi.MoneyUtils;


/**
Expand Down Expand Up @@ -69,7 +67,7 @@ public static BasisPoint of(Number number) {
*/
@Override
public MonetaryAmount apply(MonetaryAmount amount) {
return Money.from(amount).multiply(basisPointValue);
return amount.multiply(basisPointValue);
}

/*
Expand Down Expand Up @@ -111,7 +109,7 @@ public static MonetaryAmount calculate(MonetaryAmount amount, Number basisPoints
* the basis points number, 10'000-ends.
*/
private static BigDecimal calcBasisPoint(Number number) {
return MoneyUtils.getBigDecimal(number).divide(
return new BigDecimal(number.toString()).divide(
ONE_TENTHOUSAND, CalculationContext.mathContext());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@

import javax.money.MonetaryAmount;

import com.ibm.icu.math.BigDecimal;

import java.math.BigDecimal;
import java.util.Objects;

/**
Expand Down
6 changes: 2 additions & 4 deletions calc/src/main/java/org/javamoney/calc/common/Rate.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
*/
package org.javamoney.calc.common;

import org.javamoney.moneta.spi.MoneyUtils;

import java.math.BigDecimal;
import java.util.Objects;
import java.util.function.Supplier;
Expand Down Expand Up @@ -85,7 +83,7 @@ public static Rate of(BigDecimal rate, String info) {
* the rate, not {@code null}.
*/
public static Rate of(Number rate) {
return new Rate(MoneyUtils.getBigDecimal(rate), null);
return new Rate(new BigDecimal(rate.toString()), null);
}

/**
Expand All @@ -95,7 +93,7 @@ public static Rate of(Number rate) {
* the rate, not {@code null}.
*/
public static Rate of(Number rate, String info) {
return new Rate(MoneyUtils.getBigDecimal(rate), info);
return new Rate(new BigDecimal(rate.toString()), info);
}

/*
Expand Down
5 changes: 1 addition & 4 deletions exchange/exchange-rate-frb/bnd.bnd
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@
osgi.core; version=6.0,\
osgi.cmpn; version=6.0

-testpath: \
${junit}

javac.source: 1.8
javac.target: 1.8

Automatic-Module-Name: org.javamoney.moneta.convert.frb
Bundle-Version: ${version}.${tstamp}
Bundle-Version: ${project.version}.${tstamp}
Bundle-Name: JavaMoney Moneta FRB Conversion
Bundle-Activator: org.javamoney.moneta.convert.internal.frb.OSGIActivator
Bundle-SymbolicName: org.javamoney.moneta.convert.frb
Expand Down
10 changes: 8 additions & 2 deletions exchange/exchange-rate-frb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,14 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.javamoney</groupId>
<artifactId>moneta</artifactId>
<groupId>org.javamoney.moneta</groupId>
<artifactId>moneta-core</artifactId>
<version>${ri.version}</version>
</dependency>
<dependency>
<groupId>org.javamoney.moneta</groupId>
<artifactId>moneta-convert</artifactId>
<version>${ri.version}</version>
</dependency>
<!-- OSGI support -->
<dependency>
Expand Down
5 changes: 1 addition & 4 deletions exchange/exchange-rate-yahoo/bnd.bnd
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@
osgi.core; version=6.0,\
osgi.cmpn; version=6.0

-testpath: \
${junit}

javac.source: 1.8
javac.target: 1.8

Automatic-Module-Name: org.javamoney.moneta.convert.yahoo
Bundle-Version: ${version}.${tstamp}
Bundle-Version: ${project.version}.${tstamp}
Bundle-Name: JavaMoney Moneta Yahoo Conversion
Bundle-Activator: org.javamoney.moneta.convert.internal.yahoo.OSGIActivator
Bundle-SymbolicName: org.javamoney.moneta.convert.yahoo
Expand Down
Loading

0 comments on commit af4328a

Please sign in to comment.