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