1414 * The stored Materials Description is immutable once created.
1515 */
1616public class MaterialsDescription implements Map <String , String > {
17- private final Map <String , String > materialsDescription ;
1817
19- private MaterialsDescription (Builder builder ) {
20- this .materialsDescription = Collections .unmodifiableMap (new HashMap <>(builder .materialsDescription ));
21- }
18+ private final Map <String , String > materialsDescription ;
19+
20+ private MaterialsDescription (Builder builder ) {
21+ this .materialsDescription =
22+ Collections .unmodifiableMap (new HashMap <>(builder .materialsDescription ));
23+ }
24+
25+ /**
26+ * @return a new builder instance
27+ */
28+ public static Builder builder () {
29+ return new Builder ();
30+ }
31+
32+ /**
33+ * @return the materials description map
34+ */
35+ public Map <String , String > getMaterialsDescription () {
36+ return this .materialsDescription ;
37+ }
38+
39+ @ Override
40+ public int size () {
41+ return materialsDescription .size ();
42+ }
43+
44+ @ Override
45+ public boolean isEmpty () {
46+ return materialsDescription .isEmpty ();
47+ }
48+
49+ @ Override
50+ public boolean containsKey (Object key ) {
51+ return materialsDescription .containsKey (key );
52+ }
53+
54+ @ Override
55+ public boolean containsValue (Object value ) {
56+ return materialsDescription .containsValue (value );
57+ }
58+
59+ @ Override
60+ public String get (Object key ) {
61+ return materialsDescription .get (key );
62+ }
63+
64+ @ Override
65+ public String put (String key , String value ) {
66+ throw new UnsupportedOperationException ("This map is immutable" );
67+ }
68+
69+ @ Override
70+ public String remove (Object key ) {
71+ return materialsDescription .remove (key );
72+ }
73+
74+ @ Override
75+ public void putAll (Map <? extends String , ? extends String > m ) {
76+ throw new UnsupportedOperationException ("This map is immutable" );
77+ }
78+
79+ @ Override
80+ public void clear () {
81+ materialsDescription .clear ();
82+ }
83+
84+ @ Override
85+ public Set <String > keySet () {
86+ return materialsDescription .keySet ();
87+ }
88+
89+ @ Override
90+ public Collection <String > values () {
91+ return materialsDescription .values ();
92+ }
93+
94+ @ Override
95+ public Set <Entry <String , String >> entrySet () {
96+ return materialsDescription .entrySet ();
97+ }
98+
99+ /**
100+ * Builder for MaterialsDescription.
101+ */
102+ public static class Builder {
103+
104+ private final Map <String , String > materialsDescription = new HashMap <>();
22105
23106 /**
24- * @return a new builder instance
107+ * @param key the key to add
108+ * @param value the value to add
109+ * @return a reference to this object so that method calls can be chained together.
110+ * @throws IllegalArgumentException if key or value is null
25111 */
26- public static Builder builder () {
27- return new Builder ();
112+ public Builder put (String key , String value ) {
113+ if (key == null || value == null ) {
114+ throw new IllegalArgumentException ("Key and value must not be null" );
115+ }
116+ materialsDescription .put (key , value );
117+ return this ;
28118 }
29119
30120 /**
31- * @return the materials description map
121+ * @param description the map of key-value pairs to add
122+ * @return a reference to this object so that method calls can be chained together.
123+ * @throws IllegalArgumentException if description is null
32124 */
33- public Map <String , String > getMaterialsDescription () {
34- return this .materialsDescription ;
35- }
36-
37- @ Override
38- public int size () {
39- return materialsDescription .size ();
40- }
41-
42- @ Override
43- public boolean isEmpty () {
44- return materialsDescription .isEmpty ();
45- }
46-
47- @ Override
48- public boolean containsKey (Object key ) {
49- return materialsDescription .containsKey (key );
50- }
51-
52- @ Override
53- public boolean containsValue (Object value ) {
54- return materialsDescription .containsValue (value );
55- }
56-
57- @ Override
58- public String get (Object key ) {
59- return materialsDescription .get (key );
60- }
61-
62- @ Override
63- public String put (String key , String value ) {
64- throw new UnsupportedOperationException ("This map is immutable" );
65- }
66-
67- @ Override
68- public String remove (Object key ) {
69- return materialsDescription .remove (key );
70- }
71-
72- @ Override
73- public void putAll (Map <? extends String , ? extends String > m ) {
74- throw new UnsupportedOperationException ("This map is immutable" );
75- }
76-
77- @ Override
78- public void clear () {
79- materialsDescription .clear ();
80- }
81-
82- @ Override
83- public Set <String > keySet () {
84- return materialsDescription .keySet ();
85- }
86-
87- @ Override
88- public Collection <String > values () {
89- return materialsDescription .values ();
90- }
91-
92- @ Override
93- public Set <Entry <String , String >> entrySet () {
94- return materialsDescription .entrySet ();
125+ public Builder putAll (Map <String , String > description ) {
126+ if (description == null ) {
127+ throw new IllegalArgumentException ("Description must not be null" );
128+ }
129+ materialsDescription .putAll (description );
130+ return this ;
95131 }
96132
97133 /**
98- * Builder for MaterialsDescription.
134+ * @return the built MaterialsDescription
99135 */
100- public static class Builder {
101- private final Map <String , String > materialsDescription = new HashMap <>();
102-
103- /**
104- * @param key the key to add
105- * @param value the value to add
106- * @return a reference to this object so that method calls can be chained together.
107- * @throws IllegalArgumentException if key or value is null
108- */
109- public Builder put (String key , String value ) {
110- if (key == null || value == null ) {
111- throw new IllegalArgumentException ("Key and value must not be null" );
112- }
113- materialsDescription .put (key , value );
114- return this ;
115- }
116-
117- /**
118- * @param description the map of key-value pairs to add
119- * @return a reference to this object so that method calls can be chained together.
120- * @throws IllegalArgumentException if description is null
121- */
122- public Builder putAll (Map <String , String > description ) {
123- if (description == null ) {
124- throw new IllegalArgumentException ("Description must not be null" );
125- }
126- materialsDescription .putAll (description );
127- return this ;
128- }
129-
130- /**
131- * @return the built MaterialsDescription
132- */
133- public MaterialsDescription build () {
134- return new MaterialsDescription (this );
135- }
136- }
137- }
136+ public MaterialsDescription build () {
137+ return new MaterialsDescription (this );
138+ }
139+ }
140+ }
0 commit comments