1717 */
1818package org .javamoney .cdi .internal ;
1919
20- import org .javamoney .cdi .api . AmountSpec ;
21- import org .javamoney .cdi .api . CurrencySpec ;
22- import org .javamoney .cdi .api . FormatSpec ;
23- import org .javamoney .cdi .api . ConversionSpec ;
20+ import org .javamoney .cdi .Amount ;
21+ import org .javamoney .cdi .AmountConversion ;
22+ import org .javamoney .cdi .AmountCurrency ;
23+ import org .javamoney .cdi .AmountFormat ;
2424
2525import javax .enterprise .context .Dependent ;
2626import javax .enterprise .inject .Produces ;
@@ -49,11 +49,11 @@ private MonetaryProducer(){}
4949
5050 @ Produces @ Dependent
5151 public static CurrencyUnit currencyUnit (InjectionPoint ip ){
52- CurrencySpec specAnnot = ip .getAnnotated ()!=null ?
53- ip .getAnnotated ().getAnnotation (CurrencySpec .class ):
52+ AmountCurrency specAnnot = ip .getAnnotated ()!=null ?
53+ ip .getAnnotated ().getAnnotation (AmountCurrency .class ):
5454 null ;
5555 if (specAnnot ==null ){
56- Currency jdkDefault = Currency .getInstance (Locale .getDefault ());
56+ java . util . Currency jdkDefault = java . util . Currency .getInstance (Locale .getDefault ());
5757 if (jdkDefault !=null ) {
5858 return Monetary .getCurrency (jdkDefault .getCurrencyCode ());
5959 }else {
@@ -66,7 +66,7 @@ public static CurrencyUnit currencyUnit(InjectionPoint ip){
6666
6767 @ Produces @ Dependent
6868 public static Collection <CurrencyUnit > currencyUnits (InjectionPoint ip ){
69- CurrencySpec specAnnot = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (CurrencySpec .class ):null ;
69+ AmountCurrency specAnnot = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (AmountCurrency .class ):null ;
7070 if (specAnnot !=null ){
7171 return Monetary .getCurrencies (createCurrencyQuery (specAnnot ));
7272 }
@@ -76,7 +76,7 @@ public static Collection<CurrencyUnit> currencyUnits(InjectionPoint ip){
7676
7777 @ Produces @ Dependent
7878 public static ExchangeRateProvider rateProvider (InjectionPoint ip ){
79- ConversionSpec specAnnot = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (ConversionSpec .class ):null ;
79+ AmountConversion specAnnot = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (AmountConversion .class ):null ;
8080 if (specAnnot !=null ){
8181 return MonetaryConversions .getExchangeRateProvider (createConversionQuery (specAnnot ));
8282 }
@@ -86,7 +86,7 @@ public static ExchangeRateProvider rateProvider(InjectionPoint ip){
8686 @ Produces @ Dependent
8787 public static Collection <ExchangeRateProvider > rateProviders (InjectionPoint ip ){
8888 List <ExchangeRateProvider > providers = new ArrayList <>();
89- ConversionSpec specAnnot = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (ConversionSpec .class ):null ;
89+ AmountConversion specAnnot = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (AmountConversion .class ):null ;
9090 if (specAnnot !=null && specAnnot .providers ().length >0 ){
9191 for (String providerId :specAnnot .providers ()){
9292 providers .add (MonetaryConversions .getExchangeRateProvider (providerId ));
@@ -102,7 +102,7 @@ public static Collection<ExchangeRateProvider> rateProviders(InjectionPoint ip){
102102
103103 @ Produces @ Dependent
104104 public static CurrencyConversion currencyConversion (InjectionPoint ip ){
105- ConversionSpec specAnnot = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (ConversionSpec .class ):null ;
105+ AmountConversion specAnnot = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (AmountConversion .class ):null ;
106106 if (specAnnot ==null ){
107107 throw new IllegalArgumentException ("@RateSpec is required." );
108108 }
@@ -111,7 +111,7 @@ public static CurrencyConversion currencyConversion(InjectionPoint ip){
111111
112112 @ Produces @ Dependent
113113 public static ExchangeRate exchangeRate (InjectionPoint ip ){
114- ConversionSpec specAnnot = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (ConversionSpec .class ):null ;
114+ AmountConversion specAnnot = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (AmountConversion .class ):null ;
115115 if (specAnnot ==null ){
116116 throw new IllegalArgumentException ("@RateSpec is required." );
117117 }
@@ -122,7 +122,7 @@ public static ExchangeRate exchangeRate(InjectionPoint ip){
122122
123123 @ Produces @ Dependent
124124 public static Collection <ExchangeRate > exchangeRates (InjectionPoint ip ){
125- ConversionSpec specAnnot = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (ConversionSpec .class ):null ;
125+ AmountConversion specAnnot = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (AmountConversion .class ):null ;
126126 if (specAnnot ==null ){
127127 throw new IllegalArgumentException ("@RateSpec is required." );
128128 }
@@ -151,31 +151,31 @@ public static Collection<ExchangeRate> exchangeRates(InjectionPoint ip){
151151
152152 @ Produces @ Dependent
153153 public static MonetaryAmountFormat amountFormat (InjectionPoint ip ){
154- FormatSpec specAnnot = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (FormatSpec .class ):null ;
154+ AmountFormat specAnnot = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (AmountFormat .class ):null ;
155155 if (specAnnot ==null ){
156156 throw new IllegalArgumentException ("@FormatName is required." );
157157 }
158158 return MonetaryFormats .getAmountFormat (createAmountFormatQuery (
159159 specAnnot ,
160- ip .getAnnotated ().getAnnotation (AmountSpec .class )));
160+ ip .getAnnotated ().getAnnotation (Amount .class )));
161161 }
162162
163163
164164 @ Produces @ Dependent
165165 public static Collection <MonetaryAmountFormat > amountFormats (InjectionPoint ip ){
166- FormatSpec specAnnot = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (FormatSpec .class ):null ;
166+ AmountFormat specAnnot = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (AmountFormat .class ):null ;
167167 if (specAnnot ==null ){
168168 throw new IllegalArgumentException ("@FormatName is required." );
169169 }
170170 return MonetaryFormats .getAmountFormats (createAmountFormatQuery (
171171 specAnnot ,
172- ip .getAnnotated ().getAnnotation (AmountSpec .class )));
172+ ip .getAnnotated ().getAnnotation (Amount .class )));
173173 }
174174
175175
176176 @ Produces @ Dependent
177177 public static MonetaryAmountFactory amountFactory (InjectionPoint ip ){
178- AmountSpec specAnnot = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (AmountSpec .class ):null ;
178+ Amount specAnnot = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (Amount .class ):null ;
179179 if (specAnnot !=null ){
180180 return Monetary .getAmountFactory (createAmountQuery (specAnnot ));
181181 }
@@ -186,7 +186,7 @@ public static MonetaryAmountFactory amountFactory(InjectionPoint ip){
186186 @ SuppressWarnings ("unchecked" )
187187 @ Produces @ Dependent
188188 public static Collection <MonetaryAmountFactory > amountFactories (InjectionPoint ip ){
189- AmountSpec specAnnot = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (AmountSpec .class ):null ;
189+ Amount specAnnot = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (Amount .class ):null ;
190190 if (specAnnot !=null ){
191191 return Collection .class .cast (Monetary .getAmountFactories (createAmountQuery (specAnnot )));
192192 }
@@ -195,7 +195,7 @@ public static Collection<MonetaryAmountFactory> amountFactories(InjectionPoint i
195195
196196 @ Produces @ Dependent
197197 public static CurrencyQuery currencyQuery (InjectionPoint ip ){
198- CurrencySpec specAnnot = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (CurrencySpec .class ):null ;
198+ AmountCurrency specAnnot = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (AmountCurrency .class ):null ;
199199 if (specAnnot ==null ){
200200 return null ;
201201 }
@@ -204,7 +204,7 @@ public static CurrencyQuery currencyQuery(InjectionPoint ip){
204204
205205 @ Produces @ Dependent
206206 public static ConversionQuery conversionQuery (InjectionPoint ip ){
207- ConversionSpec specAnnot = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (ConversionSpec .class ):null ;
207+ AmountConversion specAnnot = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (AmountConversion .class ):null ;
208208 if (specAnnot ==null ){
209209 return null ;
210210 }
@@ -213,24 +213,24 @@ public static ConversionQuery conversionQuery(InjectionPoint ip){
213213
214214 @ Produces @ Dependent
215215 public static AmountFormatQuery amountFormatQuery (InjectionPoint ip ){
216- FormatSpec specAnnot = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (FormatSpec .class ):null ;
216+ AmountFormat specAnnot = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (AmountFormat .class ):null ;
217217 if (specAnnot ==null ){
218218 return null ;
219219 }
220- AmountSpec amountSpec = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (AmountSpec .class ):null ;
220+ Amount amountSpec = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (Amount .class ):null ;
221221 return createAmountFormatQuery (specAnnot , amountSpec );
222222 }
223223
224224 @ Produces @ Dependent
225225 public static MonetaryAmountFactoryQuery amountFactoryQuery (InjectionPoint ip ){
226- AmountSpec amountSpec = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (AmountSpec .class ):null ;
226+ Amount amountSpec = ip .getAnnotated ()!=null ?ip .getAnnotated ().getAnnotation (Amount .class ):null ;
227227 if (amountSpec ==null ){
228228 return null ;
229229 }
230230 return createAmountQuery (amountSpec );
231231 }
232232
233- private static CurrencyQuery createCurrencyQuery (CurrencySpec specAnnot ) {
233+ private static CurrencyQuery createCurrencyQuery (AmountCurrency specAnnot ) {
234234 CurrencyQueryBuilder b = CurrencyQueryBuilder .of ();
235235 b .setCountries (convertToCountries (specAnnot .countries ()));
236236 b .setCurrencyCodes (specAnnot .codes ());
@@ -252,7 +252,7 @@ private static Locale[] convertToCountries(String[] codes) {
252252 return locales ;
253253 }
254254
255- private static ConversionQuery createConversionQuery (ConversionSpec specAnnot ) {
255+ private static ConversionQuery createConversionQuery (AmountConversion specAnnot ) {
256256 ConversionQueryBuilder b = ConversionQueryBuilder .of ();
257257 if (!specAnnot .baseCurrency ().isEmpty ()){
258258 b .setBaseCurrency (specAnnot .baseCurrency ());
@@ -272,7 +272,7 @@ private static ConversionQuery createConversionQuery(ConversionSpec specAnnot) {
272272 return b .build ();
273273 }
274274
275- private static AmountFormatQuery createAmountFormatQuery (FormatSpec specAnnot , AmountSpec amountSpec ) {
275+ private static AmountFormatQuery createAmountFormatQuery (AmountFormat specAnnot , Amount amountSpec ) {
276276 AmountFormatQueryBuilder b = AmountFormatQueryBuilder .of (specAnnot .name ());
277277 if (specAnnot .providers ().length >0 ){
278278 b .setProviderNames (specAnnot .providers ());
@@ -304,7 +304,7 @@ private static Locale createLocale(String locale) {
304304 }
305305 }
306306
307- private static MonetaryAmountFactoryQuery createAmountQuery (AmountSpec specAnnot ) {
307+ private static MonetaryAmountFactoryQuery createAmountQuery (Amount specAnnot ) {
308308 MonetaryAmountFactoryQueryBuilder b = MonetaryAmountFactoryQueryBuilder .of ();
309309 if (specAnnot .value ()!=MonetaryAmount .class ){
310310 b .setTargetType (specAnnot .value ());
0 commit comments