Skip to content

Commit c11f832

Browse files
author
Anirav Kareddy
committed
Added Materials Description class
1 parent 8e438d3 commit c11f832

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package software.amazon.encryption.s3.materials;
5+
6+
import java.util.Collections;
7+
import java.util.HashMap;
8+
import java.util.Map;
9+
10+
public class MaterialsDescription {
11+
private final Map<String, String> materialsDescription;
12+
13+
private MaterialsDescription(Builder builder) {
14+
this.materialsDescription = Collections.unmodifiableMap(new HashMap<>(builder.materialsDescription));
15+
}
16+
public static Builder builder() {
17+
return new Builder();
18+
}
19+
public Map<String, String> getDescription() {
20+
return this.materialsDescription;
21+
}
22+
public static class Builder {
23+
private final Map<String, String> materialsDescription = new HashMap<>();
24+
public Builder put(String key, String value) {
25+
if (key == null || value == null) {
26+
throw new IllegalArgumentException("Key and value must not be null");
27+
}
28+
materialsDescription.put(key, value);
29+
return this;
30+
}
31+
public Builder putAll(Map<String, String> description) {
32+
if (description == null) {
33+
throw new IllegalArgumentException("Description must not be null");
34+
}
35+
for (Map.Entry<String, String> entry : description.entrySet()) {
36+
put(entry.getKey(), entry.getValue());
37+
}
38+
return this;
39+
}
40+
public MaterialsDescription build() {
41+
return new MaterialsDescription(this);
42+
}
43+
}
44+
}

0 commit comments

Comments
 (0)