Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
DocumentAttributeDecimal |
|
| 1.0;1 | ||||
DocumentAttributeDecimal$1 |
|
| 1.0;1 | ||||
DocumentAttributeDecimal$Builder |
|
| 1.0;1 | ||||
DocumentAttributeDecimal$Constants |
|
| 1.0;1 | ||||
DocumentAttributeDecimal$Elements |
|
| 1.0;1 |
1 | /** | |
2 | * Copyright 2005-2011 The Kuali Foundation | |
3 | * | |
4 | * Licensed under the Educational Community License, Version 2.0 (the "License"); | |
5 | * you may not use this file except in compliance with the License. | |
6 | * You may obtain a copy of the License at | |
7 | * | |
8 | * http://www.opensource.org/licenses/ecl2.php | |
9 | * | |
10 | * Unless required by applicable law or agreed to in writing, software | |
11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | * See the License for the specific language governing permissions and | |
14 | * limitations under the License. | |
15 | */ | |
16 | package org.kuali.rice.kew.api.document.attribute; | |
17 | ||
18 | import javax.xml.bind.annotation.XmlAccessType; | |
19 | import javax.xml.bind.annotation.XmlAccessorType; | |
20 | import javax.xml.bind.annotation.XmlElement; | |
21 | import javax.xml.bind.annotation.XmlRootElement; | |
22 | import javax.xml.bind.annotation.XmlType; | |
23 | import java.math.BigDecimal; | |
24 | ||
25 | /** | |
26 | * A document attribute which contains decimal or "real" data. Construct instances of {@code DocumentAttributeDecimal} | |
27 | * using it's builder or the {@link DocumentAttributeFactory}. | |
28 | * | |
29 | * @author Kuali Rice Team (rice.collab@kuali.org) | |
30 | */ | |
31 | 0 | @XmlRootElement(name = DocumentAttributeDecimal.Constants.ROOT_ELEMENT_NAME) |
32 | @XmlAccessorType(XmlAccessType.NONE) | |
33 | @XmlType(name = DocumentAttributeDecimal.Constants.TYPE_NAME, propOrder = { | |
34 | DocumentAttributeDecimal.Elements.VALUE | |
35 | }) | |
36 | 0 | public final class DocumentAttributeDecimal extends DocumentAttribute { |
37 | ||
38 | @XmlElement(name = Elements.VALUE, required = false) | |
39 | private final BigDecimal value; | |
40 | ||
41 | @SuppressWarnings("unused") | |
42 | 0 | private DocumentAttributeDecimal() { |
43 | 0 | this.value = null; |
44 | 0 | } |
45 | ||
46 | private DocumentAttributeDecimal(Builder builder) { | |
47 | 0 | super(builder.getName()); |
48 | 0 | this.value = builder.getValue(); |
49 | 0 | } |
50 | ||
51 | @Override | |
52 | public BigDecimal getValue() { | |
53 | 0 | return value; |
54 | } | |
55 | ||
56 | @Override | |
57 | public DocumentAttributeDataType getDataType() { | |
58 | 0 | return DocumentAttributeDataType.DECIMAL; |
59 | } | |
60 | ||
61 | /** | |
62 | * A builder implementation which allows for construction of a {@code DocumentAttributeDecimal}. | |
63 | */ | |
64 | 0 | public static final class Builder extends AbstractBuilder<BigDecimal> { |
65 | ||
66 | /** | |
67 | * Create a builder for the document attribute using the given attribute name. | |
68 | * | |
69 | * @param name the name of the document attribute which should be built by this builder, should never be a | |
70 | * null or blank value | |
71 | * @return a builder instance initialized with the given attribute name | |
72 | */ | |
73 | private Builder(String name) { | |
74 | 0 | super(name); |
75 | 0 | } |
76 | ||
77 | public static Builder create(String name) { | |
78 | 0 | return new Builder(name); |
79 | } | |
80 | ||
81 | @Override | |
82 | public DocumentAttributeDataType getDataType() { | |
83 | 0 | return DocumentAttributeDataType.DECIMAL; |
84 | } | |
85 | ||
86 | @Override | |
87 | public DocumentAttributeDecimal build() { | |
88 | 0 | return new DocumentAttributeDecimal(this); |
89 | } | |
90 | ||
91 | } | |
92 | ||
93 | ||
94 | /** | |
95 | * Defines some internal constants used on this class. | |
96 | */ | |
97 | 0 | static class Constants { |
98 | final static String ROOT_ELEMENT_NAME = "documentAttributeDecimal"; | |
99 | final static String TYPE_NAME = "DocumentAttributeDecimalType"; | |
100 | } | |
101 | ||
102 | /** | |
103 | * A private class which exposes constants which define the XML element names to use when this object is marshalled to XML. | |
104 | */ | |
105 | 0 | static class Elements { |
106 | final static String VALUE = "value"; | |
107 | } | |
108 | ||
109 | } |