PriceInfo.java
2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* aQute.bnd.annotation.ProviderType
* org.apache.sling.api.wrappers.ValueMapDecorator
*/
package com.adobe.cq.commerce.api;
import aQute.bnd.annotation.ProviderType;
import java.math.BigDecimal;
import java.text.NumberFormat;
import java.util.Currency;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import org.apache.sling.api.wrappers.ValueMapDecorator;
@ProviderType
public class PriceInfo
extends ValueMapDecorator {
public static final String MIN_QUANTITY = "minQuantity";
private BigDecimal amount;
private Currency currency;
private Locale locale;
@Deprecated
public PriceInfo(BigDecimal amount, Currency currency) {
super(new HashMap());
this.amount = amount;
this.currency = currency;
this.locale = null;
}
public PriceInfo(BigDecimal amount, Locale locale) {
super(new HashMap());
this.amount = amount;
this.currency = Currency.getInstance(locale);
this.locale = locale;
}
public PriceInfo(BigDecimal amount, Locale locale, Currency currency) {
super(new HashMap());
this.amount = amount;
this.locale = locale;
this.currency = currency;
}
public BigDecimal getAmount() {
return this.amount;
}
public long getQuantity() {
return (Long)this.get("minQuantity", (Object)1);
}
public Locale getLocale() {
return this.locale;
}
public Currency getCurrency() {
return this.currency;
}
public String getFormattedString() {
NumberFormat nf;
if (this.amount == null) {
return "";
}
if (this.locale != null) {
nf = NumberFormat.getCurrencyInstance(this.locale);
nf.setCurrency(this.currency);
} else {
nf = NumberFormat.getCurrencyInstance();
nf.setCurrency(this.currency);
nf.setMinimumFractionDigits(2);
nf.setMaximumFractionDigits(2);
}
return nf.format(this.amount);
}
public String toString() {
return this.getFormattedString();
}
}