Skip to content

Commit dc29afb

Browse files
author
Anirav Kareddy
committed
chore: applied formatting to code
1 parent 5e41470 commit dc29afb

File tree

9 files changed

+3503
-2118
lines changed

9 files changed

+3503
-2118
lines changed

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Ignore artifacts:
2+
build
3+
coverage

src/examples/java/software/amazon/encryption/s3/examples/ReEncryptInstructionFileExample.java

Lines changed: 251 additions & 162 deletions
Large diffs are not rendered by default.

src/main/java/software/amazon/encryption/s3/internal/ReEncryptInstructionFileRequest.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,20 @@
22
// SPDX-License-Identifier: Apache-2.0
33
package software.amazon.encryption.s3.internal;
44

5+
import static software.amazon.encryption.s3.S3EncryptionClientUtilities.DEFAULT_INSTRUCTION_FILE_SUFFIX;
6+
57
import software.amazon.encryption.s3.S3EncryptionClientException;
68
import software.amazon.encryption.s3.materials.AesKeyring;
79
import software.amazon.encryption.s3.materials.RawKeyring;
810

9-
import static software.amazon.encryption.s3.S3EncryptionClientUtilities.DEFAULT_INSTRUCTION_FILE_SUFFIX;
10-
1111
/**
1212
* Request object for re-encrypting instruction files in S3.
1313
* This request supports re-encryption operations using either AES or RSA keyrings.
1414
* For AES keyrings, only the default instruction file suffix is supported.
1515
* For RSA keyrings, both the default and custom instruction file suffixes are supported.
1616
*/
1717
public class ReEncryptInstructionFileRequest {
18+
1819
private final String bucket;
1920
private final String key;
2021
private final RawKeyring newKeyring;
@@ -60,7 +61,9 @@ public String instructionFileSuffix() {
6061
/**
6162
* @return whether to enforce rotation for the re-encrypted instruction file
6263
*/
63-
public boolean enforceRotation() { return enforceRotation; }
64+
public boolean enforceRotation() {
65+
return enforceRotation;
66+
}
6467

6568
/**
6669
* Creates a builder that can be used to configure and create a {@link ReEncryptInstructionFileRequest}
@@ -75,6 +78,7 @@ public static Builder builder() {
7578
* Builder for ReEncryptInstructionFileRequest.
7679
*/
7780
public static class Builder {
81+
7882
private String bucket;
7983
private String key;
8084
private RawKeyring newKeyring;
@@ -160,12 +164,12 @@ public ReEncryptInstructionFileRequest build() {
160164
}
161165
if (newKeyring instanceof AesKeyring) {
162166
if (!instructionFileSuffix.equals(DEFAULT_INSTRUCTION_FILE_SUFFIX)) {
163-
throw new S3EncryptionClientException("Custom Instruction file suffix is not applicable for AES keyring!");
167+
throw new S3EncryptionClientException(
168+
"Custom Instruction file suffix is not applicable for AES keyring!"
169+
);
164170
}
165171
}
166172
return new ReEncryptInstructionFileRequest(this);
167173
}
168-
169174
}
170-
171175
}

src/main/java/software/amazon/encryption/s3/internal/ReEncryptInstructionFileResponse.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Contains the S3 bucket name, object key, instruction file suffix, and rotation enforcement status for the re-encrypted instruction file
88
*/
99
public class ReEncryptInstructionFileResponse {
10+
1011
private final String bucket;
1112
private final String key;
1213
private final String instructionFileSuffix;
@@ -20,7 +21,12 @@ public class ReEncryptInstructionFileResponse {
2021
* @param instructionFileSuffix the suffix used for the instruction file
2122
* @param enforceRotation whether rotation was enforced for the re-encrypted instruction file
2223
*/
23-
public ReEncryptInstructionFileResponse(String bucket, String key, String instructionFileSuffix, boolean enforceRotation) {
24+
public ReEncryptInstructionFileResponse(
25+
String bucket,
26+
String key,
27+
String instructionFileSuffix,
28+
boolean enforceRotation
29+
) {
2430
this.bucket = bucket;
2531
this.key = key;
2632
this.instructionFileSuffix = instructionFileSuffix.substring(1);
@@ -55,4 +61,3 @@ public String instructionFileSuffix() {
5561
return instructionFileSuffix;
5662
}
5763
}
58-

src/main/java/software/amazon/encryption/s3/materials/MaterialsDescription.java

Lines changed: 112 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -14,124 +14,127 @@
1414
* The stored Materials Description is immutable once created.
1515
*/
1616
public 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

Comments
 (0)