|
| 1 | +/* |
| 2 | + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"). |
| 5 | + * You may not use this file except in compliance with the License. |
| 6 | + * A copy of the License is located at |
| 7 | + * |
| 8 | + * http://aws.amazon.com/apache2.0 |
| 9 | + * |
| 10 | + * or in the "license" file accompanying this file. This file is distributed |
| 11 | + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either |
| 12 | + * express or implied. See the License for the specific language governing |
| 13 | + * permissions and limitations under the License. |
| 14 | + */ |
| 15 | + |
| 16 | +package software.amazon.awssdk.core; |
| 17 | + |
| 18 | +import java.util.List; |
| 19 | +import java.util.Optional; |
| 20 | +import software.amazon.awssdk.annotations.Immutable; |
| 21 | +import software.amazon.awssdk.annotations.SdkPublicApi; |
| 22 | + |
| 23 | + |
| 24 | +@Immutable |
| 25 | +@SdkPublicApi |
| 26 | +public final class FooBarConfiguration { |
| 27 | + |
| 28 | + private final String foo; |
| 29 | + private final List<String> bar; |
| 30 | + private Optional<String> optionalField; |
| 31 | + |
| 32 | + private FooBarConfiguration(Builder builder) { |
| 33 | + this.foo = builder.foo; |
| 34 | + this.bar = builder.bar; |
| 35 | + this.optionalField = builder.optionalField; |
| 36 | + } |
| 37 | + |
| 38 | + /** |
| 39 | + * Returns the foo configuration value. |
| 40 | + * |
| 41 | + * @return The foo value, if present. |
| 42 | + */ |
| 43 | + public Optional<String> foo() { |
| 44 | + return Optional.ofNullable(foo); |
| 45 | + } |
| 46 | + |
| 47 | + /** |
| 48 | + * Returns the bar configuration value. |
| 49 | + * |
| 50 | + * @return The bar value, if present. |
| 51 | + */ |
| 52 | + public Optional<List<String>> bar() { |
| 53 | + return Optional.ofNullable(bar); |
| 54 | + } |
| 55 | + |
| 56 | + /** |
| 57 | + * Create a new builder for {@link FooBarConfiguration}. |
| 58 | + * |
| 59 | + * @return A new builder instance. |
| 60 | + */ |
| 61 | + public static Builder builder() { |
| 62 | + return new Builder(); |
| 63 | + } |
| 64 | + |
| 65 | + /** |
| 66 | + * Builder for {@link FooBarConfiguration}. |
| 67 | + */ |
| 68 | + public static final class Builder { |
| 69 | + private Optional<String> optionalField; |
| 70 | + private String foo; |
| 71 | + private List<String> bar; |
| 72 | + |
| 73 | + private Builder() { |
| 74 | + } |
| 75 | + |
| 76 | + public Builder foo(String foo) { |
| 77 | + this.foo = foo; |
| 78 | + return this; |
| 79 | + } |
| 80 | + |
| 81 | + public Builder bar(List<String> bar) { |
| 82 | + this.bar = bar; |
| 83 | + return this; |
| 84 | + } |
| 85 | + |
| 86 | + public Builder optionalField(Optional<String> optionalField) { |
| 87 | + this.optionalField = optionalField; |
| 88 | + return this; |
| 89 | + } |
| 90 | + |
| 91 | + /** |
| 92 | + * Build a new {@link FooBarConfiguration} with the properties set on this builder. |
| 93 | + * |
| 94 | + * @return The new {@code FooBarConfiguration}. |
| 95 | + */ |
| 96 | + public FooBarConfiguration build() { |
| 97 | + return new FooBarConfiguration(this); |
| 98 | + } |
| 99 | + } |
| 100 | +} |
0 commit comments