Skip to content

Commit 8337aa8

Browse files
committed
4: Implement Money and Currency SPI for Bitcoin
Task-Url: http://github.com/JavaMoney/javamoney-shelter/issues/issue/4
1 parent 7587919 commit 8337aa8

File tree

5 files changed

+152
-102
lines changed

5 files changed

+152
-102
lines changed

digital-currency/bitcoin/pom.xml

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>org.javamoney.shelter</groupId>
66
<artifactId>javamoney-digital-currency</artifactId>
7-
<version>0.4-SNAPSHOT</version>
7+
<version>0.4</version>
88
</parent>
99
<artifactId>javamoney-bitcoin</artifactId>
1010
<name>JavaMoney Bitcoin</name>
@@ -62,7 +62,6 @@
6262
<plugin>
6363
<groupId>org.apache.maven.plugins</groupId>
6464
<artifactId>maven-surefire-plugin</artifactId>
65-
<version>2.12.4</version>
6665
<configuration>
6766
<includes>
6867
<include>**/*Spec.java</include> <!-- For Spock Specs (which are actually .groovy!?) -->
@@ -71,6 +70,42 @@
7170
</configuration>
7271
</plugin>
7372
</plugins>
73+
<pluginManagement>
74+
<plugins>
75+
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
76+
<plugin>
77+
<groupId>org.eclipse.m2e</groupId>
78+
<artifactId>lifecycle-mapping</artifactId>
79+
<version>1.0.0</version>
80+
<configuration>
81+
<lifecycleMappingMetadata>
82+
<pluginExecutions>
83+
<pluginExecution>
84+
<pluginExecutionFilter>
85+
<groupId>
86+
org.codehaus.gmaven
87+
</groupId>
88+
<artifactId>
89+
gmaven-plugin
90+
</artifactId>
91+
<versionRange>
92+
[1.4,)
93+
</versionRange>
94+
<goals>
95+
<goal>compile</goal>
96+
<goal>testCompile</goal>
97+
</goals>
98+
</pluginExecutionFilter>
99+
<action>
100+
<ignore></ignore>
101+
</action>
102+
</pluginExecution>
103+
</pluginExecutions>
104+
</lifecycleMappingMetadata>
105+
</configuration>
106+
</plugin>
107+
</plugins>
108+
</pluginManagement>
74109
</build>
75110
<dependencies>
76111
<dependency>

digital-currency/bitcoin/src/main/java/org/javamoney/shelter/bitcoin/provider/BitcoinCurrencyProvider.java

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,36 @@
1+
/*
2+
* Copyright (c) 2013, 205, Werner Keil and others by the @author tag.
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
115
package org.javamoney.shelter.bitcoin.provider;
216

317
import javax.money.CurrencyContext;
418
import javax.money.CurrencyContextBuilder;
519
import javax.money.CurrencyQuery;
620
import javax.money.CurrencyUnit;
7-
import javax.money.MonetaryAmountFactoryQuery;
8-
import javax.money.MonetaryAmountFactoryQueryBuilder;
9-
import javax.money.MonetaryContext;
1021
import javax.money.spi.CurrencyProviderSpi;
1122
import java.util.Collections;
12-
import java.util.Currency;
1323
import java.util.HashSet;
1424
import java.util.Set;
1525

1626
import org.javamoney.moneta.CurrencyUnitBuilder;
17-
import org.javamoney.moneta.Money;
1827

1928
/**
2029
* A clueless attempt at a BitcoinCurrencyProvider based on (out of date?) code
2130
* in the Moneta User's Guide.
2231
*
2332
* @author Sean Gilligan
33+
* @author Werner Keil
2434
*/
2535
public final class BitcoinCurrencyProvider implements CurrencyProviderSpi {
2636

@@ -61,4 +71,9 @@ public Set<CurrencyUnit> getCurrencies(CurrencyQuery query){
6171
return Collections.emptySet();
6272
}
6373

74+
@Override
75+
public boolean isCurrencyAvailable(CurrencyQuery query) {
76+
return !getCurrencies(query).isEmpty();
77+
}
78+
6479
}

digital-currency/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>org.javamoney.shelter</groupId>
66
<artifactId>javamoney-shelter</artifactId>
7-
<version>0.4-SNAPSHOT</version>
7+
<version>0.4</version>
88
</parent>
99
<artifactId>javamoney-digital-currency</artifactId>
1010
<packaging>pom</packaging>
Lines changed: 90 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,90 @@
1-
@if "%DEBUG%" == "" @echo off
2-
@rem ##########################################################################
3-
@rem
4-
@rem Gradle startup script for Windows
5-
@rem
6-
@rem ##########################################################################
7-
8-
@rem Set local scope for the variables with windows NT shell
9-
if "%OS%"=="Windows_NT" setlocal
10-
11-
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12-
set DEFAULT_JVM_OPTS=
13-
14-
set DIRNAME=%~dp0
15-
if "%DIRNAME%" == "" set DIRNAME=.
16-
set APP_BASE_NAME=%~n0
17-
set APP_HOME=%DIRNAME%
18-
19-
@rem Find java.exe
20-
if defined JAVA_HOME goto findJavaFromJavaHome
21-
22-
set JAVA_EXE=java.exe
23-
%JAVA_EXE% -version >NUL 2>&1
24-
if "%ERRORLEVEL%" == "0" goto init
25-
26-
echo.
27-
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28-
echo.
29-
echo Please set the JAVA_HOME variable in your environment to match the
30-
echo location of your Java installation.
31-
32-
goto fail
33-
34-
:findJavaFromJavaHome
35-
set JAVA_HOME=%JAVA_HOME:"=%
36-
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37-
38-
if exist "%JAVA_EXE%" goto init
39-
40-
echo.
41-
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42-
echo.
43-
echo Please set the JAVA_HOME variable in your environment to match the
44-
echo location of your Java installation.
45-
46-
goto fail
47-
48-
:init
49-
@rem Get command-line arguments, handling Windowz variants
50-
51-
if not "%OS%" == "Windows_NT" goto win9xME_args
52-
if "%@eval[2+2]" == "4" goto 4NT_args
53-
54-
:win9xME_args
55-
@rem Slurp the command line arguments.
56-
set CMD_LINE_ARGS=
57-
set _SKIP=2
58-
59-
:win9xME_args_slurp
60-
if "x%~1" == "x" goto execute
61-
62-
set CMD_LINE_ARGS=%*
63-
goto execute
64-
65-
:4NT_args
66-
@rem Get arguments from the 4NT Shell from JP Software
67-
set CMD_LINE_ARGS=%$
68-
69-
:execute
70-
@rem Setup the command line
71-
72-
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73-
74-
@rem Execute Gradle
75-
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76-
77-
:end
78-
@rem End local scope for the variables with windows NT shell
79-
if "%ERRORLEVEL%"=="0" goto mainEnd
80-
81-
:fail
82-
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83-
rem the _cmd.exe /c_ return code!
84-
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85-
exit /b 1
86-
87-
:mainEnd
88-
if "%OS%"=="Windows_NT" endlocal
89-
90-
:omega
1+
@if "%DEBUG%" == "" @echo off
2+
@rem ##########################################################################
3+
@rem
4+
@rem Gradle startup script for Windows
5+
@rem
6+
@rem ##########################################################################
7+
8+
@rem Set local scope for the variables with windows NT shell
9+
if "%OS%"=="Windows_NT" setlocal
10+
11+
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12+
set DEFAULT_JVM_OPTS=
13+
14+
set DIRNAME=%~dp0
15+
if "%DIRNAME%" == "" set DIRNAME=.
16+
set APP_BASE_NAME=%~n0
17+
set APP_HOME=%DIRNAME%
18+
19+
@rem Find java.exe
20+
if defined JAVA_HOME goto findJavaFromJavaHome
21+
22+
set JAVA_EXE=java.exe
23+
%JAVA_EXE% -version >NUL 2>&1
24+
if "%ERRORLEVEL%" == "0" goto init
25+
26+
echo.
27+
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28+
echo.
29+
echo Please set the JAVA_HOME variable in your environment to match the
30+
echo location of your Java installation.
31+
32+
goto fail
33+
34+
:findJavaFromJavaHome
35+
set JAVA_HOME=%JAVA_HOME:"=%
36+
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37+
38+
if exist "%JAVA_EXE%" goto init
39+
40+
echo.
41+
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42+
echo.
43+
echo Please set the JAVA_HOME variable in your environment to match the
44+
echo location of your Java installation.
45+
46+
goto fail
47+
48+
:init
49+
@rem Get command-line arguments, handling Windowz variants
50+
51+
if not "%OS%" == "Windows_NT" goto win9xME_args
52+
if "%@eval[2+2]" == "4" goto 4NT_args
53+
54+
:win9xME_args
55+
@rem Slurp the command line arguments.
56+
set CMD_LINE_ARGS=
57+
set _SKIP=2
58+
59+
:win9xME_args_slurp
60+
if "x%~1" == "x" goto execute
61+
62+
set CMD_LINE_ARGS=%*
63+
goto execute
64+
65+
:4NT_args
66+
@rem Get arguments from the 4NT Shell from JP Software
67+
set CMD_LINE_ARGS=%$
68+
69+
:execute
70+
@rem Setup the command line
71+
72+
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73+
74+
@rem Execute Gradle
75+
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76+
77+
:end
78+
@rem End local scope for the variables with windows NT shell
79+
if "%ERRORLEVEL%"=="0" goto mainEnd
80+
81+
:fail
82+
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83+
rem the _cmd.exe /c_ return code!
84+
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85+
exit /b 1
86+
87+
:mainEnd
88+
if "%OS%"=="Windows_NT" endlocal
89+
90+
:omega

pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>org.javamoney.shelter</groupId>
55
<artifactId>javamoney-shelter</artifactId>
6-
<version>0.4-SNAPSHOT</version>
6+
<version>0.4</version>
77
<packaging>pom</packaging>
88
<name>JavaMoney Shelter</name>
99
<description>A shelter for new ideas and modules to be adopted, e.g. via Adopt-a-JSR </description>
1010
<parent>
1111
<groupId>org.javamoney</groupId>
1212
<artifactId>javamoney-parent</artifactId>
13-
<version>1.0-RC1</version>
13+
<version>1.0-RC2</version>
1414
</parent>
1515
<url>http://javamoney.github.io/shelter.html</url>
1616
<inceptionYear>2013</inceptionYear>
@@ -21,8 +21,8 @@
2121
<junit.version>4.8.2</junit.version>
2222
<slf4j.version>1.6.1</slf4j.version>
2323
<!-- JSR versions -->
24-
<jsr.version>1.0-RC1</jsr.version>
25-
<javamoney.version>0.6-SNAPSHOT</javamoney.version>
24+
<jsr.version>1.0-RC2</jsr.version>
25+
<!-- javamoney.version>0.6-SNAPSHOT</javamoney.version -->
2626
</properties>
2727

2828
<repositories>

0 commit comments

Comments
 (0)