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.Optional; 19 import software.amazon.awssdk.annotations.Immutable; 20 import software.amazon.awssdk.annotations.SdkPublicApi; 21 22 /** 23 * The base class for all SDK requests. 24 * <p> 25 * Implementations must ensure the class is immutable. 26 * </p> 27 * @see SdkResponse 28 */ 29 @Immutable 30 @SdkPublicApi 31 public abstract class SdkRequest implements SdkPojo { 32 /** 33 * @return The optional client configuration overrides for this request. 34 */ overrideConfiguration()35 public abstract Optional<? extends RequestOverrideConfiguration> overrideConfiguration(); 36 37 /** 38 * Used to retrieve the value of a field from any class that extends {@link SdkRequest}. The field name 39 * specified should match the member name from the corresponding service-2.json model specified in the 40 * codegen-resources folder for a given service. The class specifies what class to cast the returned value to. 41 * If the returned value is also a modeled class, the {@link #getValueForField(String, Class)} method will 42 * again be available. 43 * 44 * @param fieldName The name of the member to be retrieved. 45 * @param clazz The class to cast the returned object to. 46 * @return Optional containing the casted return value 47 */ getValueForField(String fieldName, Class<T> clazz)48 public <T> Optional<T> getValueForField(String fieldName, Class<T> clazz) { 49 return Optional.empty(); 50 } 51 toBuilder()52 public abstract Builder toBuilder(); 53 54 public interface Builder { overrideConfiguration()55 RequestOverrideConfiguration overrideConfiguration(); 56 build()57 SdkRequest build(); 58 } 59 } 60