index int64 0 0 | repo_id stringlengths 9 205 | file_path stringlengths 31 246 | content stringlengths 1 12.2M | __index_level_0__ int64 0 10k |
|---|---|---|---|---|
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/rules | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/rules/endpoints/OperationInput.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.rules.endpoints;
import com.fasterxml.jackson.core.TreeNode;
import java.util.Map;
public class OperationInput {
private String operationName;
private Map<String, TreeNode> operationParams;
public String getOperationName() {
return operationName;
}
public void setOperationName(String operationName) {
this.operationName = operationName;
}
public Map<String, TreeNode> getOperationParams() {
return operationParams;
}
public void setOperationParams(Map<String, TreeNode> operationParams) {
this.operationParams = operationParams;
}
}
| 3,800 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/rules | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/rules/endpoints/ParameterDeprecatedModel.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.rules.endpoints;
public class ParameterDeprecatedModel {
private String message;
private String since;
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getSince() {
return since;
}
public void setSince(String since) {
this.since = since;
}
}
| 3,801 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/rules | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/rules/endpoints/EndpointTestModel.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.rules.endpoints;
import com.fasterxml.jackson.core.TreeNode;
import java.util.List;
import java.util.Map;
public class EndpointTestModel {
private String documentation;
private Map<String, TreeNode> params;
private List<OperationInput> operationInputs;
private ExpectModel expect;
public String getDocumentation() {
return documentation;
}
public void setDocumentation(String documentation) {
this.documentation = documentation;
}
public Map<String, TreeNode> getParams() {
return params;
}
public void setParams(Map<String, TreeNode> params) {
this.params = params;
}
public List<OperationInput> getOperationInputs() {
return operationInputs;
}
public void setOperationInputs(List<OperationInput> operationInputs) {
this.operationInputs = operationInputs;
}
public ExpectModel getExpect() {
return expect;
}
public void setExpect(ExpectModel expect) {
this.expect = expect;
}
}
| 3,802 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/rules | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/rules/endpoints/RuleModel.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.rules.endpoints;
import java.util.List;
public class RuleModel {
private String type;
private List<ConditionModel> conditions;
// for type == error
private String error;
// for type == tree
private List<RuleModel> rules;
// for type == endpoint
private EndpointModel endpoint;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public List<ConditionModel> getConditions() {
return conditions;
}
public void setConditions(List<ConditionModel> conditions) {
this.conditions = conditions;
}
public String getError() {
return error;
}
public void setError(String error) {
this.error = error;
}
public List<RuleModel> getRules() {
return rules;
}
public void setRules(List<RuleModel> rules) {
this.rules = rules;
}
public EndpointModel getEndpoint() {
return endpoint;
}
public void setEndpoint(EndpointModel endpoint) {
this.endpoint = endpoint;
}
}
| 3,803 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/rules | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/rules/endpoints/ParameterModel.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.rules.endpoints;
import com.fasterxml.jackson.core.TreeNode;
public class ParameterModel {
private String type;
private String builtIn;
private TreeNode defaultValue;
private Boolean required;
private ParameterDeprecatedModel deprecated;
private String documentation;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public BuiltInParameter getBuiltInEnum() {
if (builtIn == null) {
return null;
}
return BuiltInParameter.fromValue(builtIn);
}
public String getBuiltIn() {
return builtIn;
}
public void setBuiltIn(String builtIn) {
this.builtIn = builtIn;
}
public TreeNode getDefault() {
return defaultValue;
}
public void setDefault(TreeNode defaultValue) {
this.defaultValue = defaultValue;
}
public Boolean isRequired() {
return required;
}
public void setRequired(Boolean required) {
this.required = required;
}
public ParameterDeprecatedModel getDeprecated() {
return deprecated;
}
public void setDeprecated(ParameterDeprecatedModel deprecated) {
this.deprecated = deprecated;
}
public String getDocumentation() {
return documentation;
}
public void setDocumentation(String documentation) {
this.documentation = documentation;
}
}
| 3,804 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/service/ServiceMetadata.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.service;
import java.util.List;
import java.util.Map;
public class ServiceMetadata {
private String apiVersion;
private String endpointPrefix;
private String signingName;
private String serviceAbbreviation;
private String serviceFullName;
private String serviceId;
private String xmlNamespace;
private String protocol;
private String jsonVersion;
private Map<String, String> awsQueryCompatible;
private boolean resultWrapped;
private String signatureVersion;
private String targetPrefix;
private String uid;
private List<String> auth;
private Map<String, String> protocolSettings;
public String getApiVersion() {
return apiVersion;
}
public void setApiVersion(String apiVersion) {
this.apiVersion = apiVersion;
}
public String getEndpointPrefix() {
return endpointPrefix;
}
public void setEndpointPrefix(String endpointPrefix) {
this.endpointPrefix = endpointPrefix;
}
public String getSigningName() {
if (signingName == null) {
setSigningName(endpointPrefix);
}
return signingName;
}
public void setSigningName(String signingName) {
this.signingName = signingName;
}
public String getServiceAbbreviation() {
return serviceAbbreviation;
}
public void setServiceAbbreviation(String serviceAbbreviation) {
this.serviceAbbreviation = serviceAbbreviation;
}
public String getServiceFullName() {
return serviceFullName;
}
public void setServiceFullName(String serviceFullName) {
this.serviceFullName = serviceFullName;
}
public String getXmlNamespace() {
return xmlNamespace;
}
public void setXmlNamespace(String xmlNamespace) {
this.xmlNamespace = xmlNamespace;
}
public String getProtocol() {
return protocol;
}
public void setProtocol(String protocol) {
this.protocol = protocol;
}
public String getJsonVersion() {
return jsonVersion;
}
public void setJsonVersion(String jsonVersion) {
this.jsonVersion = jsonVersion;
}
public Map<String, String> getAwsQueryCompatible() {
return awsQueryCompatible;
}
public void setAwsQueryCompatible(Map<String, String> awsQueryCompatible) {
this.awsQueryCompatible = awsQueryCompatible;
}
public boolean isResultWrapped() {
return resultWrapped;
}
public void setResultWrapped(boolean resultWrapped) {
this.resultWrapped = resultWrapped;
}
public String getSignatureVersion() {
return signatureVersion;
}
public void setSignatureVersion(String signatureVersion) {
this.signatureVersion = signatureVersion;
}
public String getTargetPrefix() {
return targetPrefix;
}
public void setTargetPrefix(String targetPrefix) {
this.targetPrefix = targetPrefix;
}
public String getUid() {
return uid;
}
public void setUid(String uid) {
this.uid = uid;
}
public List<String> getAuth() {
return auth;
}
public void setAuth(List<String> auth) {
this.auth = auth;
}
public Map<String, String> getProtocolSettings() {
return protocolSettings;
}
public void setProtocolSettings(Map<String, String> protocolSettings) {
this.protocolSettings = protocolSettings;
}
public String getServiceId() {
return serviceId;
}
public void setServiceId(String serviceId) {
this.serviceId = serviceId;
}
}
| 3,805 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/service/ContextParam.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.service;
public class ContextParam {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
| 3,806 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/service/MapValueType.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.service;
public class MapValueType {
private String shape;
private String locationName;
public String getShape() {
return shape;
}
public void setShape(String shape) {
this.shape = shape;
}
public String getLocationName() {
return locationName;
}
public void setLocationName(String locationName) {
this.locationName = locationName;
}
}
| 3,807 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/service/EndpointRuleSetModel.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.service;
import java.io.IOException;
import java.io.InputStream;
import java.io.UncheckedIOException;
import java.util.List;
import java.util.Map;
import software.amazon.awssdk.codegen.internal.Jackson;
import software.amazon.awssdk.codegen.model.rules.endpoints.ParameterModel;
import software.amazon.awssdk.codegen.model.rules.endpoints.RuleModel;
import software.amazon.awssdk.utils.IoUtils;
public class EndpointRuleSetModel {
private String serviceId;
private String version;
private Map<String, ParameterModel> parameters;
private List<RuleModel> rules;
public static EndpointRuleSetModel defaultRules(String endpointPrefix) {
try (InputStream defaultRulesSet = EndpointRuleSetModel.class
.getResourceAsStream("/software/amazon/awssdk/codegen/default-endpoint-rule-set.json")) {
String rules = IoUtils.toUtf8String(defaultRulesSet);
rules = String.format(rules, endpointPrefix);
return Jackson.load(EndpointRuleSetModel.class, rules);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
public String getServiceId() {
return serviceId;
}
public void setServiceId(String serviceId) {
this.serviceId = serviceId;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public Map<String, ParameterModel> getParameters() {
return parameters;
}
public void setParameters(Map<String, ParameterModel> parameters) {
this.parameters = parameters;
}
public List<RuleModel> getRules() {
return rules;
}
public void setRules(List<RuleModel> rules) {
this.rules = rules;
}
}
| 3,808 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/service/EndpointTrait.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.service;
/**
* This trait can be used to resolve the endpoint of an API using the original endpoint
* derived from client or set by customer.
*
* This trait allows using modeled members in the input shape to modify the endpoint. This is for SDK internal use.
*
* See `API Operation Endpoint Trait` SEP
*/
public final class EndpointTrait {
/**
* Expression that must be expanded by the client before invoking the API call.
* The expanded expression is added as a prefix to the original endpoint host derived on the client.
*/
private String hostPrefix;
public String getHostPrefix() {
return hostPrefix;
}
public void setHostPrefix(String hostPrefix) {
this.hostPrefix = hostPrefix;
}
}
| 3,809 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/service/MapKeyType.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.service;
public class MapKeyType {
private String shape;
private String locationName;
public String getShape() {
return shape;
}
public void setShape(String shape) {
this.shape = shape;
}
public String getLocationName() {
return locationName;
}
public void setLocationName(String locationName) {
this.locationName = locationName;
}
}
| 3,810 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/service/Waiters.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.service;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
public class Waiters {
private static final Waiters NONE = new Waiters(Collections.emptyMap());
private Map<String, WaiterDefinition> waiters;
// Needed for JSON deserialization
private Waiters() {
this(new HashMap<>());
}
private Waiters(Map<String, WaiterDefinition> waiters) {
this.waiters = waiters;
}
public static Waiters none() {
return NONE;
}
public Map<String, WaiterDefinition> getWaiters() {
return waiters;
}
public void setWaiters(Map<String, WaiterDefinition> waiters) {
this.waiters = waiters;
}
public WaiterDefinition getWaiterDefinition(String waiterName) {
return waiters.get(waiterName);
}
}
| 3,811 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/service/Operation.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.service;
import java.util.List;
import java.util.Map;
import software.amazon.awssdk.codegen.checksum.HttpChecksum;
import software.amazon.awssdk.codegen.compression.RequestCompression;
import software.amazon.awssdk.codegen.model.intermediate.EndpointDiscovery;
public class Operation {
private String name;
private boolean deprecated;
private String deprecatedMessage;
private Http http;
private Input input;
private Output output;
private String documentation;
private String authorizer;
private List<ErrorMap> errors;
private EndpointDiscovery endpointdiscovery;
private boolean endpointoperation;
private EndpointTrait endpoint;
private AuthType authtype;
private List<String> auth;
private boolean httpChecksumRequired;
private HttpChecksum httpChecksum;
private RequestCompression requestCompression;
private Map<String, StaticContextParam> staticContextParams;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Operation withName(String name) {
this.name = name;
return this;
}
public boolean isDeprecated() {
return deprecated;
}
public void setDeprecated(boolean deprecated) {
this.deprecated = deprecated;
}
public String getDeprecatedMessage() {
return deprecatedMessage;
}
public void setDeprecatedMessage(String deprecatedMessage) {
this.deprecatedMessage = deprecatedMessage;
}
public Http getHttp() {
return http;
}
public void setHttp(Http http) {
this.http = http;
}
public Operation withHttp(Http http) {
this.http = http;
return this;
}
public Input getInput() {
return input;
}
public void setInput(Input input) {
this.input = input;
}
public Operation withInput(Input input) {
this.input = input;
return this;
}
public Output getOutput() {
return output;
}
public void setOutput(Output output) {
this.output = output;
}
public String getDocumentation() {
return documentation;
}
public void setDocumentation(String documentation) {
this.documentation = documentation;
}
public List<ErrorMap> getErrors() {
return errors;
}
public void setErrors(List<ErrorMap> errors) {
this.errors = errors;
}
public AuthType getAuthtype() {
return authtype;
}
public void setAuthtype(String authtype) {
this.authtype = AuthType.fromValue(authtype);
}
public List<String> getAuth() {
return auth;
}
public void setAuth(List<String> auth) {
this.auth = auth;
}
public String getAuthorizer() {
return authorizer;
}
public void setAuthorizer(String authorizer) {
this.authorizer = authorizer;
}
public EndpointDiscovery getEndpointdiscovery() {
return endpointdiscovery;
}
public void setEndpointdiscovery(EndpointDiscovery endpointdiscovery) {
this.endpointdiscovery = endpointdiscovery;
}
public boolean isEndpointoperation() {
return endpointoperation;
}
public void setEndpointoperation(boolean endpointoperation) {
this.endpointoperation = endpointoperation;
}
public EndpointTrait getEndpoint() {
return endpoint;
}
public void setEndpoint(EndpointTrait endpoint) {
this.endpoint = endpoint;
}
public boolean isHttpChecksumRequired() {
return httpChecksumRequired;
}
public void setHttpChecksumRequired(boolean httpChecksumRequired) {
this.httpChecksumRequired = httpChecksumRequired;
}
public HttpChecksum getHttpChecksum() {
return httpChecksum;
}
public void setHttpChecksum(HttpChecksum httpChecksum) {
this.httpChecksum = httpChecksum;
}
public RequestCompression getRequestCompression() {
return requestCompression;
}
public void setRequestCompression(RequestCompression requestCompression) {
this.requestCompression = requestCompression;
}
public Map<String, StaticContextParam> getStaticContextParams() {
return staticContextParams;
}
public void setStaticContextParams(Map<String, StaticContextParam> staticContextParams) {
this.staticContextParams = staticContextParams;
}
}
| 3,812 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/service/ErrorTrait.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.service;
/**
* Expresses content of the error trait
*/
public class ErrorTrait {
private String code;
private Integer httpStatusCode;
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public Integer getHttpStatusCode() {
return httpStatusCode;
}
public void setHttpStatusCode(Integer httpStatusCode) {
this.httpStatusCode = httpStatusCode;
}
}
| 3,813 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/service/WaiterDefinition.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.service;
import java.util.List;
public class WaiterDefinition {
private int delay;
private int maxAttempts;
private String operation;
private List<Acceptor> acceptors;
public WaiterDefinition() {
}
public int getDelay() {
return delay;
}
public void setDelay(int delay) {
this.delay = delay;
}
public int getMaxAttempts() {
return maxAttempts;
}
public void setMaxAttempts(int maxAttempts) {
this.maxAttempts = maxAttempts;
}
public String getOperation() {
return operation;
}
public void setOperation(String operation) {
this.operation = operation;
}
public List<Acceptor> getAcceptors() {
return acceptors;
}
public void setAcceptors(List<Acceptor> acceptors) {
this.acceptors = acceptors;
}
}
| 3,814 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/service/StaticContextParam.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.service;
import com.fasterxml.jackson.core.TreeNode;
public class StaticContextParam {
private TreeNode value;
public TreeNode getValue() {
return value;
}
public void setValue(TreeNode value) {
this.value = value;
}
}
| 3,815 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/service/Authorizer.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.service;
public class Authorizer {
private String name;
private Placement placement;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public void setPlacement(Placement placement) {
this.placement = placement;
}
public Location getTokenLocation() {
return placement != null ? placement.getLocation() : null;
}
public String getTokenName() {
return placement != null ? placement.getName() : null;
}
public static class Placement {
private Location location;
private String name;
public Location getLocation() {
return location;
}
public void setLocation(Location location) {
this.location = location;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
}
| 3,816 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/service/ErrorMap.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.service;
public class ErrorMap {
private String shape;
private String documentation;
private boolean exception;
private boolean fault;
private ErrorTrait error;
public String getShape() {
return shape;
}
public void setShape(String shape) {
this.shape = shape;
}
public String getDocumentation() {
return documentation;
}
public void setDocumentation(String documentation) {
this.documentation = documentation;
}
public boolean isException() {
return exception;
}
public void setException(boolean exception) {
this.exception = exception;
}
public boolean isFault() {
return fault;
}
public void setFault(boolean fault) {
this.fault = fault;
}
public ErrorTrait getError() {
return error;
}
public void setError(ErrorTrait error) {
this.error = error;
}
}
| 3,817 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/service/ClientContextParam.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.service;
public class ClientContextParam {
private String documentation;
private String type;
public String getDocumentation() {
return documentation;
}
public void setDocumentation(String documentation) {
this.documentation = documentation;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}
| 3,818 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/service/ShapeType.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.service;
public enum ShapeType {
Structure("structure"),
List("list"),
Map("map");
private String name;
ShapeType(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
| 3,819 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/service/Http.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.service;
public class Http {
private String method;
private String requestUri;
private String responseCode;
public String getMethod() {
return method;
}
public void setMethod(String method) {
this.method = method;
}
public Http withMethod(String method) {
this.method = method;
return this;
}
public String getRequestUri() {
return requestUri;
}
public void setRequestUri(String requestUri) {
this.requestUri = requestUri;
}
public Http withRequestUri(String requestUri) {
this.requestUri = requestUri;
return this;
}
public String getResponseCode() {
return responseCode;
}
public void setResponseCode(String responseCode) {
this.responseCode = responseCode;
}
}
| 3,820 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/service/Output.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.service;
public class Output {
private String shape;
private String documentation;
private String locationName;
private String resultWrapper;
public String getShape() {
return shape;
}
public void setShape(String shape) {
this.shape = shape;
}
public String getDocumentation() {
return documentation;
}
public void setDocumentation(String documentation) {
this.documentation = documentation;
}
public String getLocationName() {
return locationName;
}
public void setLocationName(String locationName) {
this.locationName = locationName;
}
public String getResultWrapper() {
return resultWrapper;
}
public void setResultWrapper(String resultWrapper) {
this.resultWrapper = resultWrapper;
}
}
| 3,821 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/service/ServiceModel.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.service;
import java.util.Collections;
import java.util.Map;
public class ServiceModel {
private ServiceMetadata metadata;
private Map<String, Operation> operations;
private Map<String, Shape> shapes;
private Map<String, Authorizer> authorizers;
private Map<String, ClientContextParam> clientContextParams;
private String documentation;
public ServiceModel() {
}
public ServiceModel(ServiceMetadata metadata,
Map<String, Operation> operations,
Map<String, Shape> shapes,
Map<String, Authorizer> authorizers) {
this.metadata = metadata;
this.operations = operations;
this.shapes = shapes;
this.authorizers = authorizers;
}
public ServiceMetadata getMetadata() {
return metadata;
}
public void setMetadata(ServiceMetadata metadata) {
this.metadata = metadata;
}
public Map<String, Operation> getOperations() {
return operations;
}
public void setOperations(Map<String, Operation> operations) {
this.operations = operations != null ? operations : Collections.emptyMap();
}
/**
* Convenience getter to retrieve an {@link Operation} by name.
*
* @param operationName Name of operation to retrieve.
* @return Operation or null if not found.
*/
public Operation getOperation(String operationName) {
return operations.get(operationName);
}
public Map<String, Shape> getShapes() {
return shapes;
}
public void setShapes(Map<String, Shape> shapes) {
this.shapes = shapes != null ? shapes : Collections.emptyMap();
}
/**
* Convenience getter to retrieve a {@link Shape} by name.
*
* @param shapeName Name of shape to retrieve.
* @return Shape or null if not found.
*/
public Shape getShape(String shapeName) {
return shapes.get(shapeName);
}
public String getDocumentation() {
return documentation;
}
public void setDocumentation(String documentation) {
this.documentation = documentation;
}
public Map<String, Authorizer> getAuthorizers() {
return authorizers != null ? authorizers : Collections.emptyMap();
}
public void setAuthorizers(Map<String, Authorizer> authorizers) {
this.authorizers = authorizers;
}
public Map<String, ClientContextParam> getClientContextParams() {
return clientContextParams;
}
public void setClientContextParams(Map<String, ClientContextParam> clientContextParams) {
this.clientContextParams = clientContextParams;
}
}
| 3,822 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/service/Input.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.service;
public class Input {
private String shape;
private String documentation;
private String locationName;
private XmlNamespace xmlNamespace;
public String getShape() {
return shape;
}
public void setShape(String shape) {
this.shape = shape;
}
public String getDocumentation() {
return documentation;
}
public void setDocumentation(String documentation) {
this.documentation = documentation;
}
public String getLocationName() {
return locationName;
}
public void setLocationName(String locationName) {
this.locationName = locationName;
}
public XmlNamespace getXmlNamespace() {
return xmlNamespace;
}
public void setXmlNamespace(XmlNamespace xmlNamespace) {
this.xmlNamespace = xmlNamespace;
}
}
| 3,823 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/service/Member.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.service;
public class Member {
private String shape;
private String location;
private String locationName;
private boolean payload;
private boolean streaming;
private boolean requiresLength;
private String documentation;
private String queryName;
private boolean flattened;
private XmlNamespace xmlNamespace;
private boolean idempotencyToken;
private boolean deprecated;
private String deprecatedMessage;
private boolean jsonvalue;
private String timestampFormat;
private boolean eventpayload;
private boolean eventheader;
private boolean endpointdiscoveryid;
private boolean sensitive;
private boolean xmlAttribute;
private String deprecatedName;
private ContextParam contextParam;
public String getShape() {
return shape;
}
public void setShape(String shape) {
this.shape = shape;
}
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location;
}
public String getLocationName() {
return locationName;
}
public void setLocationName(String locationName) {
this.locationName = locationName;
}
public boolean isPayload() {
return payload;
}
public void setPayload(boolean payload) {
this.payload = payload;
}
public boolean isStreaming() {
return streaming;
}
public void setStreaming(boolean streaming) {
this.streaming = streaming;
}
public boolean isRequiresLength() {
return requiresLength;
}
public void setRequiresLength(boolean requiresLength) {
this.requiresLength = requiresLength;
}
public String getDocumentation() {
return documentation;
}
public void setDocumentation(String documentation) {
this.documentation = documentation;
}
public String getQueryName() {
return queryName;
}
public void setQueryName(String queryName) {
this.queryName = queryName;
}
public boolean isFlattened() {
return flattened;
}
public void setFlattened(boolean flattened) {
this.flattened = flattened;
}
public XmlNamespace getXmlNamespace() {
return xmlNamespace;
}
public void setXmlNamespace(XmlNamespace xmlNamespace) {
this.xmlNamespace = xmlNamespace;
}
public boolean isIdempotencyToken() {
return idempotencyToken;
}
public void setIdempotencyToken(boolean idempotencyToken) {
this.idempotencyToken = idempotencyToken;
}
public boolean isDeprecated() {
return deprecated;
}
public void setDeprecated(boolean deprecated) {
this.deprecated = deprecated;
}
public String getDeprecatedMessage() {
return deprecatedMessage;
}
public void setDeprecatedMessage(String deprecatedMessage) {
this.deprecatedMessage = deprecatedMessage;
}
public boolean getJsonvalue() {
return jsonvalue;
}
public void setJsonvalue(boolean jsonvalue) {
this.jsonvalue = jsonvalue;
}
public String getTimestampFormat() {
return timestampFormat;
}
public void setTimestampFormat(String timestampFormat) {
this.timestampFormat = timestampFormat;
}
public boolean isEventpayload() {
return eventpayload;
}
public void setEventpayload(boolean eventpayload) {
this.eventpayload = eventpayload;
}
public boolean isEventheader() {
return eventheader;
}
public void setEventheader(boolean eventheader) {
this.eventheader = eventheader;
}
public boolean isEndpointdiscoveryid() {
return endpointdiscoveryid;
}
public void setEndpointdiscoveryid(boolean endpointdiscoveryid) {
this.endpointdiscoveryid = endpointdiscoveryid;
}
public boolean isSensitive() {
return sensitive;
}
public void setSensitive(boolean sensitive) {
this.sensitive = sensitive;
}
public boolean isXmlAttribute() {
return xmlAttribute;
}
public void setXmlAttribute(boolean xmlAttribute) {
this.xmlAttribute = xmlAttribute;
}
public void setDeprecatedName(String deprecatedName) {
this.deprecatedName = deprecatedName;
}
public String getDeprecatedName() {
return deprecatedName;
}
public ContextParam getContextParam() {
return contextParam;
}
public void setContextParam(ContextParam contextParam) {
this.contextParam = contextParam;
}
}
| 3,824 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/service/Location.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.service;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
public enum Location {
URI("uri"),
HEADER("header"),
HEADERS("headers"),
STATUS_CODE("statusCode"),
QUERY_STRING("querystring");
private final String location;
Location(String location) {
this.location = location;
}
@JsonCreator
public static Location forValue(String location) {
if (location == null) {
return null;
}
for (Location locationEnum : Location.values()) {
if (locationEnum.location.equals(location)) {
return locationEnum;
}
}
throw new IllegalArgumentException(
"Unknown enum value for ParameterHttpMapping.location: " + location);
}
@JsonValue
@Override
public String toString() {
return this.location;
}
}
| 3,825 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/service/AuthType.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.service;
import java.util.Arrays;
import software.amazon.awssdk.utils.StringUtils;
public enum AuthType {
NONE("none"),
CUSTOM("custom"),
IAM("iam"),
V4("v4"),
V4_UNSIGNED_BODY("v4-unsigned-body"),
S3("s3"),
S3V4("s3v4"),
BEARER("bearer")
;
private final String value;
AuthType(String value) {
this.value = value;
}
public static AuthType fromValue(String value) {
String normalizedValue = StringUtils.lowerCase(value);
return Arrays.stream(values())
.filter(authType -> authType.value.equals(normalizedValue))
.findFirst()
.orElseThrow(() -> new IllegalArgumentException(String.format("Unknown AuthType '%s'", normalizedValue)));
}
}
| 3,826 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/service/Acceptor.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.service;
import com.fasterxml.jackson.jr.stree.JrsValue;
public class Acceptor {
private String matcher;
private String argument;
private String state;
private JrsValue expected;
public Acceptor() {
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getMatcher() {
return matcher;
}
public void setMatcher(String matcher) {
this.matcher = matcher;
}
public String getArgument() {
return argument;
}
public void setArgument(String argument) {
this.argument = argument;
}
public JrsValue getExpected() {
return expected;
}
public void setExpected(JrsValue expected) {
this.expected = expected;
}
}
| 3,827 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/service/Paginators.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.service;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
/**
* POJO class to represent the paginators.json file.
*/
public class Paginators {
private static final Paginators NONE = new Paginators(Collections.emptyMap());
private Map<String, PaginatorDefinition> pagination;
private Paginators() {
this(new HashMap<>());
}
private Paginators(Map<String, PaginatorDefinition> pagination) {
this.pagination = pagination;
}
public static Paginators none() {
return NONE;
}
/**
* Returns a map of operation name to its {@link PaginatorDefinition}.
*/
public Map<String, PaginatorDefinition> getPagination() {
return pagination;
}
public void setPagination(Map<String, PaginatorDefinition> pagination) {
this.pagination = pagination;
}
public PaginatorDefinition getPaginatorDefinition(String operationName) {
return pagination.get(operationName);
}
}
| 3,828 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/service/XmlNamespace.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.service;
public class XmlNamespace {
private String prefix;
private String uri;
public String getPrefix() {
return prefix;
}
public void setPrefix(String prefix) {
this.prefix = prefix;
}
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
} | 3,829 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/service/PaginatorDefinition.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.service;
import static java.util.Collections.singletonList;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.jr.stree.JrsArray;
import com.fasterxml.jackson.jr.stree.JrsValue;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.regex.Pattern;
import software.amazon.awssdk.utils.CollectionUtils;
import software.amazon.awssdk.utils.Validate;
/**
* Represents the structure for each operation in paginators-1.json file
*
* This class is used to generate auto-paginated APIs.
*/
public class PaginatorDefinition {
private static final String VALID_REGEX = "[a-zA-Z.]+";
/**
* The members in the request which needs to be set to get the next page.
*/
private List<String> inputToken;
/**
* The members in the response which are used to get the next page.
*/
private List<String> outputToken;
/**
* The paginated list of members in the response
*/
private List<String> resultKey;
/**
* The name of the member in the response that indicates if the response is truncated.
* If the value of member is true, there are more results that can be retrieved.
* If the value of member is false, then there are no additional results.
*
* This is an optional field. If this value is missing, use the outputToken instead to check
* if more results are available or not.
*/
private String moreResults;
/**
* The member in the request that is used to limit the number of results per page.
*/
private String limitKey;
public PaginatorDefinition() {
}
public List<String> getInputToken() {
return inputToken;
}
public void setInputToken(List<String> inputToken) {
this.inputToken = inputToken;
}
public List<String> getOutputToken() {
return outputToken;
}
public void setOutputToken(List<String> outputToken) {
this.outputToken = outputToken;
}
public List<String> getResultKey() {
return resultKey;
}
public void setResultKey(List<String> resultKey) {
this.resultKey = resultKey;
}
public String getMoreResults() {
return moreResults;
}
public void setMoreResults(String moreResults) {
this.moreResults = moreResults;
}
public String getLimitKey() {
return limitKey;
}
public void setLimitKey(String limitKey) {
this.limitKey = limitKey;
}
/**
* Returns a boolean value indicating if the information present in this object
* is sufficient to generate the paginated APIs.
*
* @return True if all necessary information to generate paginator APIs is present. Otherwise false.
*/
public boolean isValid() {
Pattern p = Pattern.compile(VALID_REGEX);
return !CollectionUtils.isNullOrEmpty(inputToken) &&
!CollectionUtils.isNullOrEmpty(outputToken) &&
outputToken.stream().allMatch(t -> p.matcher(t).matches());
}
private List<String> asList(JrsValue node) {
if (node.isArray()) {
List<String> output = new ArrayList<>();
Iterator<JrsValue> elements = ((JrsArray) node).elements();
elements.forEachRemaining(v -> output.add(asString(v)));
return output;
} else {
return singletonList(asString(node));
}
}
private String asString(JrsValue value) {
Validate.isTrue(value.asToken() == JsonToken.VALUE_STRING, "Expected a string node: " + value);
return value.asText();
}
// CHECKSTYLE:OFF - These are all gross versions of the setter methods that match the C2J name.
/**
* Gross version of {@link #setLimitKey} that matches the JSON attribute name.
*/
public void setLimit_key(String limitKey) {
this.limitKey = limitKey;
}
/**
* Gross version of {@link #setInputToken} that matches the JSON attribute name.
*/
public void setInput_token(JrsValue inputToken) {
this.inputToken = asList(inputToken);
}
/**
* Gross version of {@link #setOutputToken} that matches the JSON attribute name.
*/
public void setOutput_token(JrsValue outputToken) {
this.outputToken = asList(outputToken);
}
/**
* Gross version of {@link #setResultKey} that matches the JSON attribute name.
*/
public void setResult_key(JrsValue resultKey) {
this.resultKey = asList(resultKey);
}
/**
* Gross version of {@link #setMoreResults} that matches the JSON attribute name.
*/
public void setMore_results(String moreResults) {
this.moreResults = moreResults;
}
// CHECKSTYLE:ON
}
| 3,830 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/service/HostPrefixProcessor.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.service;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import software.amazon.awssdk.utils.StringUtils;
/**
* Class to process the hostPrefix value in the {@link EndpointTrait} class.
* This is used during client generation.
*/
public final class HostPrefixProcessor {
/**
* Pattern to retrieve the content between the curly braces
*/
private static final String CURLY_BRACES_PATTERN = "\\{([^}]+)}";
private static final Pattern PATTERN = Pattern.compile(CURLY_BRACES_PATTERN);
/**
* This is the same as the {@link EndpointTrait#hostPrefix} expression with labels replaced by "%s"
*
* For example, if expression in host trait is "{Bucket}-{AccountId}-", then
* hostWithStringSpecifier will be "%s-%s-"
*/
private String hostWithStringSpecifier;
/**
* The list of member c2j names in input shape that are referenced in the host expression.
*
* For example, if expression in host trait is "{Bucket}-{AccountId}-", then the
* list would contain [Bucket, AccountId].
*/
private List<String> c2jNames;
public HostPrefixProcessor(String hostExpression) {
this.hostWithStringSpecifier = hostExpression;
this.c2jNames = new ArrayList<>();
replaceHostLabelsWithStringSpecifier(hostExpression);
}
/**
* Replace all the labels in host with %s symbols and collect the input shape member names into a list
*/
private void replaceHostLabelsWithStringSpecifier(String hostExpression) {
if (StringUtils.isEmpty(hostExpression)) {
throw new IllegalArgumentException("Given host prefix is either null or empty");
}
Matcher matcher = PATTERN.matcher(hostExpression);
while (matcher.find()) {
String matched = matcher.group(1);
c2jNames.add(matched);
hostWithStringSpecifier = hostWithStringSpecifier.replaceFirst("\\{" + matched + "}", "%s");
}
}
public String hostWithStringSpecifier() {
return hostWithStringSpecifier;
}
public List<String> c2jNames() {
return c2jNames;
}
}
| 3,831 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/service/Shape.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.service;
import java.util.Collections;
import java.util.List;
import java.util.Map;
public class Shape {
private String type;
private Map<String, Member> members = Collections.emptyMap();
private String documentation;
private List<String> required;
private List<String> enumValues;
private String payload;
private boolean flattened;
private boolean synthetic;
private boolean exception;
private boolean streaming;
private boolean requiresLength;
private boolean wrapper;
private Member listMember;
private Member mapKeyType;
private Member mapValueType;
private ErrorTrait error;
private long min;
private long max;
private String pattern;
private boolean fault;
private boolean deprecated;
private String deprecatedMessage;
private boolean eventstream;
private boolean event;
private String timestampFormat;
private boolean sensitive;
private XmlNamespace xmlNamespace;
private boolean document;
private boolean union;
public boolean isFault() {
return fault;
}
public void setFault(boolean fault) {
this.fault = fault;
}
public String getPattern() {
return pattern;
}
public void setPattern(String pattern) {
this.pattern = pattern;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Map<String, Member> getMembers() {
return members;
}
public void setMembers(Map<String, Member> members) {
this.members = members;
}
public String getDocumentation() {
return documentation;
}
public void setDocumentation(String documentation) {
this.documentation = documentation;
}
public List<String> getRequired() {
return required;
}
public void setRequired(List<String> required) {
this.required = required;
}
public List<String> getEnumValues() {
return enumValues;
}
public void setEnumValues(List<String> enumValues) {
this.enumValues = enumValues;
}
/**
* The actual JSON value of "enumValues".
*/
public void setEnum(List<String> enumValues) {
this.enumValues = enumValues;
}
public String getPayload() {
return payload;
}
public void setPayload(String payload) {
this.payload = payload;
}
public boolean isFlattened() {
return flattened;
}
public void setFlattened(boolean flattened) {
this.flattened = flattened;
}
/**
* Returns flag that indicates whether this shape is a custom SDK shape. If true, this shape will be excluded from the static
* SdkFields, preventing it from being marshalled.
*/
public boolean isSynthetic() {
return synthetic;
}
/**
* Sets flag that indicates whether this shape is a custom SDK shape. If true, this shape will be excluded from the static
* SdkFields, preventing it from being marshalled.
*/
public void setSynthetic(boolean synthetic) {
this.synthetic = synthetic;
}
public boolean isException() {
return exception;
}
public void setException(boolean exception) {
this.exception = exception;
}
public Member getMapKeyType() {
return mapKeyType;
}
public void setMapKeyType(Member mapKeyType) {
this.mapKeyType = mapKeyType;
}
/**
* The actual JSON name of "mapKeyType".
*/
public void setKey(Member key) {
this.mapKeyType = key;
}
public Member getMapValueType() {
return mapValueType;
}
public void setMapValueType(Member mapValueType) {
this.mapValueType = mapValueType;
}
/**
* The actual JSON name of "mapValueType".
*/
public void setValue(Member value) {
this.mapValueType = value;
}
public Member getListMember() {
return listMember;
}
public void setListMember(Member listMember) {
this.listMember = listMember;
}
/**
* The actual JSON name of "listMember".
*/
public void setMember(Member listMember) {
this.listMember = listMember;
}
public long getMin() {
return min;
}
public void setMin(long min) {
this.min = min;
}
public long getMax() {
return max;
}
public void setMax(long max) {
this.max = max;
}
public boolean isStreaming() {
return streaming;
}
public void setStreaming(boolean streaming) {
this.streaming = streaming;
}
public boolean isRequiresLength() {
return requiresLength;
}
public void setRequiresLength(boolean requiresLength) {
this.requiresLength = requiresLength;
}
public boolean isWrapper() {
return wrapper;
}
public void setWrapper(boolean wrapper) {
this.wrapper = wrapper;
}
public ErrorTrait getError() {
return error;
}
public void setError(ErrorTrait error) {
this.error = error;
}
public boolean isDeprecated() {
return deprecated;
}
public void setDeprecated(boolean deprecated) {
this.deprecated = deprecated;
}
public String getDeprecatedMessage() {
return deprecatedMessage;
}
public void setDeprecatedMessage(String deprecatedMessage) {
this.deprecatedMessage = deprecatedMessage;
}
public boolean isEventstream() {
return eventstream;
}
public void setEventstream(boolean eventstream) {
this.eventstream = eventstream;
}
public boolean isEvent() {
return event;
}
public void setEvent(boolean event) {
this.event = event;
}
public String getTimestampFormat() {
return timestampFormat;
}
public void setTimestampFormat(String timestampFormat) {
this.timestampFormat = timestampFormat;
}
public boolean isSensitive() {
return sensitive;
}
public void setSensitive(boolean sensitive) {
this.sensitive = sensitive;
}
public XmlNamespace getXmlNamespace() {
return xmlNamespace;
}
public void setXmlNamespace(XmlNamespace xmlNamespace) {
this.xmlNamespace = xmlNamespace;
}
public boolean isDocument() {
return document;
}
public void setDocument(boolean document) {
this.document = document;
}
public boolean isUnion() {
return union;
}
public void setUnion(boolean union) {
this.union = union;
}
}
| 3,832 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/service/ParameterModel.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.service;
public class ParameterModel {
private String type;
/**
* The type of this parameter. Currently, only "boolean" and "string" are
* permitted for parameters.
*/
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}
| 3,833 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/intermediate/SimpleMethodFormModel.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.intermediate;
import java.util.Iterator;
import java.util.List;
import software.amazon.awssdk.codegen.internal.Utils;
public class SimpleMethodFormModel {
private List<ArgumentModel> arguments;
public List<ArgumentModel> getArguments() {
return arguments;
}
public void setArguments(List<ArgumentModel> arguments) {
this.arguments = arguments;
}
public String getArgumentsDeclaration() {
StringBuilder builder = new StringBuilder();
Iterator<ArgumentModel> iter = arguments.iterator();
while (iter.hasNext()) {
ArgumentModel arg = iter.next();
builder.append(arg.getType())
.append(" ")
.append(arg.getName());
if (iter.hasNext()) {
builder.append(", ");
}
}
return builder.toString();
}
public String getWithMethodCalls() {
StringBuilder builder = new StringBuilder();
for (ArgumentModel arg : arguments) {
builder.append(".with")
.append(Utils.capitalize(arg.getName()))
.append("(")
.append(arg.getName())
.append(")");
}
return builder.toString();
}
}
| 3,834 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/intermediate/IntermediateModel.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.intermediate;
import com.fasterxml.jackson.annotation.JsonIgnore;
import java.io.IOException;
import java.io.InputStream;
import java.io.UncheckedIOException;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import software.amazon.awssdk.awscore.AwsResponse;
import software.amazon.awssdk.awscore.AwsResponseMetadata;
import software.amazon.awssdk.codegen.model.config.customization.CustomizationConfig;
import software.amazon.awssdk.codegen.model.rules.endpoints.EndpointTestSuiteModel;
import software.amazon.awssdk.codegen.model.service.ClientContextParam;
import software.amazon.awssdk.codegen.model.service.EndpointRuleSetModel;
import software.amazon.awssdk.codegen.model.service.PaginatorDefinition;
import software.amazon.awssdk.codegen.model.service.WaiterDefinition;
import software.amazon.awssdk.codegen.naming.NamingStrategy;
import software.amazon.awssdk.utils.IoUtils;
public final class IntermediateModel {
private static final String FILE_HEADER;
private Metadata metadata;
private Map<String, OperationModel> operations;
private Map<String, ShapeModel> shapes;
private CustomizationConfig customizationConfig;
private Optional<OperationModel> endpointOperation;
private Map<String, PaginatorDefinition> paginators;
private Map<String, WaiterDefinition> waiters;
@JsonIgnore
private EndpointRuleSetModel endpointRuleSetModel;
@JsonIgnore
private EndpointTestSuiteModel endpointTestSuiteModel;
@JsonIgnore
private NamingStrategy namingStrategy;
private Map<String, ClientContextParam> clientContextParams;
static {
FILE_HEADER = loadDefaultFileHeader();
}
public IntermediateModel() {
this.operations = new HashMap<>();
this.shapes = new HashMap<>();
this.endpointOperation = Optional.empty();
this.paginators = new HashMap<>();
this.waiters = new HashMap<>();
this.namingStrategy = null;
}
public IntermediateModel(Metadata metadata,
Map<String, OperationModel> operations,
Map<String, ShapeModel> shapes,
CustomizationConfig customizationConfig) {
this(metadata, operations, shapes, customizationConfig, null,
Collections.emptyMap(), null, Collections.emptyMap(), null, null, null);
}
public IntermediateModel(
Metadata metadata,
Map<String, OperationModel> operations,
Map<String, ShapeModel> shapes,
CustomizationConfig customizationConfig,
OperationModel endpointOperation,
Map<String, PaginatorDefinition> paginators,
NamingStrategy namingStrategy,
Map<String, WaiterDefinition> waiters,
EndpointRuleSetModel endpointRuleSetModel,
EndpointTestSuiteModel endpointTestSuiteModel,
Map<String, ClientContextParam> clientContextParams) {
this.metadata = metadata;
this.operations = operations;
this.shapes = shapes;
this.customizationConfig = customizationConfig;
this.endpointOperation = Optional.ofNullable(endpointOperation);
this.paginators = paginators;
this.namingStrategy = namingStrategy;
this.waiters = waiters;
this.endpointRuleSetModel = endpointRuleSetModel;
this.endpointTestSuiteModel = endpointTestSuiteModel;
this.clientContextParams = clientContextParams;
}
public Metadata getMetadata() {
return metadata;
}
public void setMetadata(Metadata metadata) {
this.metadata = metadata;
}
public Map<String, OperationModel> getOperations() {
return operations;
}
public void setOperations(Map<String, OperationModel> operations) {
this.operations = operations;
}
public OperationModel getOperation(String operationName) {
return getOperations().get(operationName);
}
public Map<String, ShapeModel> getShapes() {
return shapes;
}
public void setShapes(Map<String, ShapeModel> shapes) {
this.shapes = shapes;
}
/**
* Looks up a shape by name and verifies that the expected C2J name matches
* @param shapeName the name of the shape in the intermediate model
* @param shapeC2jName C2J's name for the shape
* @return the ShapeModel
* @throws IllegalArgumentException if no matching shape is found
*/
public ShapeModel getShapeByNameAndC2jName(String shapeName, String shapeC2jName) {
for (ShapeModel sm : getShapes().values()) {
if (shapeName.equals(sm.getShapeName()) && shapeC2jName.equals(sm.getC2jName())) {
return sm;
}
}
throw new IllegalArgumentException("C2J shape " + shapeC2jName + " with shape name " + shapeName + " does not exist in "
+ "the intermediate model.");
}
public CustomizationConfig getCustomizationConfig() {
return customizationConfig;
}
public void setCustomizationConfig(CustomizationConfig customizationConfig) {
this.customizationConfig = customizationConfig;
}
public Map<String, PaginatorDefinition> getPaginators() {
return paginators;
}
public Map<String, WaiterDefinition> getWaiters() {
return waiters;
}
public EndpointRuleSetModel getEndpointRuleSetModel() {
if (endpointRuleSetModel == null) {
endpointRuleSetModel = EndpointRuleSetModel.defaultRules(metadata.getEndpointPrefix());
}
return endpointRuleSetModel;
}
public EndpointTestSuiteModel getEndpointTestSuiteModel() {
if (endpointTestSuiteModel == null) {
endpointTestSuiteModel = new EndpointTestSuiteModel();
}
return endpointTestSuiteModel;
}
public Map<String, ClientContextParam> getClientContextParams() {
return clientContextParams;
}
public void setPaginators(Map<String, PaginatorDefinition> paginators) {
this.paginators = paginators;
}
public NamingStrategy getNamingStrategy() {
return namingStrategy;
}
public void setNamingStrategy(NamingStrategy namingStrategy) {
this.namingStrategy = namingStrategy;
}
public String getCustomRetryPolicy() {
return customizationConfig.getCustomRetryPolicy();
}
public String getSdkModeledExceptionBaseFqcn() {
return String.format("%s.%s",
metadata.getFullModelPackageName(),
getSdkModeledExceptionBaseClassName());
}
public String getSdkModeledExceptionBaseClassName() {
if (customizationConfig.getSdkModeledExceptionBaseClassName() != null) {
return customizationConfig.getSdkModeledExceptionBaseClassName();
} else {
return metadata.getBaseExceptionName();
}
}
public String getSdkRequestBaseClassName() {
if (customizationConfig.getSdkRequestBaseClassName() != null) {
return customizationConfig.getSdkRequestBaseClassName();
} else {
return metadata.getBaseRequestName();
}
}
public String getSdkResponseBaseClassName() {
if (customizationConfig.getSdkResponseBaseClassName() != null) {
return customizationConfig.getSdkResponseBaseClassName();
} else {
return metadata.getBaseResponseName();
}
}
public Optional<String> syncClientDecoratorClassName() {
if (customizationConfig.getSyncClientDecorator() != null) {
return Optional.of(customizationConfig.getSyncClientDecorator());
}
return Optional.empty();
}
public Optional<String> asyncClientDecoratorClassName() {
String asyncClientDecorator = customizationConfig.getAsyncClientDecorator();
if (customizationConfig.getAsyncClientDecorator() != null) {
return Optional.of(asyncClientDecorator);
}
return Optional.empty();
}
public String getFileHeader() {
return FILE_HEADER;
}
private static String loadDefaultFileHeader() {
try (InputStream inputStream =
IntermediateModel.class.getResourceAsStream("/software/amazon/awssdk/codegen/DefaultFileHeader.txt")) {
return IoUtils.toUtf8String(inputStream);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
public String getSdkBaseResponseFqcn() {
return String.format("%s<%s>",
AwsResponse.class.getName(),
getResponseMetadataClassName());
}
private String getResponseMetadataClassName() {
return AwsResponseMetadata.class.getName();
}
public Optional<OperationModel> getEndpointOperation() {
return endpointOperation;
}
public void setEndpointOperation(OperationModel endpointOperation) {
this.endpointOperation = Optional.ofNullable(endpointOperation);
}
public boolean hasPaginators() {
return paginators.size() > 0;
}
public boolean hasWaiters() {
return waiters.size() > 0;
}
public boolean containsRequestSigners() {
return getShapes().values().stream()
.anyMatch(ShapeModel::isRequestSignerAware);
}
public boolean containsRequestEventStreams() {
return getOperations().values().stream()
.anyMatch(OperationModel::hasEventStreamInput);
}
}
| 3,835 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/intermediate/MemberModel.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.intermediate;
import static software.amazon.awssdk.codegen.internal.Constant.LF;
import static software.amazon.awssdk.codegen.internal.DocumentationUtils.defaultExistenceCheck;
import static software.amazon.awssdk.codegen.internal.DocumentationUtils.defaultFluentReturn;
import static software.amazon.awssdk.codegen.internal.DocumentationUtils.defaultGetter;
import static software.amazon.awssdk.codegen.internal.DocumentationUtils.defaultGetterParam;
import static software.amazon.awssdk.codegen.internal.DocumentationUtils.defaultSetter;
import static software.amazon.awssdk.codegen.internal.DocumentationUtils.defaultSetterParam;
import static software.amazon.awssdk.codegen.internal.DocumentationUtils.stripHtmlTags;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.squareup.javapoet.ClassName;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import software.amazon.awssdk.codegen.internal.TypeUtils;
import software.amazon.awssdk.codegen.model.service.ContextParam;
import software.amazon.awssdk.core.SdkBytes;
import software.amazon.awssdk.core.SdkField;
import software.amazon.awssdk.core.protocol.MarshallingType;
import software.amazon.awssdk.core.util.SdkAutoConstructList;
import software.amazon.awssdk.core.util.SdkAutoConstructMap;
import software.amazon.awssdk.protocols.core.PathMarshaller;
import software.amazon.awssdk.utils.StringUtils;
public class MemberModel extends DocumentationModel {
private String name;
private String c2jName;
private String c2jShape;
private VariableModel variable;
private VariableModel setterModel;
private ReturnTypeModel getterModel;
private ParameterHttpMapping http;
private boolean deprecated;
private String deprecatedMessage;
private boolean required;
private boolean synthetic;
private ListModel listModel;
private MapModel mapModel;
private String enumType;
private String xmlNameSpaceUri;
private boolean idempotencyToken;
private ShapeModel shape;
private String fluentGetterMethodName;
private String fluentEnumGetterMethodName;
private String fluentSetterMethodName;
private String fluentEnumSetterMethodName;
private String existenceCheckMethodName;
private String beanStyleGetterName;
private String beanStyleSetterName;
private String unionEnumTypeName;
private boolean isJsonValue;
private String timestampFormat;
private boolean eventPayload;
private boolean eventHeader;
private boolean endpointDiscoveryId;
private boolean sensitive;
private boolean xmlAttribute;
private String deprecatedName;
private String fluentDeprecatedGetterMethodName;
private String fluentDeprecatedSetterMethodName;
private String deprecatedBeanStyleSetterMethodName;
private ContextParam contextParam;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public MemberModel withName(String name) {
setName(name);
return this;
}
public boolean isSynthetic() {
return synthetic;
}
public void setSynthetic(boolean synthetic) {
this.synthetic = synthetic;
}
public String getC2jName() {
return c2jName;
}
public void setC2jName(String c2jName) {
this.c2jName = c2jName;
}
public MemberModel withC2jName(String c2jName) {
setC2jName(c2jName);
return this;
}
public String getC2jShape() {
return c2jShape;
}
public void setC2jShape(String c2jShape) {
this.c2jShape = c2jShape;
}
public MemberModel withC2jShape(String c2jShape) {
setC2jShape(c2jShape);
return this;
}
public VariableModel getVariable() {
return variable;
}
public void setVariable(VariableModel variable) {
this.variable = variable;
}
public MemberModel withVariable(VariableModel variable) {
setVariable(variable);
return this;
}
public VariableModel getSetterModel() {
return setterModel;
}
public void setSetterModel(VariableModel setterModel) {
this.setterModel = setterModel;
}
public MemberModel withSetterModel(VariableModel setterModel) {
setSetterModel(setterModel);
return this;
}
public String getFluentGetterMethodName() {
return fluentGetterMethodName;
}
public void setFluentGetterMethodName(String fluentGetterMethodName) {
this.fluentGetterMethodName = fluentGetterMethodName;
}
public MemberModel withFluentGetterMethodName(String getterMethodName) {
setFluentGetterMethodName(getterMethodName);
return this;
}
public String getFluentEnumGetterMethodName() {
return fluentEnumGetterMethodName;
}
public void setFluentEnumGetterMethodName(String fluentEnumGetterMethodName) {
this.fluentEnumGetterMethodName = fluentEnumGetterMethodName;
}
public MemberModel withFluentEnumGetterMethodName(String fluentEnumGetterMethodName) {
setFluentEnumGetterMethodName(fluentEnumGetterMethodName);
return this;
}
public String getBeanStyleGetterMethodName() {
return beanStyleGetterName;
}
public void setBeanStyleGetterMethodName(String beanStyleGetterName) {
this.beanStyleGetterName = beanStyleGetterName;
}
public MemberModel withBeanStyleGetterMethodName(String beanStyleGetterName) {
this.beanStyleGetterName = beanStyleGetterName;
return this;
}
public String getBeanStyleSetterMethodName() {
return beanStyleSetterName;
}
public void setBeanStyleSetterMethodName(String beanStyleSetterName) {
this.beanStyleSetterName = beanStyleSetterName;
}
public MemberModel withBeanStyleSetterMethodName(String beanStyleSetterName) {
this.beanStyleSetterName = beanStyleSetterName;
return this;
}
public String getFluentSetterMethodName() {
return fluentSetterMethodName;
}
public void setFluentSetterMethodName(String fluentSetterMethodName) {
this.fluentSetterMethodName = fluentSetterMethodName;
}
public MemberModel withFluentSetterMethodName(String fluentMethodName) {
setFluentSetterMethodName(fluentMethodName);
return this;
}
public String getFluentEnumSetterMethodName() {
return fluentEnumSetterMethodName;
}
public void setFluentEnumSetterMethodName(String fluentEnumSetterMethodName) {
this.fluentEnumSetterMethodName = fluentEnumSetterMethodName;
}
public MemberModel withFluentEnumSetterMethodName(String fluentEnumSetterMethodName) {
setFluentEnumSetterMethodName(fluentEnumSetterMethodName);
return this;
}
public String getExistenceCheckMethodName() {
return existenceCheckMethodName;
}
public void setExistenceCheckMethodName(String existenceCheckMethodName) {
this.existenceCheckMethodName = existenceCheckMethodName;
}
public MemberModel withExistenceCheckMethodName(String existenceCheckMethodName) {
setExistenceCheckMethodName(existenceCheckMethodName);
return this;
}
public ReturnTypeModel getGetterModel() {
return getterModel;
}
public void setGetterModel(ReturnTypeModel getterModel) {
this.getterModel = getterModel;
}
public MemberModel withGetterModel(ReturnTypeModel getterModel) {
setGetterModel(getterModel);
return this;
}
public ParameterHttpMapping getHttp() {
return http;
}
public void setHttp(ParameterHttpMapping parameterHttpMapping) {
this.http = parameterHttpMapping;
}
public boolean isSimple() {
return TypeUtils.isSimple(variable.getVariableType());
}
public boolean isList() {
return listModel != null;
}
public boolean isMap() {
return mapModel != null;
}
public boolean isDeprecated() {
return deprecated;
}
public void setDeprecated(boolean deprecated) {
this.deprecated = deprecated;
}
public String getDeprecatedMessage() {
return deprecatedMessage;
}
public void setDeprecatedMessage(String deprecatedMessage) {
this.deprecatedMessage = deprecatedMessage;
}
public boolean isRequired() {
return required;
}
public void setRequired(boolean required) {
this.required = required;
}
public boolean isEventPayload() {
return eventPayload;
}
public void setEventPayload(boolean eventPayload) {
this.eventPayload = eventPayload;
}
public boolean isEventHeader() {
return eventHeader;
}
public void setEventHeader(boolean eventHeader) {
this.eventHeader = eventHeader;
}
public boolean isEndpointDiscoveryId() {
return endpointDiscoveryId;
}
public void setEndpointDiscoveryId(boolean endpointDiscoveryId) {
this.endpointDiscoveryId = endpointDiscoveryId;
}
public ListModel getListModel() {
return listModel;
}
public void setListModel(ListModel listModel) {
this.listModel = listModel;
}
public MemberModel withListModel(ListModel list) {
setListModel(list);
return this;
}
public MapModel getMapModel() {
return mapModel;
}
public void setMapModel(MapModel map) {
this.mapModel = map;
}
public MemberModel withMapModel(MapModel map) {
setMapModel(map);
return this;
}
public String getEnumType() {
return enumType;
}
public void setEnumType(String enumType) {
this.enumType = enumType;
}
public MemberModel withEnumType(String enumType) {
setEnumType(enumType);
return this;
}
public String getXmlNameSpaceUri() {
return xmlNameSpaceUri;
}
public void setXmlNameSpaceUri(String xmlNameSpaceUri) {
this.xmlNameSpaceUri = xmlNameSpaceUri;
}
public MemberModel withXmlNameSpaceUri(String xmlNameSpaceUri) {
setXmlNameSpaceUri(xmlNameSpaceUri);
return this;
}
public String getSetterDocumentation() {
StringBuilder docBuilder = new StringBuilder();
docBuilder.append(StringUtils.isNotBlank(documentation) ? documentation : defaultSetter().replace("%s", name) + "\n");
docBuilder.append(getParamDoc())
.append(getEnumDoc());
return docBuilder.toString();
}
public String getGetterDocumentation() {
StringBuilder docBuilder = new StringBuilder();
docBuilder.append(StringUtils.isNotBlank(documentation) ? documentation : defaultGetter().replace("%s", name))
.append(LF);
if (returnTypeIs(List.class) || returnTypeIs(Map.class)) {
appendParagraph(docBuilder, "Attempts to modify the collection returned by this method will result in an "
+ "UnsupportedOperationException.");
}
if (enumType != null) {
if (returnTypeIs(List.class)) {
appendParagraph(docBuilder,
"If the list returned by the service includes enum values that are not available in the "
+ "current SDK version, {@link #%s} will use {@link %s#UNKNOWN_TO_SDK_VERSION} in place of those "
+ "values in the list. The raw values returned by the service are available from {@link #%s}.",
getFluentEnumGetterMethodName(), getEnumType(), getFluentGetterMethodName());
} else if (returnTypeIs(Map.class)) {
appendParagraph(docBuilder,
"If the map returned by the service includes enum values that are not available in the "
+ "current SDK version, {@link #%s} will not include those keys in the map. {@link #%s} "
+ "will include all data from the service.",
getFluentEnumGetterMethodName(), getEnumType(), getFluentGetterMethodName());
} else {
appendParagraph(docBuilder,
"If the service returns an enum value that is not available in the current SDK version, "
+ "{@link #%s} will return {@link %s#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the "
+ "service is available from {@link #%s}.",
getFluentEnumGetterMethodName(), getEnumType(), getFluentGetterMethodName());
}
}
if (getAutoConstructClassIfExists().isPresent()) {
appendParagraph(docBuilder,
"This method will never return null. If you would like to know whether the service returned this "
+ "field (so that you can differentiate between null and empty), you can use the {@link #%s} method.",
getExistenceCheckMethodName());
}
String variableDesc = StringUtils.isNotBlank(documentation) ? documentation : defaultGetterParam().replace("%s", name);
docBuilder.append("@return ")
.append(stripHtmlTags(variableDesc))
.append(getEnumDoc());
return docBuilder.toString();
}
public String getDeprecatedGetterDocumentation() {
String getterDocumentation = getGetterDocumentation();
return getterDocumentation
+ LF
+ "@deprecated Use {@link #" + getFluentGetterMethodName() + "()}"
+ LF;
}
private boolean returnTypeIs(Class<?> clazz) {
String returnType = this.getGetterModel().getReturnType();
return returnType != null && returnType.startsWith(clazz.getName()); // Use startsWith in case it's parametrized
}
public String getFluentSetterDocumentation() {
return getSetterDocumentation()
+ LF
+ "@return " + stripHtmlTags(defaultFluentReturn())
+ getEnumDoc();
}
public String getExistenceCheckDocumentation() {
return defaultExistenceCheck().replace("%s", name) + LF;
}
public String getDeprecatedSetterDocumentation() {
return getFluentSetterDocumentation()
+ LF
+ "@deprecated Use {@link #" + getFluentSetterMethodName() + "(" + setterModel.getSimpleType() + ")}"
+ LF;
}
public String getDefaultConsumerFluentSetterDocumentation(String variableType) {
return (StringUtils.isNotBlank(documentation) ? documentation : defaultSetter().replace("%s", name) + "\n")
+ LF
+ "This is a convenience method that creates an instance of the {@link "
+ variableType
+ ".Builder} avoiding the need to create one manually via {@link "
+ variableType
+ "#builder()}.\n"
+ LF
+ "<p>"
+ "When the {@link Consumer} completes, {@link "
+ variableType
+ ".Builder#build()} is called immediately and its result is passed to {@link #"
+ getFluentGetterMethodName()
+ "("
+ variable.getSimpleType()
+ ")}."
+ LF
+ "@param "
+ variable.getVariableName()
+ " a consumer that will call methods on {@link "
+ variableType + ".Builder}"
+ LF
+ "@return " + stripHtmlTags(defaultFluentReturn())
+ LF
+ "@see #"
+ getFluentSetterMethodName()
+ "("
+ variable.getVariableSetterType()
+ ")";
}
public String getUnionConstructorDocumentation() {
return "Create an instance of this class with {@link #" + this.getFluentGetterMethodName() +
"()} initialized to the given value." +
LF + LF +
getSetterDocumentation();
}
private String getParamDoc() {
return LF
+ "@param "
+ variable.getVariableName()
+ " "
+ stripHtmlTags(StringUtils.isNotBlank(documentation) ? documentation : defaultSetterParam().replace("%s", name));
}
private String getEnumDoc() {
StringBuilder docBuilder = new StringBuilder();
if (enumType != null) {
docBuilder.append(LF).append("@see ").append(enumType);
}
return docBuilder.toString();
}
public boolean isIdempotencyToken() {
return idempotencyToken;
}
public void setIdempotencyToken(boolean idempotencyToken) {
this.idempotencyToken = idempotencyToken;
}
public boolean getIsBinary() {
return http.getIsStreaming() ||
(isSdkBytesType() && (http.getIsPayload() || isEventPayload()));
}
/**
* @return Implementation of {@link PathMarshaller} to use if this member is bound the the URI.
* @throws IllegalStateException If this member is not bound to the URI. Templates should first check
* {@link ParameterHttpMapping#isUri()} first.
*/
// TODO remove when rest XML marshaller refactor is merged
@JsonIgnore
public String getPathMarshaller() {
if (!http.isUri()) {
throw new IllegalStateException("Only members bound to the URI have a path marshaller");
}
String prefix = PathMarshaller.class.getName();
if (http.isGreedy()) {
return prefix + ".GREEDY";
} else if (isIdempotencyToken()) {
return prefix + ".IDEMPOTENCY";
} else {
return prefix + ".NON_GREEDY";
}
}
public boolean isJsonValue() {
return isJsonValue;
}
public void setJsonValue(boolean jsonValue) {
isJsonValue = jsonValue;
}
public MemberModel withJsonValue(boolean jsonValue) {
setJsonValue(jsonValue);
return this;
}
public String getTimestampFormat() {
return timestampFormat;
}
public void setTimestampFormat(String timestampFormat) {
this.timestampFormat = timestampFormat;
}
public MemberModel withTimestampFormat(String timestampFormat) {
setTimestampFormat(timestampFormat);
return this;
}
public void setSensitive(boolean sensitive) {
this.sensitive = sensitive;
}
public boolean isSensitive() {
return sensitive;
}
public boolean isXmlAttribute() {
return xmlAttribute;
}
public void setXmlAttribute(boolean xmlAttribute) {
this.xmlAttribute = xmlAttribute;
}
public MemberModel withXmlAttribtue(boolean xmlAttribtue) {
this.xmlAttribute = xmlAttribtue;
return this;
}
public String getDeprecatedName() {
return deprecatedName;
}
public void setDeprecatedName(String deprecatedName) {
this.deprecatedName = deprecatedName;
}
public MemberModel withDeprecatedName(String deprecatedName) {
this.deprecatedName = deprecatedName;
return this;
}
@JsonIgnore
public boolean hasBuilder() {
return !(isSimple() || isList() || isMap());
}
@JsonIgnore
public boolean containsBuildable() {
return containsBuildable(true);
}
private boolean containsBuildable(boolean root) {
if (!root && hasBuilder()) {
return true;
}
if (isList()) {
return getListModel().getListMemberModel().containsBuildable(false);
}
if (isMap()) {
MapModel mapModel = getMapModel();
return mapModel.getKeyModel().containsBuildable(false) ||
mapModel.getValueModel().containsBuildable(false);
}
return false;
}
@JsonIgnore
public boolean isSdkBytesType() {
return SdkBytes.class.getName().equals(variable.getVariableType());
}
/**
* @return Marshalling type to use when creating a {@link SdkField}. Must be a
* field of {@link MarshallingType}.
*/
public String getMarshallingType() {
if (isList()) {
return "LIST";
} else if (isMap()) {
return "MAP";
} else if (!isSimple()) {
return "SDK_POJO";
} else {
return TypeUtils.getMarshallingType(variable.getSimpleType());
}
}
@JsonIgnore
public ShapeModel getShape() {
return shape;
}
public void setShape(ShapeModel shape) {
this.shape = shape;
}
@Override
public String toString() {
return c2jName;
}
private void appendParagraph(StringBuilder builder, String content, Object... contentArgs) {
builder.append("<p>")
.append(LF)
.append(String.format(content, contentArgs))
.append(LF)
.append("</p>")
.append(LF);
}
public Optional<ClassName> getAutoConstructClassIfExists() {
if (isList()) {
return Optional.of(ClassName.get(SdkAutoConstructList.class));
} else if (isMap()) {
return Optional.of(ClassName.get(SdkAutoConstructMap.class));
}
return Optional.empty();
}
public void setDeprecatedFluentGetterMethodName(String fluentDeprecatedGetterMethodName) {
this.fluentDeprecatedGetterMethodName = fluentDeprecatedGetterMethodName;
}
public String getDeprecatedFluentGetterMethodName() {
return fluentDeprecatedGetterMethodName;
}
public void setDeprecatedFluentSetterMethodName(String fluentDeprecatedSetterMethodName) {
this.fluentDeprecatedSetterMethodName = fluentDeprecatedSetterMethodName;
}
public String getDeprecatedFluentSetterMethodName() {
return fluentDeprecatedSetterMethodName;
}
public String getDeprecatedBeanStyleSetterMethodName() {
return deprecatedBeanStyleSetterMethodName;
}
public void setDeprecatedBeanStyleSetterMethodName(String deprecatedBeanStyleSetterMethodName) {
this.deprecatedBeanStyleSetterMethodName = deprecatedBeanStyleSetterMethodName;
}
public String getUnionEnumTypeName() {
return unionEnumTypeName;
}
public void setUnionEnumTypeName(String unionEnumTypeName) {
this.unionEnumTypeName = unionEnumTypeName;
}
public ContextParam getContextParam() {
return contextParam;
}
public void setContextParam(ContextParam contextParam) {
this.contextParam = contextParam;
}
}
| 3,836 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/intermediate/VariableModel.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.intermediate;
import java.util.Collection;
import java.util.List;
public class VariableModel extends DocumentationModel {
private String variableName;
private String variableType;
/**
* Variable declaration type, which can be different from the
* {@link #variableType}, for example, for auto construct list or map.
* Otherwise, it's the same as the {@link #variableType}.
*/
private String variableDeclarationType;
public VariableModel() {
}
public VariableModel(String variableName, String variableType) {
this(variableName, variableType, variableType);
}
public VariableModel(String variableName,
String variableType,
String variableDeclarationType) {
setVariableName(variableName);
setVariableType(variableType);
setVariableDeclarationType(variableDeclarationType);
}
public String getVariableName() {
return variableName;
}
public void setVariableName(String variableName) {
this.variableName = variableName;
}
public String getVariableType() {
return variableType;
}
public void setVariableType(String variableType) {
this.variableType = variableType;
}
public String getSimpleType() {
if (variableType.contains(".")) {
return variableType.substring(variableType.lastIndexOf('.') + 1);
}
return variableType;
}
public VariableModel withDocumentation(String documentation) {
setDocumentation(documentation);
return this;
}
public String getVariableDeclarationType() {
return variableDeclarationType;
}
public void setVariableDeclarationType(String variableDeclarationType) {
this.variableDeclarationType = variableDeclarationType;
}
/**
* Returns the Java type used for the input parameter of a setter method.
*/
public String getVariableSetterType() {
String prefix = List.class.getName();
if (variableType.startsWith(prefix)) {
return Collection.class.getName() + variableType.substring(prefix.length());
} else {
return variableType;
}
}
@Override
public String toString() {
return variableName;
}
}
| 3,837 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/intermediate/AuthorizerModel.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.intermediate;
import com.fasterxml.jackson.annotation.JsonIgnore;
import software.amazon.awssdk.codegen.model.service.Location;
public class AuthorizerModel extends DocumentationModel {
private final String name;
private final String interfaceName;
private final Location authTokenLocation;
private final String tokenName;
public AuthorizerModel(String name, String interfaceName, Location authTokenLocation, String tokenName) {
this.name = name;
this.interfaceName = interfaceName;
this.authTokenLocation = authTokenLocation;
this.tokenName = tokenName;
}
public String getName() {
return name;
}
public boolean hasTokenPlacement() {
return tokenName != null && authTokenLocation != null;
}
public String getTokenName() {
return tokenName;
}
public String getInterfaceName() {
return interfaceName;
}
public Location getAuthTokenLocation() {
return authTokenLocation;
}
@JsonIgnore
public String getAddAuthTokenMethod() {
switch (authTokenLocation) {
case HEADER:
return "addHeader";
case QUERY_STRING:
return "addParameter";
default:
throw new IllegalArgumentException(String.format("Unhandled Location type for Auth Token Location '%s'",
authTokenLocation));
}
}
}
| 3,838 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/intermediate/ShapeMarshaller.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.intermediate;
public class ShapeMarshaller {
private String action;
private String verb;
private String target;
private String requestUri;
private String locationName;
private String xmlNameSpaceUri;
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
public ShapeMarshaller withAction(String action) {
setAction(action);
return this;
}
public String getVerb() {
return verb;
}
public void setVerb(String verb) {
this.verb = verb;
}
public ShapeMarshaller withVerb(String verb) {
setVerb(verb);
return this;
}
public String getTarget() {
return target;
}
public void setTarget(String target) {
this.target = target;
}
public ShapeMarshaller withTarget(String target) {
setTarget(target);
return this;
}
public String getRequestUri() {
return requestUri;
}
public void setRequestUri(String requestUri) {
this.requestUri = requestUri;
}
public ShapeMarshaller withRequestUri(String requestUri) {
setRequestUri(requestUri);
return this;
}
public String getLocationName() {
return locationName;
}
public void setLocationName(String locationName) {
this.locationName = locationName;
}
public ShapeMarshaller withLocationName(String locationName) {
setLocationName(locationName);
return this;
}
public String getXmlNameSpaceUri() {
return xmlNameSpaceUri;
}
public void setXmlNameSpaceUri(String xmlNameSpaceUri) {
this.xmlNameSpaceUri = xmlNameSpaceUri;
}
public ShapeMarshaller withXmlNameSpaceUri(String xmlNameSpaceUri) {
setXmlNameSpaceUri(xmlNameSpaceUri);
return this;
}
}
| 3,839 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/intermediate/ExceptionModel.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.intermediate;
public class ExceptionModel {
private String exceptionName;
private String documentation;
private Integer httpStatusCode;
public ExceptionModel() {
}
public ExceptionModel(String exceptionName) {
this.exceptionName = exceptionName;
}
public String getExceptionName() {
return exceptionName;
}
public void setExceptionName(String exceptionName) {
this.exceptionName = exceptionName;
}
public String getDocumentation() {
return documentation;
}
public void setDocumentation(String documentation) {
this.documentation = documentation;
}
public ExceptionModel withDocumentation(String documentation) {
setDocumentation(documentation);
return this;
}
public Integer getHttpStatusCode() {
return httpStatusCode;
}
public void setHttpStatusCode(Integer httpStatusCode) {
this.httpStatusCode = httpStatusCode;
}
public ExceptionModel withHttpStatusCode(Integer httpStatusCode) {
this.httpStatusCode = httpStatusCode;
return this;
}
}
| 3,840 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/intermediate/Protocol.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.intermediate;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
public enum Protocol {
EC2("ec2"),
AWS_JSON("json"),
REST_JSON("rest-json"),
CBOR("cbor"),
QUERY("query"),
REST_XML("rest-xml");
private String protocol;
Protocol(String protocol) {
this.protocol = protocol;
}
@JsonCreator
public static Protocol fromValue(String strProtocol) {
if (strProtocol == null) {
return null;
}
for (Protocol protocol : Protocol.values()) {
if (protocol.protocol.equals(strProtocol)) {
return protocol;
}
}
throw new IllegalArgumentException("Unknown enum value for Protocol : " + strProtocol);
}
@JsonValue
public String getValue() {
return protocol;
}
}
| 3,841 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/intermediate/ReturnTypeModel.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.intermediate;
public class ReturnTypeModel {
private String returnType;
private String documentation;
public ReturnTypeModel() {
}
public ReturnTypeModel(String returnType) {
setReturnType(returnType);
}
public String getReturnType() {
return returnType;
}
public void setReturnType(String returnType) {
this.returnType = returnType;
}
public String getDocumentation() {
return documentation;
}
public void setDocumentation(String documentation) {
this.documentation = documentation;
}
public ReturnTypeModel withDocumentation(String documentation) {
setDocumentation(documentation);
return this;
}
}
| 3,842 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/intermediate/ArgumentModel.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.intermediate;
public class ArgumentModel extends DocumentationModel {
private String name;
private String type;
private boolean isEnumArg;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public ArgumentModel withName(String name) {
this.name = name;
return this;
}
public ArgumentModel withType(String type) {
this.type = type;
return this;
}
public boolean getIsEnumArg() {
return isEnumArg;
}
public void setIsEnumArg(boolean isEnumArg) {
this.isEnumArg = isEnumArg;
}
public ArgumentModel withIsEnumArg(boolean isEnumArg) {
this.isEnumArg = isEnumArg;
return this;
}
}
| 3,843 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/intermediate/EnumModel.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.intermediate;
/**
* Represents a single enum field in a enum.
*/
public class EnumModel {
/** The value for the enum field.*/
private String value;
/** The name of the enum field. */
private String name;
public EnumModel() {
}
public EnumModel(String name, String value) {
this.name = name;
this.value = value;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public void setValue(String value) {
this.value = value;
}
public String getValue() {
return value;
}
}
| 3,844 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/intermediate/ShapeType.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.intermediate;
public enum ShapeType {
Request("Request"),
Response("Response"),
Exception("Exception"),
Enum("Enum"),
Model("Model");
private String value;
ShapeType(String value) {
this.value = value;
}
public static ShapeType fromValue(String value) {
if (value.equals(Request.getValue())) {
return Request;
} else if (value.equals(Response.getValue())) {
return Response;
} else if (value.equals(Enum.getValue())) {
return Enum;
} else if (value.equals(Exception.getValue())) {
return Exception;
} else {
return Model;
}
}
public String getValue() {
return value;
}
}
| 3,845 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/intermediate/OperationModel.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.intermediate;
import com.fasterxml.jackson.annotation.JsonIgnore;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import software.amazon.awssdk.codegen.checksum.HttpChecksum;
import software.amazon.awssdk.codegen.compression.RequestCompression;
import software.amazon.awssdk.codegen.docs.ClientType;
import software.amazon.awssdk.codegen.docs.DocConfiguration;
import software.amazon.awssdk.codegen.docs.OperationDocs;
import software.amazon.awssdk.codegen.docs.SimpleMethodOverload;
import software.amazon.awssdk.codegen.internal.Utils;
import software.amazon.awssdk.codegen.model.service.AuthType;
import software.amazon.awssdk.codegen.model.service.EndpointTrait;
import software.amazon.awssdk.codegen.model.service.StaticContextParam;
public class OperationModel extends DocumentationModel {
private String operationName;
private String serviceProtocol;
private boolean deprecated;
private String deprecatedMessage;
private VariableModel input;
private ReturnTypeModel returnType;
private List<ExceptionModel> exceptions = new ArrayList<>();
private List<SimpleMethodFormModel> simpleMethods;
private boolean hasBlobMemberAsPayload;
private boolean hasStringMemberAsPayload;
private boolean isAuthenticated = true;
private AuthType authType;
private List<AuthType> auth;
private boolean isPaginated;
private boolean endpointOperation;
private boolean endpointCacheRequired;
private EndpointDiscovery endpointDiscovery;
@JsonIgnore
private ShapeModel inputShape;
@JsonIgnore
private ShapeModel outputShape;
private EndpointTrait endpointTrait;
private boolean httpChecksumRequired;
private HttpChecksum httpChecksum;
private RequestCompression requestCompression;
@JsonIgnore
private Map<String, StaticContextParam> staticContextParams;
public String getOperationName() {
return operationName;
}
public void setOperationName(String operationName) {
this.operationName = operationName;
}
public String getMethodName() {
return Utils.unCapitalize(operationName);
}
public String getServiceProtocol() {
return serviceProtocol;
}
public void setServiceProtocol(String serviceProtocol) {
this.serviceProtocol = serviceProtocol;
}
public boolean isDeprecated() {
return deprecated;
}
public void setDeprecated(boolean deprecated) {
this.deprecated = deprecated;
}
public String getDeprecatedMessage() {
return deprecatedMessage;
}
public void setDeprecatedMessage(String deprecatedMessage) {
this.deprecatedMessage = deprecatedMessage;
}
public String getDocs(IntermediateModel model,
ClientType clientType) {
return OperationDocs.getDocs(model, this, clientType);
}
public String getDocs(IntermediateModel model,
ClientType clientType,
SimpleMethodOverload methodOverload) {
return OperationDocs.getDocs(model, this, clientType, methodOverload);
}
public String getDocs(IntermediateModel model,
ClientType clientType,
SimpleMethodOverload methodOverload,
DocConfiguration config) {
return OperationDocs.getDocs(model, this, clientType, methodOverload, config);
}
public boolean isAuthenticated() {
return isAuthenticated;
}
public void setIsAuthenticated(boolean isAuthenticated) {
this.isAuthenticated = isAuthenticated;
}
public AuthType getAuthType() {
return authType;
}
public void setAuthType(AuthType authType) {
this.authType = authType;
}
public List<AuthType> getAuth() {
return auth;
}
public void setAuth(List<AuthType> auth) {
this.auth = auth;
}
public ShapeModel getInputShape() {
return inputShape;
}
public void setInputShape(ShapeModel inputShape) {
this.inputShape = inputShape;
}
public ShapeModel getOutputShape() {
return outputShape;
}
public void setOutputShape(ShapeModel outputShape) {
this.outputShape = outputShape;
}
public VariableModel getInput() {
return input;
}
public void setInput(VariableModel input) {
this.input = input;
}
public ReturnTypeModel getReturnType() {
return returnType;
}
public void setReturnType(ReturnTypeModel returnType) {
this.returnType = returnType;
}
public String getSyncReturnType() {
return returnType.getReturnType();
}
public List<ExceptionModel> getExceptions() {
return exceptions;
}
public void setExceptions(List<ExceptionModel> exceptions) {
this.exceptions = exceptions;
}
public void addException(ExceptionModel exception) {
exceptions.add(exception);
}
@JsonIgnore
public List<SimpleMethodFormModel> getSimpleMethodForms() {
return simpleMethods;
}
public void addSimpleMethodForm(List<ArgumentModel> arguments) {
if (this.simpleMethods == null) {
this.simpleMethods = new ArrayList<>();
}
SimpleMethodFormModel form = new SimpleMethodFormModel();
form.setArguments(arguments);
this.simpleMethods.add(form);
}
public boolean getHasBlobMemberAsPayload() {
return this.hasBlobMemberAsPayload;
}
public void setHasBlobMemberAsPayload(boolean hasBlobMemberAsPayload) {
this.hasBlobMemberAsPayload = hasBlobMemberAsPayload;
}
public boolean getHasStringMemberAsPayload() {
return this.hasStringMemberAsPayload;
}
public void setHasStringMemberAsPayload(boolean hasStringMemberAsPayload) {
this.hasStringMemberAsPayload = hasStringMemberAsPayload;
}
public boolean hasStreamingInput() {
return inputShape != null && inputShape.isHasStreamingMember();
}
public boolean hasStreamingOutput() {
return outputShape != null && outputShape.isHasStreamingMember();
}
@JsonIgnore
public boolean isStreaming() {
return hasStreamingInput() || hasStreamingOutput();
}
public boolean isEndpointOperation() {
return endpointOperation;
}
public void setEndpointOperation(boolean endpointOperation) {
this.endpointOperation = endpointOperation;
}
public boolean isEndpointCacheRequired() {
return endpointCacheRequired;
}
public void setEndpointCacheRequired(boolean endpointCacheRequired) {
this.endpointCacheRequired = endpointCacheRequired;
}
public boolean isPaginated() {
return isPaginated;
}
public void setPaginated(boolean paginated) {
isPaginated = paginated;
}
public EndpointDiscovery getEndpointDiscovery() {
return endpointDiscovery;
}
public void setEndpointDiscovery(EndpointDiscovery endpointDiscovery) {
this.endpointDiscovery = endpointDiscovery;
}
/**
* Returns the endpoint trait that will be used to resolve the endpoint of an API.
*/
public EndpointTrait getEndpointTrait() {
return endpointTrait;
}
/**
* Sets the endpoint trait that will be used to resolve the endpoint of an API.
*/
public void setEndpointTrait(EndpointTrait endpointTrait) {
this.endpointTrait = endpointTrait;
}
/**
* @return True if the operation has an event stream member in the output shape. False otherwise.
*/
public boolean hasEventStreamOutput() {
return containsEventStream(outputShape);
}
/**
* @return True if the operation has an event stream member in the input shape. False otherwise.
*/
public boolean hasEventStreamInput() {
return containsEventStream(inputShape);
}
public boolean hasRequiresLengthInInput() {
return inputShape != null && inputShape.isHasRequiresLengthMember();
}
private boolean containsEventStream(ShapeModel shapeModel) {
return shapeModel != null
&& shapeModel.getMembers() != null
&& shapeModel.getMembers().stream()
.filter(m -> m.getShape() != null)
.anyMatch(m -> m.getShape().isEventStream());
}
public boolean isHttpChecksumRequired() {
return httpChecksumRequired;
}
public void setHttpChecksumRequired(boolean httpChecksumRequired) {
this.httpChecksumRequired = httpChecksumRequired;
}
public HttpChecksum getHttpChecksum() {
return httpChecksum;
}
public void setHttpChecksum(HttpChecksum httpChecksum) {
this.httpChecksum = httpChecksum;
}
public RequestCompression getRequestCompression() {
return requestCompression;
}
public void setRequestCompression(RequestCompression requestCompression) {
this.requestCompression = requestCompression;
}
public Map<String, StaticContextParam> getStaticContextParams() {
return staticContextParams;
}
public void setStaticContextParams(Map<String, StaticContextParam> staticContextParams) {
this.staticContextParams = staticContextParams;
}
}
| 3,846 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/intermediate/Metadata.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.intermediate;
import java.util.List;
import java.util.Map;
import software.amazon.awssdk.awscore.exception.AwsErrorDetails;
import software.amazon.awssdk.codegen.model.service.AuthType;
import software.amazon.awssdk.utils.StringUtils;
public class Metadata {
private String apiVersion;
private Protocol protocol;
private String documentation;
private String defaultEndpoint;
private String defaultRegion;
private String defaultEndpointWithoutHttpProtocol;
private String syncInterface;
private String syncClient;
private String syncBuilderInterface;
private String syncBuilder;
private String asyncInterface;
private String asyncClient;
private String asyncBuilderInterface;
private String asyncBuilder;
private String baseBuilderInterface;
private String baseBuilder;
private String rootPackageName;
private String clientPackageName;
private String modelPackageName;
private String transformPackageName;
private String requestTransformPackageName;
private String paginatorsPackageName;
private String authPolicyPackageName;
private String waitersPackageName;
private String endpointRulesPackageName;
private String authSchemePackageName;
private String serviceAbbreviation;
private String serviceFullName;
private String serviceName;
private String baseExceptionName;
private String contentType;
private String jsonVersion;
private Map<String, String> awsQueryCompatible;
private String endpointPrefix;
private String signingName;
private boolean requiresIamSigners;
private boolean requiresApiKey;
private String uid;
private AuthType authType;
private String baseRequestName;
private String baseResponseName;
private boolean supportsH2;
private String serviceId;
private List<AuthType> auth;
public List<AuthType> getAuth() {
return auth;
}
public void setAuth(List<AuthType> auth) {
this.auth = auth;
}
public Metadata withAuth(List<AuthType> auth) {
this.auth = auth;
return this;
}
public String getApiVersion() {
return apiVersion;
}
public void setApiVersion(String apiVersion) {
this.apiVersion = apiVersion;
}
public Metadata withApiVersion(String apiVersion) {
setApiVersion(apiVersion);
return this;
}
public Protocol getProtocol() {
return protocol;
}
public void setProtocol(Protocol protocol) {
this.protocol = protocol;
}
public Metadata withProtocol(Protocol protocol) {
setProtocol(protocol);
return this;
}
public String getDocumentation() {
return documentation;
}
public void setDocumentation(String documentation) {
this.documentation = documentation;
}
public Metadata withDocumentation(String documentation) {
setDocumentation(documentation);
return this;
}
public String getDefaultEndpoint() {
return defaultEndpoint;
}
public void setDefaultEndpoint(String defaultEndpoint) {
this.defaultEndpoint = defaultEndpoint;
}
public Metadata withDefaultEndpoint(String defaultEndpoint) {
setDefaultEndpoint(defaultEndpoint);
return this;
}
public String getDefaultRegion() {
return defaultRegion;
}
public void setDefaultRegion(String defaultRegion) {
this.defaultRegion = defaultRegion;
}
public Metadata withDefaultRegion(String defaultRegion) {
setDefaultRegion(defaultRegion);
return this;
}
public String getDefaultEndpointWithoutHttpProtocol() {
return defaultEndpointWithoutHttpProtocol;
}
public void setDefaultEndpointWithoutHttpProtocol(
String defaultEndpointWithoutHttpProtocol) {
this.defaultEndpointWithoutHttpProtocol = defaultEndpointWithoutHttpProtocol;
}
public Metadata withDefaultEndpointWithoutHttpProtocol(
String defaultEndpointWithoutHttpProtocol) {
setDefaultEndpointWithoutHttpProtocol(defaultEndpointWithoutHttpProtocol);
return this;
}
public String getSyncInterface() {
return syncInterface;
}
public void setSyncInterface(String syncInterface) {
this.syncInterface = syncInterface;
}
public Metadata withSyncInterface(String syncInterface) {
setSyncInterface(syncInterface);
return this;
}
public String getSyncClient() {
return syncClient;
}
public void setSyncClient(String syncClient) {
this.syncClient = syncClient;
}
public Metadata withSyncClient(String syncClient) {
setSyncClient(syncClient);
return this;
}
public String getSyncBuilderInterface() {
return syncBuilderInterface;
}
public void setSyncBuilderInterface(String syncBuilderInterface) {
this.syncBuilderInterface = syncBuilderInterface;
}
public Metadata withSyncBuilderInterface(String syncBuilderInterface) {
this.syncBuilderInterface = syncBuilderInterface;
return this;
}
public String getSyncBuilder() {
return syncBuilder;
}
public void setSyncBuilder(String syncBuilder) {
this.syncBuilder = syncBuilder;
}
public Metadata withSyncBuilder(String syncBuilder) {
this.syncBuilder = syncBuilder;
return this;
}
public String getAsyncInterface() {
return asyncInterface;
}
public void setAsyncInterface(String asyncInterface) {
this.asyncInterface = asyncInterface;
}
public Metadata withAsyncInterface(String asyncInterface) {
setAsyncInterface(asyncInterface);
return this;
}
public String getAsyncClient() {
return asyncClient;
}
public void setAsyncClient(String asyncClient) {
this.asyncClient = asyncClient;
}
public Metadata withAsyncClient(String asyncClient) {
setAsyncClient(asyncClient);
return this;
}
public String getAsyncBuilderInterface() {
return asyncBuilderInterface;
}
public void setAsyncBuilderInterface(String asyncBuilderInterface) {
this.asyncBuilderInterface = asyncBuilderInterface;
}
public Metadata withAsyncBuilderInterface(String asyncBuilderInterface) {
this.asyncBuilderInterface = asyncBuilderInterface;
return this;
}
public String getBaseBuilderInterface() {
return baseBuilderInterface;
}
public void setBaseBuilderInterface(String baseBuilderInterface) {
this.baseBuilderInterface = baseBuilderInterface;
}
public Metadata withBaseBuilderInterface(String baseBuilderInterface) {
this.baseBuilderInterface = baseBuilderInterface;
return this;
}
public String getBaseBuilder() {
return baseBuilder;
}
public void setBaseBuilder(String baseBuilder) {
this.baseBuilder = baseBuilder;
}
public Metadata withBaseBuilder(String baseBuilder) {
this.baseBuilder = baseBuilder;
return this;
}
public String getAsyncBuilder() {
return asyncBuilder;
}
public void setAsyncBuilder(String asyncBuilder) {
this.asyncBuilder = asyncBuilder;
}
public Metadata withAsyncBuilder(String asyncBuilder) {
this.asyncBuilder = asyncBuilder;
return this;
}
public String getBaseExceptionName() {
return baseExceptionName;
}
public void setBaseExceptionName(String baseExceptionName) {
this.baseExceptionName = baseExceptionName;
}
public Metadata withBaseExceptionName(String baseExceptionName) {
setBaseExceptionName(baseExceptionName);
return this;
}
public String getRootPackageName() {
return rootPackageName;
}
public void setRootPackageName(String rootPackageName) {
this.rootPackageName = rootPackageName;
}
public Metadata withRootPackageName(String rootPackageName) {
setRootPackageName(rootPackageName);
return this;
}
public String getFullClientPackageName() {
return joinPackageNames(rootPackageName, getClientPackageName());
}
public String getFullClientInternalPackageName() {
return joinPackageNames(getFullClientPackageName(), "internal");
}
public String getClientPackageName() {
return clientPackageName;
}
public void setClientPackageName(String clientPackageName) {
this.clientPackageName = clientPackageName;
}
public Metadata withClientPackageName(String clientPackageName) {
setClientPackageName(clientPackageName);
return this;
}
public String getFullModelPackageName() {
return joinPackageNames(rootPackageName, getModelPackageName());
}
public String getModelPackageName() {
return modelPackageName;
}
public void setModelPackageName(String modelPackageName) {
this.modelPackageName = modelPackageName;
}
public Metadata withModelPackageName(String modelPackageName) {
setModelPackageName(modelPackageName);
return this;
}
public String getFullTransformPackageName() {
return joinPackageNames(rootPackageName, getTransformPackageName());
}
public String getTransformPackageName() {
return transformPackageName;
}
public void setTransformPackageName(String transformPackageName) {
this.transformPackageName = transformPackageName;
}
public Metadata withTransformPackageName(String transformPackageName) {
setTransformPackageName(transformPackageName);
return this;
}
public String getFullRequestTransformPackageName() {
return joinPackageNames(rootPackageName, getRequestTransformPackageName());
}
public String getRequestTransformPackageName() {
return requestTransformPackageName;
}
public void setRequestTransformPackageName(String requestTransformPackageName) {
this.requestTransformPackageName = requestTransformPackageName;
}
public Metadata withRequestTransformPackageName(String requestTransformPackageName) {
setRequestTransformPackageName(requestTransformPackageName);
return this;
}
public String getFullPaginatorsPackageName() {
return joinPackageNames(rootPackageName, getPaginatorsPackageName());
}
public String getPaginatorsPackageName() {
return paginatorsPackageName;
}
public void setPaginatorsPackageName(String paginatorsPackageName) {
this.paginatorsPackageName = paginatorsPackageName;
}
public Metadata withPaginatorsPackageName(String paginatorsPackageName) {
setPaginatorsPackageName(paginatorsPackageName);
return this;
}
public String getFullAuthPolicyPackageName() {
return joinPackageNames(rootPackageName, getAuthPolicyPackageName());
}
public String getAuthPolicyPackageName() {
return authPolicyPackageName;
}
public void setAuthPolicyPackageName(String authPolicyPackageName) {
this.authPolicyPackageName = authPolicyPackageName;
}
public Metadata withAuthPolicyPackageName(String authPolicyPackageName) {
setAuthPolicyPackageName(authPolicyPackageName);
return this;
}
public void setServiceAbbreviation(String serviceAbbreviation) {
this.serviceAbbreviation = serviceAbbreviation;
}
public Metadata withServiceAbbreviation(String serviceAbbreviation) {
setServiceAbbreviation(serviceAbbreviation);
return this;
}
public void setServiceFullName(String serviceFullName) {
this.serviceFullName = serviceFullName;
}
public Metadata withServiceFullName(String serviceFullName) {
setServiceFullName(serviceFullName);
return this;
}
/**
* Returns a convenient name for the service. If an abbreviated form
* of the service name is available it will return that, otherwise it
* will return the full service name.
*/
public String getDescriptiveServiceName() {
if (serviceAbbreviation != null) {
return serviceAbbreviation;
}
return serviceFullName;
}
/**
* @return Unique, short name for the service. Suitable for displaying in metadata like {@link AwsErrorDetails} and
* for use in metrics. Should not be used in documentation, use {@link #getDescriptiveServiceName()} for that.
*/
public String getServiceName() {
return this.serviceName;
}
public void setServiceName(String serviceName) {
this.serviceName = serviceName;
}
public Metadata withServiceName(String serviceName) {
setServiceName(serviceName);
return this;
}
public String getJsonVersion() {
return jsonVersion;
}
public void setJsonVersion(String jsonVersion) {
this.jsonVersion = jsonVersion;
}
public Metadata withJsonVersion(String jsonVersion) {
setJsonVersion(jsonVersion);
return this;
}
public Map<String, String> getAwsQueryCompatible() {
return awsQueryCompatible;
}
public void setAwsQueryCompatible(Map<String, String> awsQueryCompatible) {
this.awsQueryCompatible = awsQueryCompatible;
}
public Metadata withAwsQueryCompatible(Map<String, String> awsQueryCompatible) {
setAwsQueryCompatible(awsQueryCompatible);
return this;
}
public boolean isCborProtocol() {
return protocol == Protocol.CBOR;
}
public boolean isJsonProtocol() {
return protocol == Protocol.CBOR ||
protocol == Protocol.AWS_JSON ||
protocol == Protocol.REST_JSON;
}
public boolean isXmlProtocol() {
return protocol == Protocol.EC2 ||
protocol == Protocol.QUERY ||
protocol == Protocol.REST_XML;
}
public boolean isQueryProtocol() {
return protocol == Protocol.EC2 ||
protocol == Protocol.QUERY;
}
/**
* @return True for RESTful protocols. False for all other protocols (RPC, Query, etc).
*/
public static boolean isNotRestProtocol(String protocol) {
switch (Protocol.fromValue(protocol)) {
case REST_JSON:
case REST_XML:
return false;
default:
return true;
}
}
public String getEndpointPrefix() {
return endpointPrefix;
}
public void setEndpointPrefix(String endpointPrefix) {
this.endpointPrefix = endpointPrefix;
}
public Metadata withEndpointPrefix(String endpointPrefix) {
setEndpointPrefix(endpointPrefix);
return this;
}
public String getSigningName() {
return signingName;
}
public void setSigningName(String signingName) {
this.signingName = signingName;
}
public Metadata withSigningName(String signingName) {
setSigningName(signingName);
return this;
}
public void setContentType(String contentType) {
this.contentType = contentType;
}
public String getContentType() {
return contentType;
}
public boolean isRequiresIamSigners() {
return requiresIamSigners;
}
public void setRequiresIamSigners(boolean requiresIamSigners) {
this.requiresIamSigners = requiresIamSigners;
}
public boolean isRequiresApiKey() {
return requiresApiKey;
}
public Metadata withRequiresApiKey(boolean requiresApiKey) {
this.requiresApiKey = requiresApiKey;
return this;
}
public String getUid() {
return uid;
}
public void setUid(String uid) {
this.uid = uid;
}
public Metadata withUid(String uid) {
setUid(uid);
return this;
}
public AuthType getAuthType() {
return authType;
}
public void setAuthType(AuthType authType) {
this.authType = authType;
}
public Metadata withAuthType(AuthType authType) {
this.authType = authType;
return this;
}
public String getBaseRequestName() {
return baseRequestName;
}
public Metadata withBaseRequestName(String baseRequestName) {
this.baseRequestName = baseRequestName;
return this;
}
public String getBaseResponseName() {
return baseResponseName;
}
public Metadata withBaseResponseName(String baseResponseName) {
this.baseResponseName = baseResponseName;
return this;
}
private String joinPackageNames(String lhs, String rhs) {
return StringUtils.isBlank(rhs) ? lhs : lhs + '.' + rhs;
}
public boolean supportsH2() {
return supportsH2;
}
public void setSupportsH2(boolean supportsH2) {
this.supportsH2 = supportsH2;
}
public Metadata withSupportsH2(boolean supportsH2) {
setSupportsH2(supportsH2);
return this;
}
public String getServiceId() {
return serviceId;
}
public void setServiceId(String serviceId) {
this.serviceId = serviceId;
}
public Metadata withServiceId(String serviceId) {
setServiceId(serviceId);
return this;
}
public String getWaitersPackageName() {
return waitersPackageName;
}
public void setWaitersPackageName(String waitersPackageName) {
this.waitersPackageName = waitersPackageName;
}
public Metadata withWaitersPackageName(String waitersPackageName) {
setWaitersPackageName(waitersPackageName);
return this;
}
public String getFullWaitersPackageName() {
return joinPackageNames(rootPackageName, getWaitersPackageName());
}
public String getFullWaitersInternalPackageName() {
return joinPackageNames(getFullWaitersPackageName(), "internal");
}
public void setEndpointRulesPackageName(String endpointRulesPackageName) {
this.endpointRulesPackageName = endpointRulesPackageName;
}
public Metadata withEndpointRulesPackageName(String endpointRulesPackageName) {
setEndpointRulesPackageName(endpointRulesPackageName);
return this;
}
public String getEndpointRulesPackageName() {
return endpointRulesPackageName;
}
public String getFullEndpointRulesPackageName() {
return joinPackageNames(rootPackageName, getEndpointRulesPackageName());
}
public String getFullInternalEndpointRulesPackageName() {
return joinPackageNames(getFullEndpointRulesPackageName(), "internal");
}
public void setAuthSchemePackageName(String authSchemePackageName) {
this.authSchemePackageName = authSchemePackageName;
}
public Metadata withAuthSchemePackageName(String authSchemePackageName) {
setAuthSchemePackageName(authSchemePackageName);
return this;
}
public String getAuthSchemePackageName() {
return authSchemePackageName;
}
public String getFullAuthSchemePackageName() {
return joinPackageNames(rootPackageName, getAuthSchemePackageName());
}
public String getFullInternalAuthSchemePackageName() {
return joinPackageNames(getFullAuthSchemePackageName(), "internal");
}
public String getFullInternalPackageName() {
return joinPackageNames(getFullClientPackageName(), "internal");
}
}
| 3,847 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/intermediate/MapModel.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.intermediate;
public class MapModel {
private String implType;
private String interfaceType;
private String keyLocationName;
private MemberModel keyModel;
private String valueLocationName;
private MemberModel valueModel;
public MapModel() {
}
public MapModel(String implType,
String interfaceType,
String keyLocationName,
MemberModel keyModel,
String valueLocationName,
MemberModel valueModel) {
this.implType = implType;
this.interfaceType = interfaceType;
this.keyLocationName = keyLocationName;
this.keyModel = keyModel;
this.valueLocationName = valueLocationName;
this.valueModel = valueModel;
}
public String getImplType() {
return implType;
}
public void setImplType(String implType) {
this.implType = implType;
}
public String getInterfaceType() {
return interfaceType;
}
public void setInterfaceType(String interfaceType) {
this.interfaceType = interfaceType;
}
public String getKeyLocationName() {
return keyLocationName;
}
public void setKeyLocationName(String keyLocationName) {
this.keyLocationName = keyLocationName;
}
public MemberModel getKeyModel() {
return keyModel;
}
public void setKeyModel(MemberModel keyModel) {
this.keyModel = keyModel;
}
public String getValueLocationName() {
return valueLocationName;
}
public void setValueLocationName(String valueLocationName) {
this.valueLocationName = valueLocationName;
}
public MemberModel getValueModel() {
return valueModel;
}
public void setValueModel(MemberModel valueModel) {
this.valueModel = valueModel;
}
public String getTemplateType() {
return interfaceType +
"<" + keyModel.getVariable().getVariableType() + "," + valueModel.getVariable().getVariableType() + ">";
}
public String getEntryType() {
return String.format("Map.Entry<%s, %s>",
keyModel.getVariable().getVariableType(), valueModel.getVariable().getVariableType());
}
}
| 3,848 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/intermediate/ListModel.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.intermediate;
import software.amazon.awssdk.codegen.internal.TypeUtils;
public class ListModel {
private String implType;
private String memberType;
private String interfaceType;
private MemberModel listMemberModel;
private String memberLocationName;
private String memberAdditionalMarshallingPath;
private String memberAdditionalUnmarshallingPath;
public ListModel() {
}
public ListModel(String memberType,
String memberLocationName,
String implType,
String interfaceType,
MemberModel listMemberModel) {
this.memberType = memberType;
this.memberLocationName = memberLocationName;
this.implType = implType;
this.interfaceType = interfaceType;
this.listMemberModel = listMemberModel;
}
public String getImplType() {
return implType;
}
public void setImplType(String implType) {
this.implType = implType;
}
public String getMemberType() {
return memberType;
}
public void setMemberType(String memberType) {
this.memberType = memberType;
}
public String getInterfaceType() {
return interfaceType;
}
public void setInterfaceType(String interfaceType) {
this.interfaceType = interfaceType;
}
public MemberModel getListMemberModel() {
return listMemberModel;
}
public void setListMemberModel(MemberModel listMemberModel) {
this.listMemberModel = listMemberModel;
}
public String getMemberLocationName() {
return memberLocationName;
}
public void setMemberLocationName(String memberLocationName) {
this.memberLocationName = memberLocationName;
}
public String getMemberAdditionalMarshallingPath() {
return memberAdditionalMarshallingPath;
}
public void setMemberAdditionalMarshallingPath(
String memberAdditionalMarshallingPath) {
this.memberAdditionalMarshallingPath = memberAdditionalMarshallingPath;
}
public String getMemberAdditionalUnmarshallingPath() {
return memberAdditionalUnmarshallingPath;
}
public void setMemberAdditionalUnmarshallingPath(
String memberAdditionalUnmarshallingPath) {
this.memberAdditionalUnmarshallingPath = memberAdditionalUnmarshallingPath;
}
public boolean isSimple() {
return TypeUtils.isSimple(memberType);
}
public boolean isMap() {
return memberType.startsWith(TypeUtils
.getDataTypeMapping(TypeUtils.TypeKey.MAP_INTERFACE));
}
public String getTemplateType() {
return interfaceType + "<" + memberType + ">";
}
public String getTemplateImplType() {
return implType + "<" + memberType + ">";
}
public String getSimpleType() {
int startIndex = memberType.lastIndexOf('.');
return memberType.substring(startIndex + 1);
}
}
| 3,849 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/intermediate/EndpointDiscovery.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.intermediate;
public class EndpointDiscovery {
private boolean required;
public boolean isRequired() {
return required;
}
public void setRequired(boolean required) {
this.required = required;
}
}
| 3,850 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/intermediate/ShapeUnmarshaller.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.intermediate;
public class ShapeUnmarshaller {
private String resultWrapper;
private boolean flattened;
public String getResultWrapper() {
return resultWrapper;
}
public void setResultWrapper(String resultWrapper) {
this.resultWrapper = resultWrapper;
}
public ShapeUnmarshaller withResultWrapper(String resultWrapper) {
setResultWrapper(resultWrapper);
return this;
}
public boolean isFlattened() {
return flattened;
}
public void setFlattened(boolean flattened) {
this.flattened = flattened;
}
public ShapeUnmarshaller withFlattened(boolean flattened) {
setFlattened(flattened);
return this;
}
}
| 3,851 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/intermediate/ShapeModel.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.intermediate;
import static software.amazon.awssdk.codegen.internal.Constant.LF;
import static software.amazon.awssdk.codegen.internal.Constant.REQUEST_CLASS_SUFFIX;
import static software.amazon.awssdk.codegen.internal.Constant.RESPONSE_CLASS_SUFFIX;
import static software.amazon.awssdk.codegen.internal.DocumentationUtils.removeFromEnd;
import com.fasterxml.jackson.annotation.JsonIgnore;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import software.amazon.awssdk.codegen.model.intermediate.customization.ShapeCustomizationInfo;
import software.amazon.awssdk.codegen.model.service.XmlNamespace;
import software.amazon.awssdk.utils.StringUtils;
public class ShapeModel extends DocumentationModel implements HasDeprecation {
private String c2jName;
// shapeName might be later modified by the customization.
private String shapeName;
// the local variable name inside marshaller/unmarshaller implementation
private boolean deprecated;
private String deprecatedMessage;
private String type;
private List<String> required;
private boolean hasPayloadMember;
private boolean hasHeaderMember;
private boolean hasStatusCodeMember;
private boolean hasStreamingMember;
private boolean hasRequiresLengthMember;
private boolean wrapper;
private boolean simpleMethod;
private String requestSignerClassFqcn;
private EndpointDiscovery endpointDiscovery;
private List<MemberModel> members;
private List<EnumModel> enums;
private VariableModel variable;
private ShapeMarshaller marshaller;
private ShapeUnmarshaller unmarshaller;
private String errorCode;
private Integer httpStatusCode;
private boolean fault;
private ShapeCustomizationInfo customization = new ShapeCustomizationInfo();
private boolean isEventStream;
private boolean isEvent;
private XmlNamespace xmlNamespace;
private boolean document;
private boolean union;
public ShapeModel() {
}
public ShapeModel(String c2jName) {
this.c2jName = c2jName;
}
public String getShapeName() {
return shapeName;
}
public void setShapeName(String shapeName) {
this.shapeName = shapeName;
}
@Override
public boolean isDeprecated() {
return deprecated;
}
public void setDeprecated(boolean deprecated) {
this.deprecated = deprecated;
}
public String getDeprecatedMessage() {
return deprecatedMessage;
}
public void setDeprecatedMessage(String deprecatedMessage) {
this.deprecatedMessage = deprecatedMessage;
}
public String getC2jName() {
return c2jName;
}
public void setC2jName(String c2jName) {
this.c2jName = c2jName;
}
public String getType() {
return type;
}
@JsonIgnore
public void setType(ShapeType shapeType) {
setType(shapeType.getValue());
}
public void setType(String type) {
this.type = type;
}
@JsonIgnore
public ShapeType getShapeType() {
return ShapeType.fromValue(type);
}
public ShapeModel withType(String type) {
this.type = type;
return this;
}
// Returns the list of C2j member names that are required for this shape.
public List<String> getRequired() {
return required;
}
public void setRequired(List<String> required) {
this.required = required;
}
public boolean isHasPayloadMember() {
return hasPayloadMember;
}
public void setHasPayloadMember(boolean hasPayloadMember) {
this.hasPayloadMember = hasPayloadMember;
}
public ShapeModel withHasPayloadMember(boolean hasPayloadMember) {
setHasPayloadMember(hasPayloadMember);
return this;
}
/**
* @return The member explicitly designated as the payload member
*/
@JsonIgnore
public MemberModel getPayloadMember() {
MemberModel payloadMember = null;
for (MemberModel member : members) {
if (member.getHttp().getIsPayload()) {
if (payloadMember == null) {
payloadMember = member;
} else {
throw new IllegalStateException(
String.format("Only one payload member can be explicitly set on %s. This is likely an error in " +
"the C2J model", c2jName));
}
}
}
return payloadMember;
}
/**
* @return The list of members whose location is not specified. If no payload member is
* explicitly set then these members will appear in the payload
*/
@JsonIgnore
public List<MemberModel> getUnboundMembers() {
List<MemberModel> unboundMembers = new ArrayList<>();
if (members != null) {
for (MemberModel member : members) {
if (member.getHttp().getLocation() == null && !member.getHttp().getIsPayload()) {
if (hasPayloadMember) {
// There is an explicit payload, but this unbound
// member isn't it.
// Note: Somewhat unintuitive, explicit payloads don't
// have an explicit location; they're identified by
// the payload HTTP trait being true.
throw new IllegalStateException(String.format(
"C2J Shape %s has both an explicit payload member and unbound (no explicit location) member, %s."
+ " This is undefined behavior, verify the correctness of the C2J model.",
c2jName, member.getName()));
}
unboundMembers.add(member);
}
}
}
return unboundMembers;
}
/**
* @return The list of members whose are not marked with either eventheader or eventpayload trait.
*/
@JsonIgnore
public List<MemberModel> getUnboundEventMembers() {
if (members == null) {
return new ArrayList<>();
}
return members.stream()
.filter(m -> !m.isEventHeader())
.filter(m -> !m.isEventPayload())
.collect(Collectors.toList());
}
/**
* @return True if the shape has an explicit payload member or implicit payload member(s).
*/
public boolean hasPayloadMembers() {
return hasPayloadMember ||
getExplicitEventPayloadMember() != null ||
hasImplicitPayloadMembers();
}
public boolean hasImplicitPayloadMembers() {
return !getUnboundMembers().isEmpty() ||
hasImplicitEventPayloadMembers();
}
public boolean hasImplicitEventPayloadMembers() {
return isEvent() && !getUnboundEventMembers().isEmpty();
}
/**
* Explicit event payload member will have "eventpayload" trait set to true.
* There can be at most only one member that can be declared as explicit payload.
*
* @return the member that has the 'eventpayload' trait set to true. If none found, return null.
*/
public MemberModel getExplicitEventPayloadMember() {
if (members == null) {
return null;
}
return members.stream()
.filter(MemberModel::isEventPayload)
.findFirst()
.orElse(null);
}
/**
* If all members in shape have eventheader trait, then there is no payload
*/
public boolean hasNoEventPayload() {
return members == null || members.stream().allMatch(MemberModel::isEventHeader);
}
public boolean isHasStreamingMember() {
return hasStreamingMember;
}
public void setHasStreamingMember(boolean hasStreamingMember) {
this.hasStreamingMember = hasStreamingMember;
}
public ShapeModel withHasStreamingMember(boolean hasStreamingMember) {
setHasStreamingMember(hasStreamingMember);
return this;
}
public boolean isHasRequiresLengthMember() {
return hasRequiresLengthMember;
}
public void setHasRequiresLengthMember(boolean hasRequiresLengthMember) {
this.hasRequiresLengthMember = hasRequiresLengthMember;
}
public ShapeModel withHasRequiresLengthMember(boolean hasRequiresLengthMember) {
setHasRequiresLengthMember(hasRequiresLengthMember);
return this;
}
public boolean isHasHeaderMember() {
return hasHeaderMember;
}
public void setHasHeaderMember(boolean hasHeaderMember) {
this.hasHeaderMember = hasHeaderMember;
}
public ShapeModel withHasHeaderMember(boolean hasHeaderMember) {
setHasHeaderMember(hasHeaderMember);
return this;
}
public boolean isHasStatusCodeMember() {
return hasStatusCodeMember;
}
public void setHasStatusCodeMember(boolean hasStatusCodeMember) {
this.hasStatusCodeMember = hasStatusCodeMember;
}
public boolean isWrapper() {
return wrapper;
}
public void setWrapper(boolean wrapper) {
this.wrapper = wrapper;
}
public boolean isSimpleMethod() {
return simpleMethod;
}
public void setSimpleMethod(boolean simpleMethod) {
this.simpleMethod = simpleMethod;
}
public ShapeModel withHasStatusCodeMember(boolean hasStatusCodeMember) {
setHasStatusCodeMember(hasStatusCodeMember);
return this;
}
public MemberModel getMemberByVariableName(String memberVariableName) {
for (MemberModel memberModel : members) {
if (memberModel.getVariable().getVariableName().equals(memberVariableName)) {
return memberModel;
}
}
throw new IllegalArgumentException("Unknown member variable name: " + memberVariableName);
}
public MemberModel getMemberByName(String memberName) {
for (MemberModel memberModel : members) {
if (memberModel.getName().equals(memberName)) {
return memberModel;
}
}
return null;
}
public MemberModel getMemberByC2jName(String memberName) {
for (MemberModel memberModel : members) {
if (memberModel.getC2jName().equals(memberName)) {
return memberModel;
}
}
return null;
}
public List<MemberModel> getMembers() {
if (members == null) {
return Collections.emptyList();
}
return members;
}
/**
* @return All non-streaming members of the shape.
*/
public List<MemberModel> getNonStreamingMembers() {
return getMembers().stream()
// Filter out binary streaming members
.filter(m -> !m.getHttp().getIsStreaming())
// Filter out event stream members (if shape is null then it's primitive and we should include it).
.filter(m -> m.getShape() == null || !m.getShape().isEventStream)
.collect(Collectors.toList());
}
public void setMembers(List<MemberModel> members) {
this.members = members;
}
public void addMember(MemberModel member) {
if (this.members == null) {
this.members = new ArrayList<>();
}
members.add(member);
}
public List<EnumModel> getEnums() {
return enums;
}
public void setEnums(List<EnumModel> enums) {
this.enums = enums;
}
public void addEnum(EnumModel enumModel) {
if (this.enums == null) {
this.enums = new ArrayList<>();
}
this.enums.add(enumModel);
}
public VariableModel getVariable() {
return variable;
}
public void setVariable(VariableModel variable) {
this.variable = variable;
}
public ShapeMarshaller getMarshaller() {
return marshaller;
}
public void setMarshaller(ShapeMarshaller marshaller) {
this.marshaller = marshaller;
}
public ShapeUnmarshaller getUnmarshaller() {
return unmarshaller;
}
public void setUnmarshaller(ShapeUnmarshaller unmarshaller) {
this.unmarshaller = unmarshaller;
}
public ShapeCustomizationInfo getCustomization() {
return customization;
}
public void setCustomization(ShapeCustomizationInfo customization) {
this.customization = customization;
}
public Map<String, MemberModel> getMembersAsMap() {
Map<String, MemberModel> shapeMembers = new HashMap<>();
// Creating a map of shape's members. This map is used below when
// fetching the details of a member.
List<MemberModel> memberModels = getMembers();
if (memberModels != null) {
for (MemberModel model : memberModels) {
shapeMembers.put(model.getName(), model);
}
}
return shapeMembers;
}
/**
* Tries to find the member model associated with the given c2j member name from this shape
* model. Returns the member model if present else returns null.
*/
public MemberModel tryFindMemberModelByC2jName(String memberC2jName, boolean ignoreCase) {
List<MemberModel> memberModels = getMembers();
String expectedName = ignoreCase ? StringUtils.lowerCase(memberC2jName)
: memberC2jName;
if (memberModels != null) {
for (MemberModel member : memberModels) {
String actualName = ignoreCase ? StringUtils.lowerCase(member.getC2jName())
: member.getC2jName();
if (expectedName.equals(actualName)) {
return member;
}
}
}
return null;
}
/**
* Returns the member model associated with the given c2j member name from this shape model.
*/
public MemberModel findMemberModelByC2jName(String memberC2jName) {
MemberModel model = tryFindMemberModelByC2jName(memberC2jName, false);
if (model == null) {
throw new IllegalArgumentException(memberC2jName + " member (c2j name) does not exist in the shape.");
}
return model;
}
/**
* Takes in the c2j member name as input and removes if the shape contains a member with the
* given name. Return false otherwise.
*/
public boolean removeMemberByC2jName(String memberC2jName, boolean ignoreCase) {
// Implicitly depending on the default equals and hashcode
// implementation of the class MemberModel
MemberModel model = tryFindMemberModelByC2jName(memberC2jName, ignoreCase);
return model == null ? false : members.remove(model);
}
/**
* Returns the enum model for the given enum value.
* Returns null if no such enum value exists.
*/
public EnumModel findEnumModelByValue(String enumValue) {
if (enums != null) {
for (EnumModel enumModel : enums) {
if (enumValue.equals(enumModel.getValue())) {
return enumModel;
}
}
}
return null;
}
@JsonIgnore
public String getDocumentationShapeName() {
switch (getShapeType()) {
case Request:
return removeFromEnd(shapeName, REQUEST_CLASS_SUFFIX);
case Response:
return removeFromEnd(shapeName, RESPONSE_CLASS_SUFFIX);
default:
return c2jName;
}
}
public String getUnionTypeGetterDocumentation() {
return "Retrieve an enum value representing which member of this object is populated. "
+ LF + LF
+ "When this class is returned in a service response, this will be {@link Type#UNKNOWN_TO_SDK_VERSION} if the "
+ "service returned a member that is only known to a newer SDK version."
+ LF + LF
+ "When this class is created directly in your code, this will be {@link Type#UNKNOWN_TO_SDK_VERSION} if zero "
+ "members are set, and {@code null} if more than one member is set.";
}
@Override
public String toString() {
return shapeName;
}
public String getErrorCode() {
return errorCode;
}
public void setErrorCode(String errorCode) {
this.errorCode = errorCode;
}
/**
* Return the httpStatusCode of the exception shape. This value is present only for modeled exceptions.
*/
public Integer getHttpStatusCode() {
return httpStatusCode;
}
public void setHttpStatusCode(Integer httpStatusCode) {
this.httpStatusCode = httpStatusCode;
}
public boolean isRequestSignerAware() {
return requestSignerClassFqcn != null;
}
public String getRequestSignerClassFqcn() {
return requestSignerClassFqcn;
}
public void setRequestSignerClassFqcn(String authorizerClass) {
this.requestSignerClassFqcn = authorizerClass;
}
public EndpointDiscovery getEndpointDiscovery() {
return endpointDiscovery;
}
public void setEndpointDiscovery(EndpointDiscovery endpointDiscovery) {
this.endpointDiscovery = endpointDiscovery;
}
/**
* @return True if the shape is an 'eventstream' shape. The eventstream shape is the tagged union like
* container that holds individual 'events'.
*/
public boolean isEventStream() {
return this.isEventStream;
}
public ShapeModel withIsEventStream(boolean isEventStream) {
this.isEventStream = isEventStream;
return this;
}
/**
* @return True if the shape is an 'event'. I.E. It is a member of the eventstream and represents one logical event
* that can be delivered on the event stream.
*/
public boolean isEvent() {
return this.isEvent;
}
public ShapeModel withIsEvent(boolean isEvent) {
this.isEvent = isEvent;
return this;
}
public XmlNamespace getXmlNamespace() {
return xmlNamespace;
}
public ShapeModel withXmlNamespace(XmlNamespace xmlNamespace) {
this.xmlNamespace = xmlNamespace;
return this;
}
public void setXmlNamespace(XmlNamespace xmlNamespace) {
this.xmlNamespace = xmlNamespace;
}
public boolean isDocument() {
return document;
}
public ShapeModel withIsDocument(boolean document) {
this.document = document;
return this;
}
public boolean isUnion() {
return union;
}
public void withIsUnion(boolean union) {
this.union = union;
}
public boolean isFault() {
return fault;
}
public ShapeModel withIsFault(boolean fault) {
this.fault = fault;
return this;
}
}
| 3,852 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/intermediate/HasDeprecation.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.intermediate;
public interface HasDeprecation {
boolean isDeprecated();
}
| 3,853 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/intermediate/ParameterHttpMapping.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.intermediate;
import software.amazon.awssdk.codegen.model.service.Location;
import software.amazon.awssdk.core.protocol.MarshallLocation;
public class ParameterHttpMapping {
private String unmarshallLocationName;
private String marshallLocationName;
private String additionalUnmarshallingPath;
private String additionalMarshallingPath;
private boolean isPayload;
private boolean isStreaming;
private Location location;
private boolean flattened;
private boolean isGreedy;
private boolean requiresLength;
public boolean getIsPayload() {
return isPayload;
}
public void setPayload(boolean isPayload) {
this.isPayload = isPayload;
}
public ParameterHttpMapping withPayload(boolean isPayload) {
this.isPayload = isPayload;
return this;
}
public boolean getIsStreaming() {
return isStreaming;
}
public void setStreaming(boolean isStreaming) {
this.isStreaming = isStreaming;
}
public ParameterHttpMapping withStreaming(boolean isStreaming) {
this.isStreaming = isStreaming;
return this;
}
public Location getLocation() {
return location;
}
public void setLocation(Location location) {
this.location = location;
}
public ParameterHttpMapping withLocation(Location location) {
this.location = location;
return this;
}
public boolean isHeader() {
return this.location == Location.HEADER;
}
public boolean isUri() {
return this.location == Location.URI;
}
public boolean isStatusCode() {
return this.location == Location.STATUS_CODE;
}
public boolean isQueryString() {
return this.location == Location.QUERY_STRING;
}
public boolean isFlattened() {
return flattened;
}
public void setFlattened(boolean flattened) {
this.flattened = flattened;
}
public ParameterHttpMapping withFlattened(boolean flattened) {
this.flattened = flattened;
return this;
}
public String getUnmarshallLocationName() {
return unmarshallLocationName;
}
public void setUnmarshallLocationName(String unmarshallLocationName) {
this.unmarshallLocationName = unmarshallLocationName;
}
public ParameterHttpMapping withUnmarshallLocationName(String unmarshallLocationName) {
this.unmarshallLocationName = unmarshallLocationName;
return this;
}
public String getMarshallLocationName() {
return marshallLocationName;
}
public void setMarshallLocationName(String marshallLocationName) {
this.marshallLocationName = marshallLocationName;
}
public ParameterHttpMapping withMarshallLocationName(String marshallLocationName) {
this.marshallLocationName = marshallLocationName;
return this;
}
public String getAdditionalUnmarshallingPath() {
return additionalUnmarshallingPath;
}
public void setAdditionalUnmarshallingPath(String additionalUnmarshallingPath) {
this.additionalUnmarshallingPath = additionalUnmarshallingPath;
}
public ParameterHttpMapping withAdditionalUnmarshallingPath(String additionalUnmarshallingPath) {
this.additionalUnmarshallingPath = additionalUnmarshallingPath;
return this;
}
public String getAdditionalMarshallingPath() {
return additionalMarshallingPath;
}
public void setAdditionalMarshallingPath(String additionalMarshallingPath) {
this.additionalMarshallingPath = additionalMarshallingPath;
}
public ParameterHttpMapping withAdditionalMarshallingPath(String additionalMarshallingPath) {
this.additionalMarshallingPath = additionalMarshallingPath;
return this;
}
public boolean isGreedy() {
return isGreedy;
}
public ParameterHttpMapping setIsGreedy(boolean greedy) {
isGreedy = greedy;
return this;
}
public ParameterHttpMapping withIsGreedy(boolean greedy) {
setIsGreedy(greedy);
return this;
}
public boolean isRequiresLength() {
return requiresLength;
}
public void setRequiresLength(boolean requiresLength) {
this.requiresLength = requiresLength;
}
public ParameterHttpMapping withRequiresLength(boolean requiresLength) {
setRequiresLength(requiresLength);
return this;
}
public MarshallLocation getMarshallLocation() {
if (location == null) {
return MarshallLocation.PAYLOAD;
}
switch (location) {
default:
return MarshallLocation.PAYLOAD;
case STATUS_CODE:
return MarshallLocation.STATUS_CODE;
case HEADER:
case HEADERS:
return MarshallLocation.HEADER;
case QUERY_STRING:
return MarshallLocation.QUERY_PARAM;
case URI:
return isGreedy ? MarshallLocation.GREEDY_PATH : MarshallLocation.PATH;
}
}
}
| 3,854 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/intermediate/DocumentationModel.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.intermediate;
import static software.amazon.awssdk.codegen.internal.DocumentationUtils.escapeIllegalCharacters;
public class DocumentationModel {
protected String documentation;
public String getDocumentation() {
return documentation;
}
public void setDocumentation(String documentation) {
this.documentation = escapeIllegalCharacters(documentation);
}
}
| 3,855 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/intermediate | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/intermediate/customization/ShapeCustomizationInfo.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.intermediate.customization;
import com.fasterxml.jackson.annotation.JsonIgnore;
public class ShapeCustomizationInfo {
private ArtificialResultWrapper artificialResultWrapper;
private boolean skipGeneratingModelClass;
private boolean skipGeneratingMarshaller;
private boolean skipGeneratingUnmarshaller;
private int staxTargetDepthOffset;
private boolean hasStaxTargetDepthOffset = false;
public ArtificialResultWrapper getArtificialResultWrapper() {
return artificialResultWrapper;
}
public void setArtificialResultWrapper(
ArtificialResultWrapper artificialResultWrapper) {
this.artificialResultWrapper = artificialResultWrapper;
}
public boolean isSkipGeneratingModelClass() {
return skipGeneratingModelClass;
}
public void setSkipGeneratingModelClass(boolean skipGeneratingModelClass) {
this.skipGeneratingModelClass = skipGeneratingModelClass;
}
public boolean isSkipGeneratingMarshaller() {
return skipGeneratingMarshaller;
}
public void setSkipGeneratingMarshaller(boolean skipGeneratingMarshaller) {
this.skipGeneratingMarshaller = skipGeneratingMarshaller;
}
public boolean isSkipGeneratingUnmarshaller() {
return skipGeneratingUnmarshaller;
}
public void setSkipGeneratingUnmarshaller(boolean skipGeneratingUnmarshaller) {
this.skipGeneratingUnmarshaller = skipGeneratingUnmarshaller;
}
public Integer getStaxTargetDepthOffset() {
return staxTargetDepthOffset;
}
public void setStaxTargetDepthOffset(int staxTargetDepthOffset) {
hasStaxTargetDepthOffset = true;
this.staxTargetDepthOffset = staxTargetDepthOffset;
}
@JsonIgnore
public boolean hasStaxTargetDepthOffset() {
return hasStaxTargetDepthOffset;
}
}
| 3,856 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/intermediate | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/model/intermediate/customization/ArtificialResultWrapper.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.model.intermediate.customization;
public class ArtificialResultWrapper {
private String wrappedMemberName;
private String wrappedMemberSimpleType;
public String getWrappedMemberName() {
return wrappedMemberName;
}
public void setWrappedMemberName(String wrappedMemberName) {
this.wrappedMemberName = wrappedMemberName;
}
public String getWrappedMemberSimpleType() {
return wrappedMemberSimpleType;
}
public void setWrappedMemberSimpleType(String wrappedMemberSimpleType) {
this.wrappedMemberSimpleType = wrappedMemberSimpleType;
}
}
| 3,857 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath/component/NotExpression.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.jmespath.component;
/**
* A not-expression negates the result of an expression. If the expression results in a truth-like value, a
* not-expression will change this value to false. If the expression results in a false-like value, a not-expression will
* change this value to true.
*
* https://jmespath.org/specification.html#not-expressions
*/
public class NotExpression {
private final Expression expression;
public NotExpression(Expression expression) {
this.expression = expression;
}
public Expression expression() {
return expression;
}
}
| 3,858 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath/component/BracketSpecifierWithoutContents.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.jmespath.component;
/**
* A {@link BracketSpecifier} without content, i.e. [].
*/
public class BracketSpecifierWithoutContents {
}
| 3,859 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath/component/ParenExpression.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.jmespath.component;
/**
* A paren-expression allows a user to override the precedence order of an expression, e.g. (a || b) && c.
*
* https://jmespath.org/specification.html#paren-expressions
*/
public class ParenExpression {
private final Expression expression;
public ParenExpression(Expression expression) {
this.expression = expression;
}
public Expression expression() {
return expression;
}
}
| 3,860 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath/component/WildcardExpression.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.jmespath.component;
/**
* A wildcard expression is a expression of either * or [*]. A wildcard expression can return multiple elements, and the
* remaining expressions are evaluated against each returned element from a wildcard expression. The [*] syntax applies to a
* list type and the * syntax applies to a hash type.
*
* https://jmespath.org/specification.html#wildcard-expressions
*/
public class WildcardExpression {
}
| 3,861 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath/component/BracketSpecifier.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.jmespath.component;
import software.amazon.awssdk.codegen.jmespath.parser.JmesPathVisitor;
import software.amazon.awssdk.utils.Validate;
/**
* A bracket specifier within an {@link IndexExpression}. Either:
* <ul>
* <li>With content, as in [1], [*] or [1:2:3]: {@link BracketSpecifierWithContents}</li>
* <li>Without content, as in []: {@link BracketSpecifierWithContents}</li>
* <li>With question-mark content, as in [?foo]: {@link BracketSpecifierWithQuestionMark}</li>
* </ul>
*/
public class BracketSpecifier {
private BracketSpecifierWithContents bracketSpecifierWithContents;
private BracketSpecifierWithoutContents bracketSpecifierWithoutContents;
private BracketSpecifierWithQuestionMark bracketSpecifierWithQuestionMark;
public static BracketSpecifier withContents(BracketSpecifierWithContents bracketSpecifierWithContents) {
Validate.notNull(bracketSpecifierWithContents, "bracketSpecifierWithContents");
BracketSpecifier result = new BracketSpecifier();
result.bracketSpecifierWithContents = bracketSpecifierWithContents;
return result;
}
public static BracketSpecifier withNumberContents(int numberContents) {
return withContents(BracketSpecifierWithContents.number(numberContents));
}
public static BracketSpecifier withSliceExpressionContents(SliceExpression sliceExpression) {
return withContents(BracketSpecifierWithContents.sliceExpression(sliceExpression));
}
public static BracketSpecifier withWildcardExpressionContents(WildcardExpression wildcardExpression) {
return withContents(BracketSpecifierWithContents.wildcardExpression(wildcardExpression));
}
public static BracketSpecifier withoutContents() {
BracketSpecifier result = new BracketSpecifier();
result.bracketSpecifierWithoutContents = new BracketSpecifierWithoutContents();
return result;
}
public static BracketSpecifier withQuestionMark(BracketSpecifierWithQuestionMark bracketSpecifierWithQuestionMark) {
Validate.notNull(bracketSpecifierWithQuestionMark, "bracketSpecifierWithQuestionMark");
BracketSpecifier result = new BracketSpecifier();
result.bracketSpecifierWithQuestionMark = bracketSpecifierWithQuestionMark;
return result;
}
public boolean isBracketSpecifierWithContents() {
return bracketSpecifierWithContents != null;
}
public boolean isBracketSpecifierWithoutContents() {
return bracketSpecifierWithoutContents != null;
}
public boolean isBracketSpecifierWithQuestionMark() {
return bracketSpecifierWithQuestionMark != null;
}
public BracketSpecifierWithContents asBracketSpecifierWithContents() {
Validate.validState(isBracketSpecifierWithContents(), "Not a BracketSpecifierWithContents");
return bracketSpecifierWithContents;
}
public BracketSpecifierWithoutContents asBracketSpecifierWithoutContents() {
Validate.validState(isBracketSpecifierWithoutContents(), "Not a BracketSpecifierWithoutContents");
return bracketSpecifierWithoutContents;
}
public BracketSpecifierWithQuestionMark asBracketSpecifierWithQuestionMark() {
Validate.validState(isBracketSpecifierWithQuestionMark(), "Not a BracketSpecifierWithQuestionMark");
return bracketSpecifierWithQuestionMark;
}
public void visit(JmesPathVisitor visitor) {
if (isBracketSpecifierWithContents()) {
visitor.visitBracketSpecifierWithContents(asBracketSpecifierWithContents());
} else if (isBracketSpecifierWithoutContents()) {
visitor.visitBracketSpecifierWithoutContents(asBracketSpecifierWithoutContents());
} else if (isBracketSpecifierWithQuestionMark()) {
visitor.visitBracketSpecifierWithQuestionMark(asBracketSpecifierWithQuestionMark());
} else {
throw new IllegalStateException();
}
}
}
| 3,862 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath/component/SubExpression.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.jmespath.component;
/**
* A subexpression is a combination of two expressions separated by the ‘.’ char. A subexpression is evaluated as follows:
* <ol>
* <li>Evaluate the expression on the left with the original JSON document.</li>
* <li>Evaluate the expression on the right with the result of the left expression evaluation.</li>
* </ol>
*
* https://jmespath.org/specification.html#subexpressions
*/
public class SubExpression {
private final Expression leftExpression;
private final SubExpressionRight rightSide;
public SubExpression(Expression leftExpression, SubExpressionRight rightSide) {
this.leftExpression = leftExpression;
this.rightSide = rightSide;
}
public Expression leftExpression() {
return leftExpression;
}
public SubExpressionRight rightSubExpression() {
return rightSide;
}
}
| 3,863 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath/component/ComparatorExpression.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.jmespath.component;
/**
* A comparator expression is two expressions separated by a {@link Comparator}.
*
* Examples:
* <ul>
* <li>Foo == Bar</li>
* <li>Bar <= `101</li>
* </ul>
*/
public class ComparatorExpression {
private final Expression leftExpression;
private final Comparator comparator;
private final Expression rightExpression;
public ComparatorExpression(Expression leftExpression, Comparator comparator, Expression rightExpression) {
this.leftExpression = leftExpression;
this.comparator = comparator;
this.rightExpression = rightExpression;
}
public Expression leftExpression() {
return leftExpression;
}
public Comparator comparator() {
return comparator;
}
public Expression rightExpression() {
return rightExpression;
}
}
| 3,864 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath/component/MultiSelectList.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.jmespath.component;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
/**
* A multiselect expression is used to extract a subset of elements from a JSON hash. Each expression in the multi-select-list
* will be evaluated against the JSON document. Each returned element will be the result of evaluating the expression.
*
* https://jmespath.org/specification.html#multiselect-list
*/
public class MultiSelectList {
private final List<Expression> expressions;
public MultiSelectList(Expression... expressions) {
this.expressions = Arrays.asList(expressions);
}
public MultiSelectList(Collection<Expression> expressions) {
this.expressions = new ArrayList<>(expressions);
}
public List<Expression> expressions() {
return Collections.unmodifiableList(expressions);
}
}
| 3,865 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath/component/MultiSelectHash.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.jmespath.component;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
/**
* A multi-select-hash expression is similar to a multi-select-list {@link MultiSelectList} expression, except that a hash is
* created instead of a list. A multi-select-hash expression also requires key names to be provided, as specified in the
* keyval-expr ({@link KeyValueExpression} rule.
*
* https://jmespath.org/specification.html#multiselect-hash
*/
public class MultiSelectHash {
private final List<KeyValueExpression> expressions;
public MultiSelectHash(KeyValueExpression... expressions) {
this.expressions = Arrays.asList(expressions);
}
public MultiSelectHash(Collection<KeyValueExpression> expressions) {
this.expressions = new ArrayList<>(expressions);
}
public List<KeyValueExpression> keyValueExpressions() {
return Collections.unmodifiableList(expressions);
}
}
| 3,866 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath/component/FunctionExpression.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.jmespath.component;
import java.util.List;
/**
* A function allowing users to easily transform and filter data in JMESPath expressions.
*
* https://jmespath.org/specification.html#functions-expressions
*/
public class FunctionExpression {
private final String function;
private final List<FunctionArg> functionArgs;
public FunctionExpression(String function, List<FunctionArg> functionArgs) {
this.function = function;
this.functionArgs = functionArgs;
}
public String function() {
return function;
}
public List<FunctionArg> functionArgs() {
return functionArgs;
}
}
| 3,867 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath/component/CurrentNode.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.jmespath.component;
/**
* The current-node expression '@': https://jmespath.org/specification.html#current-node
*/
public class CurrentNode {
}
| 3,868 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath/component/Expression.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.jmespath.component;
import software.amazon.awssdk.codegen.jmespath.parser.JmesPathVisitor;
import software.amazon.awssdk.utils.Validate;
/**
* An expression is any statement that can be executed in isolation from other parts of a JMESPath string. Every valid JMESPath
* string is an expression, usually made up of other expressions.
*
* Examples: https://jmespath.org/examples.html
*/
public class Expression {
private SubExpression subExpression;
private IndexExpression indexExpression;
private ComparatorExpression comparatorExpression;
private OrExpression orExpression;
private String identifier;
private AndExpression andExpression;
private NotExpression notExpression;
private ParenExpression parenExpression;
private WildcardExpression wildcardExpression;
private MultiSelectList multiSelectList;
private MultiSelectHash multiSelectHash;
private Literal literal;
private FunctionExpression functionExpression;
private PipeExpression pipeExpression;
private String rawString;
private CurrentNode currentNode;
public static Expression subExpression(SubExpression subExpression) {
Validate.notNull(subExpression, "subExpression");
Expression expression = new Expression();
expression.subExpression = subExpression;
return expression;
}
public static Expression indexExpression(IndexExpression indexExpression) {
Validate.notNull(indexExpression, "indexExpression");
Expression expression = new Expression();
expression.indexExpression = indexExpression;
return expression;
}
public static Expression comparatorExpression(ComparatorExpression comparatorExpression) {
Validate.notNull(comparatorExpression, "comparatorExpression");
Expression expression = new Expression();
expression.comparatorExpression = comparatorExpression;
return expression;
}
public static Expression orExpression(OrExpression orExpression) {
Validate.notNull(orExpression, "orExpression");
Expression expression = new Expression();
expression.orExpression = orExpression;
return expression;
}
public static Expression identifier(String identifier) {
Validate.notNull(identifier, "identifier");
Expression expression = new Expression();
expression.identifier = identifier;
return expression;
}
public static Expression andExpression(AndExpression andExpression) {
Validate.notNull(andExpression, "andExpression");
Expression expression = new Expression();
expression.andExpression = andExpression;
return expression;
}
public static Expression notExpression(NotExpression notExpression) {
Validate.notNull(notExpression, "notExpression");
Expression expression = new Expression();
expression.notExpression = notExpression;
return expression;
}
public static Expression parenExpression(ParenExpression parenExpression) {
Validate.notNull(parenExpression, "parenExpression");
Expression expression = new Expression();
expression.parenExpression = parenExpression;
return expression;
}
public static Expression wildcardExpression(WildcardExpression wildcardExpression) {
Validate.notNull(wildcardExpression, "wildcardExpression");
Expression expression = new Expression();
expression.wildcardExpression = wildcardExpression;
return expression;
}
public static Expression multiSelectList(MultiSelectList multiSelectList) {
Validate.notNull(multiSelectList, "multiSelectList");
Expression expression = new Expression();
expression.multiSelectList = multiSelectList;
return expression;
}
public static Expression multiSelectHash(MultiSelectHash multiSelectHash) {
Validate.notNull(multiSelectHash, "multiSelectHash");
Expression expression = new Expression();
expression.multiSelectHash = multiSelectHash;
return expression;
}
public static Expression literal(Literal literal) {
Validate.notNull(literal, "literal");
Expression expression = new Expression();
expression.literal = literal;
return expression;
}
public static Expression functionExpression(FunctionExpression functionExpression) {
Validate.notNull(functionExpression, "functionExpression");
Expression expression = new Expression();
expression.functionExpression = functionExpression;
return expression;
}
public static Expression pipeExpression(PipeExpression pipeExpression) {
Validate.notNull(pipeExpression, "pipeExpression");
Expression expression = new Expression();
expression.pipeExpression = pipeExpression;
return expression;
}
public static Expression rawString(String rawString) {
Validate.notNull(rawString, "rawString");
Expression expression = new Expression();
expression.rawString = rawString;
return expression;
}
public static Expression currentNode(CurrentNode currentNode) {
Validate.notNull(currentNode, "currentNode");
Expression expression = new Expression();
expression.currentNode = currentNode;
return expression;
}
public boolean isSubExpression() {
return subExpression != null;
}
public boolean isIndexExpression() {
return indexExpression != null;
}
public boolean isComparatorExpression() {
return comparatorExpression != null;
}
public boolean isOrExpression() {
return orExpression != null;
}
public boolean isIdentifier() {
return identifier != null;
}
public boolean isAndExpression() {
return andExpression != null;
}
public boolean isNotExpression() {
return notExpression != null;
}
public boolean isParenExpression() {
return parenExpression != null;
}
public boolean isWildcardExpression() {
return wildcardExpression != null;
}
public boolean isMultiSelectList() {
return multiSelectList != null;
}
public boolean isMultiSelectHash() {
return multiSelectHash != null;
}
public boolean isLiteral() {
return literal != null;
}
public boolean isFunctionExpression() {
return functionExpression != null;
}
public boolean isPipeExpression() {
return pipeExpression != null;
}
public boolean isRawString() {
return rawString != null;
}
public boolean isCurrentNode() {
return currentNode != null;
}
public SubExpression asSubExpression() {
Validate.validState(isSubExpression(), "Not a SubExpression");
return subExpression;
}
public IndexExpression asIndexExpression() {
Validate.validState(isIndexExpression(), "Not a IndexExpression");
return indexExpression;
}
public ComparatorExpression asComparatorExpression() {
Validate.validState(isComparatorExpression(), "Not a ComparatorExpression");
return comparatorExpression;
}
public OrExpression asOrExpression() {
Validate.validState(isOrExpression(), "Not a OrExpression");
return orExpression;
}
public String asIdentifier() {
Validate.validState(isIdentifier(), "Not a Identifier");
return identifier;
}
public AndExpression asAndExpression() {
Validate.validState(isAndExpression(), "Not a AndExpression");
return andExpression;
}
public NotExpression asNotExpression() {
Validate.validState(isNotExpression(), "Not a NotExpression");
return notExpression;
}
public ParenExpression asParenExpression() {
Validate.validState(isParenExpression(), "Not a ParenExpression");
return parenExpression;
}
public WildcardExpression asWildcardExpression() {
Validate.validState(isWildcardExpression(), "Not a WildcardExpression");
return wildcardExpression;
}
public MultiSelectList asMultiSelectList() {
Validate.validState(isMultiSelectList(), "Not a MultiSelectList");
return multiSelectList;
}
public MultiSelectHash asMultiSelectHash() {
Validate.validState(isMultiSelectHash(), "Not a MultiSelectHash");
return multiSelectHash;
}
public Literal asLiteral() {
Validate.validState(isLiteral(), "Not a Literal");
return literal;
}
public FunctionExpression asFunctionExpression() {
Validate.validState(isFunctionExpression(), "Not a FunctionExpression");
return functionExpression;
}
public PipeExpression asPipeExpression() {
Validate.validState(isPipeExpression(), "Not a PipeExpression");
return pipeExpression;
}
public String asRawString() {
Validate.validState(isRawString(), "Not a RawString");
return rawString;
}
public CurrentNode asCurrentNode() {
Validate.validState(isCurrentNode(), "Not a CurrentNode");
return currentNode;
}
public void visit(JmesPathVisitor visitor) {
if (isSubExpression()) {
visitor.visitSubExpression(asSubExpression());
} else if (isIndexExpression()) {
visitor.visitIndexExpression(asIndexExpression());
} else if (isComparatorExpression()) {
visitor.visitComparatorExpression(asComparatorExpression());
} else if (isOrExpression()) {
visitor.visitOrExpression(asOrExpression());
} else if (isIdentifier()) {
visitor.visitIdentifier(asIdentifier());
} else if (isAndExpression()) {
visitor.visitAndExpression(asAndExpression());
} else if (isNotExpression()) {
visitor.visitNotExpression(asNotExpression());
} else if (isParenExpression()) {
visitor.visitParenExpression(asParenExpression());
} else if (isWildcardExpression()) {
visitor.visitWildcardExpression(asWildcardExpression());
} else if (isMultiSelectList()) {
visitor.visitMultiSelectList(asMultiSelectList());
} else if (isMultiSelectHash()) {
visitor.visitMultiSelectHash(asMultiSelectHash());
} else if (isLiteral()) {
visitor.visitLiteral(asLiteral());
} else if (isFunctionExpression()) {
visitor.visitFunctionExpression(asFunctionExpression());
} else if (isPipeExpression()) {
visitor.visitPipeExpression(asPipeExpression());
} else if (isRawString()) {
visitor.visitRawString(asRawString());
} else if (isCurrentNode()) {
visitor.visitCurrentNode(asCurrentNode());
} else {
throw new IllegalStateException();
}
}
}
| 3,869 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath/component/OrExpression.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.jmespath.component;
/**
* An or expression will evaluate to either the left expression or the right expression. If the evaluation of the left
* expression is not false it is used as the return value. If the evaluation of the right expression is not false it is
* used as the return value. If neither the left or right expression are non-null, then a value of null is returned.
*
* Examples:
* <ul>
* <li>True || False</li>
* <li>Number || EmptyList</li>
* <li>a == `1` || b == `2`</li>
* </ul>
*
* https://jmespath.org/specification.html#or-expressions
*/
public class OrExpression {
private final Expression leftExpression;
private final Expression rightExpression;
public OrExpression(Expression leftExpression, Expression rightExpression) {
this.leftExpression = leftExpression;
this.rightExpression = rightExpression;
}
public Expression leftExpression() {
return leftExpression;
}
public Expression rightExpression() {
return rightExpression;
}
}
| 3,870 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath/component/BracketSpecifierWithQuestionMark.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.jmespath.component;
/**
* A {@link BracketSpecifier} with a question-mark expression, as in [?Foo].
*/
public class BracketSpecifierWithQuestionMark {
private final Expression expression;
public BracketSpecifierWithQuestionMark(Expression expression) {
this.expression = expression;
}
public Expression expression() {
return expression;
}
}
| 3,871 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath/component/KeyValueExpression.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.jmespath.component;
/**
* A key-value expression within a {@link MultiSelectHash}.
*/
public class KeyValueExpression {
private final String key;
private final Expression value;
public KeyValueExpression(String key, Expression value) {
this.key = key;
this.value = value;
}
public String key() {
return key;
}
public Expression value() {
return value;
}
}
| 3,872 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath/component/IndexExpression.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.jmespath.component;
import java.util.Optional;
import software.amazon.awssdk.utils.Validate;
/**
* An index expression is used to access elements in a list. Indexing is 0 based, the index of 0 refers to the first element
* of the list. A negative number is a valid index. A negative number indicates that indexing is relative to the end of the
* list.
*
* https://jmespath.org/specification.html#index-expressions
*/
public class IndexExpression {
private final Expression expression;
private final BracketSpecifier bracketSpecifier;
private IndexExpression(Expression expression, BracketSpecifier bracketSpecifier) {
this.expression = expression;
this.bracketSpecifier = bracketSpecifier;
}
public static IndexExpression indexExpression(Expression expression, BracketSpecifier bracketSpecifier) {
Validate.notNull(bracketSpecifier, "bracketSpecifier");
return new IndexExpression(expression, bracketSpecifier);
}
public Optional<Expression> expression() {
return Optional.ofNullable(expression);
}
public BracketSpecifier bracketSpecifier() {
return bracketSpecifier;
}
}
| 3,873 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath/component/Literal.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.jmespath.component;
import com.fasterxml.jackson.jr.stree.JrsValue;
/**
* A literal JSON value embedded in a JMESPath expression.
*
* https://jmespath.org/specification.html#literal-expressions
*/
public class Literal {
private final JrsValue jsonValue;
public Literal(JrsValue jsonValue) {
this.jsonValue = jsonValue;
}
public JrsValue jsonValue() {
return jsonValue;
}
}
| 3,874 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath/component/FunctionArg.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.jmespath.component;
import software.amazon.awssdk.codegen.jmespath.parser.JmesPathVisitor;
import software.amazon.awssdk.utils.Validate;
/**
* An argument to a {@link FunctionExpression}. Either a {@link Expression} that is evaluated and passed to the function or a
* {@link ExpressionType} that is passed to the function as-is and is evaluated by the function.
*/
public class FunctionArg {
private Expression expression;
private ExpressionType expressionType;
private FunctionArg() {
}
public static FunctionArg expression(Expression expression) {
Validate.notNull(expression, "expression");
FunctionArg result = new FunctionArg();
result.expression = expression;
return result;
}
public static FunctionArg expressionType(ExpressionType expressionType) {
Validate.notNull(expressionType, "expressionType");
FunctionArg result = new FunctionArg();
result.expressionType = expressionType;
return result;
}
public boolean isExpression() {
return expression != null;
}
public boolean isExpressionType() {
return expressionType != null;
}
public Expression asExpression() {
Validate.validState(isExpression(), "Not a Expression");
return expression;
}
public ExpressionType asExpressionType() {
Validate.validState(isExpressionType(), "Not a ExpressionType");
return expressionType;
}
public void visit(JmesPathVisitor visitor) {
if (isExpression()) {
visitor.visitExpression(asExpression());
} else if (isExpressionType()) {
visitor.visitExpressionType(asExpressionType());
} else {
throw new IllegalStateException();
}
}
}
| 3,875 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath/component/AndExpression.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.jmespath.component;
/**
* An and expression will evaluate to either the left expression or the right expression. If the expression on the left hand side
* is a truth-like value, then the value on the right hand side is returned. Otherwise the result of the expression on the left
* hand side is returned.
*
* Examples:
* <ul>
* <li>True && False</li>
* <li>Number && EmptyList</li>
* <li>a == `1` && b == `2`</li>
* </ul>
*
* https://jmespath.org/specification.html#and-expressions
*/
public class AndExpression {
private final Expression leftExpression;
private final Expression rightExpression;
public AndExpression(Expression leftExpression, Expression rightExpression) {
this.leftExpression = leftExpression;
this.rightExpression = rightExpression;
}
public Expression leftExpression() {
return leftExpression;
}
public Expression rightExpression() {
return rightExpression;
}
}
| 3,876 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath/component/SubExpressionRight.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.jmespath.component;
import software.amazon.awssdk.codegen.jmespath.parser.JmesPathVisitor;
import software.amazon.awssdk.utils.Validate;
/**
* The right side of a {@link SubExpression}.
*/
public class SubExpressionRight {
private String identifier;
private MultiSelectList multiSelectList;
private MultiSelectHash multiSelectHash;
private FunctionExpression functionExpression;
private WildcardExpression wildcardExpression;
public static SubExpressionRight identifier(String identifier) {
Validate.notNull(identifier, "identifier");
SubExpressionRight result = new SubExpressionRight();
result.identifier = identifier;
return result;
}
public static SubExpressionRight multiSelectList(MultiSelectList multiSelectList) {
Validate.notNull(multiSelectList, "multiSelectList");
SubExpressionRight result = new SubExpressionRight();
result.multiSelectList = multiSelectList;
return result;
}
public static SubExpressionRight multiSelectHash(MultiSelectHash multiSelectHash) {
Validate.notNull(multiSelectHash, "multiSelectHash");
SubExpressionRight result = new SubExpressionRight();
result.multiSelectHash = multiSelectHash;
return result;
}
public static SubExpressionRight functionExpression(FunctionExpression functionExpression) {
Validate.notNull(functionExpression, "functionExpression");
SubExpressionRight result = new SubExpressionRight();
result.functionExpression = functionExpression;
return result;
}
public static SubExpressionRight wildcardExpression(WildcardExpression wildcardExpression) {
Validate.notNull(wildcardExpression, "wildcardExpression");
SubExpressionRight result = new SubExpressionRight();
result.wildcardExpression = wildcardExpression;
return result;
}
public boolean isIdentifier() {
return identifier != null;
}
public boolean isMultiSelectList() {
return multiSelectList != null;
}
public boolean isMultiSelectHash() {
return multiSelectHash != null;
}
public boolean isFunctionExpression() {
return functionExpression != null;
}
public boolean isWildcardExpression() {
return wildcardExpression != null;
}
public String asIdentifier() {
Validate.validState(isIdentifier(), "Not an Identifier");
return identifier;
}
public MultiSelectList asMultiSelectList() {
Validate.validState(isMultiSelectList(), "Not a MultiSelectList");
return multiSelectList;
}
public MultiSelectHash asMultiSelectHash() {
Validate.validState(isMultiSelectHash(), "Not a MultiSelectHash");
return multiSelectHash;
}
public FunctionExpression asFunctionExpression() {
Validate.validState(isFunctionExpression(), "Not a FunctionExpression");
return functionExpression;
}
public WildcardExpression asWildcardExpression() {
Validate.validState(isWildcardExpression(), "Not a WildcardExpression");
return wildcardExpression;
}
public void visit(JmesPathVisitor visitor) {
if (isIdentifier()) {
visitor.visitIdentifier(asIdentifier());
} else if (isMultiSelectList()) {
visitor.visitMultiSelectList(asMultiSelectList());
} else if (isMultiSelectHash()) {
visitor.visitMultiSelectHash(asMultiSelectHash());
} else if (isFunctionExpression()) {
visitor.visitFunctionExpression(asFunctionExpression());
} else if (isWildcardExpression()) {
visitor.visitWildcardExpression(asWildcardExpression());
} else {
throw new IllegalStateException();
}
}
}
| 3,877 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath/component/BracketSpecifierWithContents.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.jmespath.component;
import software.amazon.awssdk.codegen.jmespath.parser.JmesPathVisitor;
import software.amazon.awssdk.utils.Validate;
/**
* A {@link BracketSpecifier} with some kind of content. Either:
* <ul>
* <li>A number, as in [1]</li>
* <li>A star expression, as in [*]</li>
* <li>A slice expression, as in [1:2:3]</li>
* </ul>
*/
public class BracketSpecifierWithContents {
private Integer number;
private WildcardExpression wildcardExpression;
private SliceExpression sliceExpression;
private BracketSpecifierWithContents() {
}
public static BracketSpecifierWithContents number(Integer number) {
Validate.notNull(number, "number");
BracketSpecifierWithContents result = new BracketSpecifierWithContents();
result.number = number;
return result;
}
public static BracketSpecifierWithContents wildcardExpression(WildcardExpression wildcardExpression) {
Validate.notNull(wildcardExpression, "wildcardExpression");
BracketSpecifierWithContents result = new BracketSpecifierWithContents();
result.wildcardExpression = wildcardExpression;
return result;
}
public static BracketSpecifierWithContents sliceExpression(SliceExpression sliceExpression) {
Validate.notNull(sliceExpression, "sliceExpression");
BracketSpecifierWithContents result = new BracketSpecifierWithContents();
result.sliceExpression = sliceExpression;
return result;
}
public boolean isNumber() {
return number != null;
}
public boolean isWildcardExpression() {
return wildcardExpression != null;
}
public boolean isSliceExpression() {
return sliceExpression != null;
}
public int asNumber() {
Validate.validState(isNumber(), "Not a Number");
return number;
}
public WildcardExpression asWildcardExpression() {
Validate.validState(isWildcardExpression(), "Not a WildcardExpression");
return wildcardExpression;
}
public SliceExpression asSliceExpression() {
Validate.validState(isSliceExpression(), "Not a SliceExpression");
return sliceExpression;
}
public void visit(JmesPathVisitor visitor) {
if (isNumber()) {
visitor.visitNumber(asNumber());
} else if (isWildcardExpression()) {
visitor.visitWildcardExpression(asWildcardExpression());
} else if (isSliceExpression()) {
visitor.visitSliceExpression(asSliceExpression());
} else {
throw new IllegalStateException();
}
}
}
| 3,878 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath/component/PipeExpression.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.jmespath.component;
/**
* A pipe expression combines two expressions, separated by the | character. It is similar to a sub-expression with two
* important distinctions:
*
* <ol>
* <li>Any expression can be used on the right hand side. A sub-expression restricts the type of expression that can be used
* on the right hand side.</li>
* <li>A pipe-expression stops projections on the left hand side from propagating to the right hand side. If the left
* expression creates a projection, it does not apply to the right hand side.</li>
* </ol>
*
* https://jmespath.org/specification.html#pipe-expressions
*/
public class PipeExpression {
private final Expression leftExpression;
private final Expression rightExpression;
public PipeExpression(Expression leftExpression, Expression rightExpression) {
this.leftExpression = leftExpression;
this.rightExpression = rightExpression;
}
public Expression leftExpression() {
return leftExpression;
}
public Expression rightExpression() {
return rightExpression;
}
}
| 3,879 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath/component/Comparator.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.jmespath.component;
/**
* A comparator within a {@link ComparatorExpression}.
*/
public enum Comparator {
LESS_THAN_OR_EQUAL("<="),
EQUAL("=="),
GREATER_THAN_OR_EQUAL(">="),
NOT_EQUAL("!="),
LESS_THAN("<"),
GREATER_THAN(">");
private final String tokenSymbol;
Comparator(String tokenSymbol) {
this.tokenSymbol = tokenSymbol;
}
public String tokenSymbol() {
return tokenSymbol;
}
}
| 3,880 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath/component/SliceExpression.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.jmespath.component;
import java.util.OptionalInt;
/**
* A slice expression allows you to select a contiguous subset of an array. A slice has a start, stop, and step value. The
* general form of a slice is [start:stop:step], but each component is optional and can be omitted.
*
* https://jmespath.org/specification.html#slices
*/
public class SliceExpression {
private final Integer start;
private final Integer stop;
private final Integer step;
public SliceExpression(Integer start, Integer stop, Integer step) {
this.start = start;
this.stop = stop;
this.step = step;
}
public OptionalInt start() {
return toOptional(start);
}
public OptionalInt stop() {
return toOptional(stop);
}
public OptionalInt step() {
return toOptional(step);
}
private OptionalInt toOptional(Integer n) {
return n == null ? OptionalInt.empty() : OptionalInt.of(n);
}
}
| 3,881 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath/component/ExpressionType.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.jmespath.component;
/**
* An expression type is an expression prefixed by "&". These are used within {@link FunctionExpression}s as a lambda to be
* invoked by the JMESPath function where they are needed.
*
* For an example in practice, see the sort_by function: https://jmespath.org/specification.html#func-sort-by
*/
public class ExpressionType {
private final Expression expression;
public ExpressionType(Expression expression) {
this.expression = expression;
}
public Expression expression() {
return expression;
}
}
| 3,882 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath/parser/Parser.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.jmespath.parser;
/**
* A JMESPath parser, for generating a {@link ParseResult} from a string between two provided bounds.
*/
@FunctionalInterface
public interface Parser<T> {
/**
* Parse a JMESPath string between the start position (inclusive) and end position (exclusive).
*/
ParseResult<T> parse(int startPosition, int endPosition);
}
| 3,883 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath/parser/JmesPathParser.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.jmespath.parser;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.OptionalInt;
import java.util.function.BiFunction;
import software.amazon.awssdk.codegen.internal.Jackson;
import software.amazon.awssdk.codegen.jmespath.component.AndExpression;
import software.amazon.awssdk.codegen.jmespath.component.BracketSpecifier;
import software.amazon.awssdk.codegen.jmespath.component.BracketSpecifierWithQuestionMark;
import software.amazon.awssdk.codegen.jmespath.component.Comparator;
import software.amazon.awssdk.codegen.jmespath.component.ComparatorExpression;
import software.amazon.awssdk.codegen.jmespath.component.CurrentNode;
import software.amazon.awssdk.codegen.jmespath.component.Expression;
import software.amazon.awssdk.codegen.jmespath.component.ExpressionType;
import software.amazon.awssdk.codegen.jmespath.component.FunctionArg;
import software.amazon.awssdk.codegen.jmespath.component.FunctionExpression;
import software.amazon.awssdk.codegen.jmespath.component.IndexExpression;
import software.amazon.awssdk.codegen.jmespath.component.KeyValueExpression;
import software.amazon.awssdk.codegen.jmespath.component.Literal;
import software.amazon.awssdk.codegen.jmespath.component.MultiSelectHash;
import software.amazon.awssdk.codegen.jmespath.component.MultiSelectList;
import software.amazon.awssdk.codegen.jmespath.component.NotExpression;
import software.amazon.awssdk.codegen.jmespath.component.OrExpression;
import software.amazon.awssdk.codegen.jmespath.component.ParenExpression;
import software.amazon.awssdk.codegen.jmespath.component.PipeExpression;
import software.amazon.awssdk.codegen.jmespath.component.SliceExpression;
import software.amazon.awssdk.codegen.jmespath.component.SubExpression;
import software.amazon.awssdk.codegen.jmespath.component.SubExpressionRight;
import software.amazon.awssdk.codegen.jmespath.component.WildcardExpression;
import software.amazon.awssdk.codegen.jmespath.parser.util.CompositeParser;
import software.amazon.awssdk.utils.Logger;
/**
* Parses a JMESPath expression string into an {@link Expression}.
*
* This implements the grammar described here: https://jmespath.org/specification.html#grammar
*/
public class JmesPathParser {
private static final Logger log = Logger.loggerFor(JmesPathParser.class);
private final String input;
private JmesPathParser(String input) {
this.input = input;
}
/**
* Parses a JMESPath expression string into a {@link Expression}.
*/
public static Expression parse(String jmesPathString) {
return new JmesPathParser(jmesPathString).parse();
}
private Expression parse() {
ParseResult<Expression> expression = parseExpression(0, input.length());
if (!expression.hasResult()) {
throw new IllegalArgumentException("Failed to parse expression.");
}
return expression.result();
}
/**
* expression = sub-expression / index-expression / comparator-expression
* expression =/ or-expression / identifier
* expression =/ and-expression / not-expression / paren-expression
* expression =/ "*" / multi-select-list / multi-select-hash / literal
* expression =/ function-expression / pipe-expression / raw-string
* expression =/ current-node
*/
private ParseResult<Expression> parseExpression(int startPosition, int endPosition) {
startPosition = trimLeftWhitespace(startPosition, endPosition);
endPosition = trimRightWhitespace(startPosition, endPosition);
if (startPosition < 0 || endPosition > input.length() + 1) {
return ParseResult.error();
}
return CompositeParser.firstTry(this::parseSubExpression, Expression::subExpression)
.thenTry(this::parseIndexExpression, Expression::indexExpression)
.thenTry(this::parseNotExpression, Expression::notExpression)
.thenTry(this::parseAndExpression, Expression::andExpression)
.thenTry(this::parseOrExpression, Expression::orExpression)
.thenTry(this::parseComparatorExpression, Expression::comparatorExpression)
.thenTry(this::parsePipeExpression, Expression::pipeExpression)
.thenTry(this::parseIdentifier, Expression::identifier)
.thenTry(this::parseParenExpression, Expression::parenExpression)
.thenTry(this::parseWildcardExpression, Expression::wildcardExpression)
.thenTry(this::parseMultiSelectList, Expression::multiSelectList)
.thenTry(this::parseMultiSelectHash, Expression::multiSelectHash)
.thenTry(this::parseLiteral, Expression::literal)
.thenTry(this::parseFunctionExpression, Expression::functionExpression)
.thenTry(this::parseRawString, Expression::rawString)
.thenTry(this::parseCurrentNode, Expression::currentNode)
.parse(startPosition, endPosition);
}
/**
* sub-expression = expression "." ( identifier /
* multi-select-list /
* multi-select-hash /
* function-expression /
* "*" )
*/
private ParseResult<SubExpression> parseSubExpression(int startPosition, int endPosition) {
startPosition = trimLeftWhitespace(startPosition, endPosition);
endPosition = trimRightWhitespace(startPosition, endPosition);
List<Integer> dotPositions = findCharacters(startPosition + 1, endPosition - 1, ".");
for (Integer dotPosition : dotPositions) {
ParseResult<Expression> leftSide = parseExpression(startPosition, dotPosition);
if (!leftSide.hasResult()) {
continue;
}
ParseResult<SubExpressionRight> rightSide =
CompositeParser.firstTry(this::parseIdentifier, SubExpressionRight::identifier)
.thenTry(this::parseMultiSelectList, SubExpressionRight::multiSelectList)
.thenTry(this::parseMultiSelectHash, SubExpressionRight::multiSelectHash)
.thenTry(this::parseFunctionExpression, SubExpressionRight::functionExpression)
.thenTry(this::parseWildcardExpression, SubExpressionRight::wildcardExpression)
.parse(dotPosition + 1, endPosition);
if (!rightSide.hasResult()) {
continue;
}
return ParseResult.success(new SubExpression(leftSide.result(), rightSide.result()));
}
logError("sub-expression", "Invalid sub-expression", startPosition);
return ParseResult.error();
}
/**
* pipe-expression = expression "|" expression
*/
private ParseResult<PipeExpression> parsePipeExpression(int startPosition, int endPosition) {
return parseBinaryExpression(startPosition, endPosition, "|", PipeExpression::new);
}
/**
* or-expression = expression "||" expression
*/
private ParseResult<OrExpression> parseOrExpression(int startPosition, int endPosition) {
return parseBinaryExpression(startPosition, endPosition, "||", OrExpression::new);
}
/**
* and-expression = expression "&&" expression
*/
private ParseResult<AndExpression> parseAndExpression(int startPosition, int endPosition) {
return parseBinaryExpression(startPosition, endPosition, "&&", AndExpression::new);
}
private <T> ParseResult<T> parseBinaryExpression(int startPosition, int endPosition, String delimiter,
BiFunction<Expression, Expression, T> constructor) {
startPosition = trimLeftWhitespace(startPosition, endPosition);
endPosition = trimRightWhitespace(startPosition, endPosition);
List<Integer> delimiterPositions = findCharacters(startPosition + 1, endPosition - 1, delimiter);
for (Integer delimiterPosition : delimiterPositions) {
ParseResult<Expression> leftSide = parseExpression(startPosition, delimiterPosition);
if (!leftSide.hasResult()) {
continue;
}
ParseResult<Expression> rightSide = parseExpression(delimiterPosition + delimiter.length(), endPosition);
if (!rightSide.hasResult()) {
continue;
}
return ParseResult.success(constructor.apply(leftSide.result(), rightSide.result()));
}
logError("binary-expression", "Invalid binary-expression", startPosition);
return ParseResult.error();
}
/**
* not-expression = "!" expression
*/
private ParseResult<NotExpression> parseNotExpression(int startPosition, int endPosition) {
startPosition = trimLeftWhitespace(startPosition, endPosition);
endPosition = trimRightWhitespace(startPosition, endPosition);
if (!startsWith(startPosition, '!')) {
logError("not-expression", "Expected '!'", startPosition);
return ParseResult.error();
}
return parseExpression(startPosition + 1, endPosition).mapResult(NotExpression::new);
}
/**
* paren-expression = "(" expression ")"
*/
private ParseResult<ParenExpression> parseParenExpression(int startPosition, int endPosition) {
startPosition = trimLeftWhitespace(startPosition, endPosition);
endPosition = trimRightWhitespace(startPosition, endPosition);
if (!startsAndEndsWith(startPosition, endPosition, '(', ')')) {
logError("paren-expression", "Expected '(' and ')'", startPosition);
return ParseResult.error();
}
return parseExpression(startPosition + 1, endPosition - 1).mapResult(ParenExpression::new);
}
/**
* index-expression = expression bracket-specifier / bracket-specifier
*/
private ParseResult<IndexExpression> parseIndexExpression(int startPosition, int endPosition) {
startPosition = trimLeftWhitespace(startPosition, endPosition);
endPosition = trimRightWhitespace(startPosition, endPosition);
return CompositeParser.firstTry(this::parseIndexExpressionWithLhsExpression)
.thenTry(this::parseBracketSpecifier, b -> IndexExpression.indexExpression(null, b))
.parse(startPosition, endPosition);
}
/**
* expression bracket-specifier
*/
private ParseResult<IndexExpression> parseIndexExpressionWithLhsExpression(int startPosition, int endPosition) {
startPosition = trimLeftWhitespace(startPosition, endPosition);
endPosition = trimRightWhitespace(startPosition, endPosition);
List<Integer> bracketPositions = findCharacters(startPosition + 1, endPosition - 1, "[");
for (Integer bracketPosition : bracketPositions) {
ParseResult<Expression> leftSide = parseExpression(startPosition, bracketPosition);
if (!leftSide.hasResult()) {
continue;
}
ParseResult<BracketSpecifier> rightSide = parseBracketSpecifier(bracketPosition, endPosition);
if (!rightSide.hasResult()) {
continue;
}
return ParseResult.success(IndexExpression.indexExpression(leftSide.result(), rightSide.result()));
}
logError("index-expression with lhs-expression", "Invalid index-expression with lhs-expression", startPosition);
return ParseResult.error();
}
/**
* multi-select-list = "[" ( expression *( "," expression ) ) "]"
*/
private ParseResult<MultiSelectList> parseMultiSelectList(int startPosition, int endPosition) {
return parseMultiSelect(startPosition, endPosition, '[', ']', this::parseExpression)
.mapResult(MultiSelectList::new);
}
/**
* multi-select-hash = "{" ( keyval-expr *( "," keyval-expr ) ) "}"
*/
private ParseResult<MultiSelectHash> parseMultiSelectHash(int startPosition, int endPosition) {
return parseMultiSelect(startPosition, endPosition, '{', '}', this::parseKeyValueExpression)
.mapResult(MultiSelectHash::new);
}
/**
* Parses "startDelimiter" ( entryParserType *( "," entryParserType ) ) "endDelimiter"
* <p>
* Used by {@link #parseMultiSelectHash}, {@link #parseMultiSelectList}.
*/
private <T> ParseResult<List<T>> parseMultiSelect(int startPosition, int endPosition,
char startDelimiter, char endDelimiter,
Parser<T> entryParser) {
startPosition = trimLeftWhitespace(startPosition, endPosition);
endPosition = trimRightWhitespace(startPosition, endPosition);
if (!startsAndEndsWith(startPosition, endPosition, startDelimiter, endDelimiter)) {
logError("multi-select", "Expected '" + startDelimiter + "' and '" + endDelimiter + "'", startPosition);
return ParseResult.error();
}
List<Integer> commaPositions = findCharacters(startPosition + 1, endPosition - 1, ",");
if (commaPositions.isEmpty()) {
return entryParser.parse(startPosition + 1, endPosition - 1).mapResult(Collections::singletonList);
}
List<T> results = new ArrayList<>();
// Find first valid entries before a comma
int startOfSecondEntry = -1;
for (Integer comma : commaPositions) {
ParseResult<T> result = entryParser.parse(startPosition + 1, comma);
if (!result.hasResult()) {
continue;
}
results.add(result.result());
startOfSecondEntry = comma + 1;
}
if (results.size() == 0) {
logError("multi-select", "Invalid value", startPosition + 1);
return ParseResult.error();
}
if (results.size() > 1) {
logError("multi-select", "Ambiguous separation", startPosition);
return ParseResult.error();
}
// Find any subsequent entries
int startPositionAfterComma = startOfSecondEntry;
for (Integer commaPosition : commaPositions) {
if (startPositionAfterComma > commaPosition) {
continue;
}
ParseResult<T> entry = entryParser.parse(startPositionAfterComma, commaPosition);
if (!entry.hasResult()) {
continue;
}
results.add(entry.result());
startPositionAfterComma = commaPosition + 1;
}
ParseResult<T> entry = entryParser.parse(startPositionAfterComma, endPosition - 1);
if (!entry.hasResult()) {
logError("multi-select", "Ambiguous separation", startPosition);
return ParseResult.error();
}
results.add(entry.result());
return ParseResult.success(results);
}
/**
* keyval-expr = identifier ":" expression
*/
private ParseResult<KeyValueExpression> parseKeyValueExpression(int startPosition, int endPosition) {
startPosition = trimLeftWhitespace(startPosition, endPosition);
endPosition = trimRightWhitespace(startPosition, endPosition);
List<Integer> delimiterPositions = findCharacters(startPosition + 1, endPosition - 1, ":");
for (Integer delimiterPosition : delimiterPositions) {
ParseResult<String> identifier = parseIdentifier(startPosition, delimiterPosition);
if (!identifier.hasResult()) {
continue;
}
ParseResult<Expression> expression = parseExpression(delimiterPosition + 1, endPosition);
if (!expression.hasResult()) {
continue;
}
return ParseResult.success(new KeyValueExpression(identifier.result(), expression.result()));
}
logError("keyval-expr", "Invalid keyval-expr", startPosition);
return ParseResult.error();
}
/**
* bracket-specifier = "[" (number / "*" / slice-expression) "]" / "[]"
* bracket-specifier =/ "[?" expression "]"
*/
private ParseResult<BracketSpecifier> parseBracketSpecifier(int startPosition, int endPosition) {
startPosition = trimLeftWhitespace(startPosition, endPosition);
endPosition = trimRightWhitespace(startPosition, endPosition);
if (!startsAndEndsWith(startPosition, endPosition, '[', ']')) {
logError("bracket-specifier", "Expecting '[' and ']'", startPosition);
return ParseResult.error();
}
// "[]"
if (charsInRange(startPosition, endPosition) == 2) {
return ParseResult.success(BracketSpecifier.withoutContents());
}
// "[?" expression "]"
if (input.charAt(startPosition + 1) == '?') {
return parseExpression(startPosition + 2, endPosition - 1)
.mapResult(e -> BracketSpecifier.withQuestionMark(new BracketSpecifierWithQuestionMark(e)));
}
// "[" (number / "*" / slice-expression) "]"
return CompositeParser.firstTry(this::parseNumber, BracketSpecifier::withNumberContents)
.thenTry(this::parseWildcardExpression, BracketSpecifier::withWildcardExpressionContents)
.thenTry(this::parseSliceExpression, BracketSpecifier::withSliceExpressionContents)
.parse(startPosition + 1, endPosition - 1);
}
/**
* comparator-expression = expression comparator expression
*/
private ParseResult<ComparatorExpression> parseComparatorExpression(int startPosition, int endPosition) {
startPosition = trimLeftWhitespace(startPosition, endPosition);
endPosition = trimRightWhitespace(startPosition, endPosition);
for (Comparator comparator : Comparator.values()) {
List<Integer> comparatorPositions = findCharacters(startPosition, endPosition, comparator.tokenSymbol());
for (Integer comparatorPosition : comparatorPositions) {
ParseResult<Expression> lhsExpression = parseExpression(startPosition, comparatorPosition);
if (!lhsExpression.hasResult()) {
continue;
}
ParseResult<Expression> rhsExpression =
parseExpression(comparatorPosition + comparator.tokenSymbol().length(), endPosition);
if (!rhsExpression.hasResult()) {
continue;
}
return ParseResult.success(new ComparatorExpression(lhsExpression.result(),
comparator,
rhsExpression.result()));
}
}
logError("comparator-expression", "Invalid comparator expression", startPosition);
return ParseResult.error();
}
/**
* slice-expression = [number] ":" [number] [ ":" [number] ]
*/
private ParseResult<SliceExpression> parseSliceExpression(int startPosition, int endPosition) {
startPosition = trimLeftWhitespace(startPosition, endPosition);
endPosition = trimRightWhitespace(startPosition, endPosition);
// Find the first colon
int firstColonIndex = input.indexOf(':', startPosition);
if (firstColonIndex < 0 || firstColonIndex >= endPosition) {
logError("slice-expression", "Expected slice expression", startPosition);
return ParseResult.error();
}
// Find the second colon (if it exists)
int maybeSecondColonIndex = input.indexOf(':', firstColonIndex + 1);
OptionalInt secondColonIndex = maybeSecondColonIndex < 0 || maybeSecondColonIndex >= endPosition
? OptionalInt.empty()
: OptionalInt.of(maybeSecondColonIndex);
// Find the first number bounds (if it exists)
int firstNumberStart = startPosition;
int firstNumberEnd = firstColonIndex;
// Find the second number bounds (if it exists)
int secondNumberStart = firstColonIndex + 1;
int secondNumberEnd = secondColonIndex.orElse(endPosition);
// Find the third number bounds (if it exists)
int thirdNumberStart = secondColonIndex.orElse(endPosition) + 1;
int thirdNumberEnd = endPosition;
// Parse the first number (if it exists)
Optional<Integer> firstNumber = Optional.empty();
if (firstNumberStart < firstNumberEnd) {
ParseResult<Integer> firstNumberParse = parseNumber(firstNumberStart, firstNumberEnd);
if (!firstNumberParse.hasResult()) {
return ParseResult.error();
}
firstNumber = Optional.of(firstNumberParse.result());
}
// Parse the second number (if it exists)
Optional<Integer> secondNumber = Optional.empty();
if (secondNumberStart < secondNumberEnd) {
ParseResult<Integer> secondNumberParse = parseNumber(secondNumberStart, secondNumberEnd);
if (!secondNumberParse.hasResult()) {
return ParseResult.error();
}
secondNumber = Optional.of(secondNumberParse.result());
}
// Parse the third number (if it exists)
Optional<Integer> thirdNumber = Optional.empty();
if (thirdNumberStart < thirdNumberEnd) {
ParseResult<Integer> thirdNumberParse = parseNumber(thirdNumberStart, thirdNumberEnd);
if (!thirdNumberParse.hasResult()) {
return ParseResult.error();
}
thirdNumber = Optional.of(thirdNumberParse.result());
}
return ParseResult.success(new SliceExpression(firstNumber.orElse(null),
secondNumber.orElse(null),
thirdNumber.orElse(null)));
}
/**
* function-expression = unquoted-string ( no-args / one-or-more-args )
*/
private ParseResult<FunctionExpression> parseFunctionExpression(int startPosition, int endPosition) {
startPosition = trimLeftWhitespace(startPosition, endPosition);
endPosition = trimRightWhitespace(startPosition, endPosition);
int paramIndex = input.indexOf('(', startPosition);
if (paramIndex <= 0) {
logError("function-expression", "Expected function", startPosition);
return ParseResult.error();
}
ParseResult<String> functionNameParse = parseUnquotedString(startPosition, paramIndex);
if (!functionNameParse.hasResult()) {
logError("function-expression", "Expected valid function name", startPosition);
return ParseResult.error();
}
return CompositeParser.firstTry(this::parseNoArgs)
.thenTry(this::parseOneOrMoreArgs)
.parse(paramIndex, endPosition)
.mapResult(args -> new FunctionExpression(functionNameParse.result(), args));
}
/**
* no-args = "(" ")"
*/
private ParseResult<List<FunctionArg>> parseNoArgs(int startPosition, int endPosition) {
startPosition = trimLeftWhitespace(startPosition, endPosition);
endPosition = trimRightWhitespace(startPosition, endPosition);
if (!startsWith(startPosition, '(')) {
logError("no-args", "Expected '('", startPosition);
return ParseResult.error();
}
int closePosition = trimLeftWhitespace(startPosition + 1, endPosition);
if (input.charAt(closePosition) != ')') {
logError("no-args", "Expected ')'", closePosition);
return ParseResult.error();
}
if (closePosition + 1 != endPosition) {
logError("no-args", "Unexpected character", closePosition + 1);
return ParseResult.error();
}
return ParseResult.success(Collections.emptyList());
}
/**
* one-or-more-args = "(" ( function-arg *( "," function-arg ) ) ")"
*/
private ParseResult<List<FunctionArg>> parseOneOrMoreArgs(int startPosition, int endPosition) {
return parseMultiSelect(startPosition, endPosition, '(', ')', this::parseFunctionArg);
}
/**
* function-arg = expression / expression-type
*/
private ParseResult<FunctionArg> parseFunctionArg(int startPosition, int endPosition) {
return CompositeParser.firstTry(this::parseExpression, FunctionArg::expression)
.thenTry(this::parseExpressionType, FunctionArg::expressionType)
.parse(startPosition, endPosition);
}
/**
* current-node = "@"
*/
private ParseResult<CurrentNode> parseCurrentNode(int startPosition, int endPosition) {
startPosition = trimLeftWhitespace(startPosition, endPosition);
endPosition = trimRightWhitespace(startPosition, endPosition);
return parseExpectedToken("current-node", startPosition, endPosition, '@').mapResult(x -> new CurrentNode());
}
/**
* expression-type = "&" expression
*/
private ParseResult<ExpressionType> parseExpressionType(int startPosition, int endPosition) {
startPosition = trimLeftWhitespace(startPosition, endPosition);
endPosition = trimRightWhitespace(startPosition, endPosition);
if (!startsWith(startPosition, '&')) {
logError("expression-type", "Expected '&'", startPosition);
return ParseResult.error();
}
return parseExpression(startPosition + 1, endPosition).mapResult(ExpressionType::new);
}
/**
* raw-string = "'" *raw-string-char "'"
*/
private ParseResult<String> parseRawString(int startPosition, int endPosition) {
startPosition = trimLeftWhitespace(startPosition, endPosition);
endPosition = trimRightWhitespace(startPosition, endPosition);
if (charsInRange(startPosition, endPosition) < 2) {
logError("raw-string", "Invalid length", startPosition);
return ParseResult.error();
}
if (!startsAndEndsWith(startPosition, endPosition, '\'', '\'')) {
logError("raw-string", "Expected opening and closing \"'\"", startPosition);
return ParseResult.error();
}
if (charsInRange(startPosition, endPosition) == 2) {
return ParseResult.success("");
}
return parseRawStringChars(startPosition + 1, endPosition - 1);
}
/**
* raw-string-char = (%x20-26 / %x28-5B / %x5D-10FFFF) / preserved-escape / raw-string-escape
*/
private ParseResult<String> parseRawStringChars(int startPosition, int endPosition) {
StringBuilder result = new StringBuilder();
for (int i = startPosition; i < endPosition; i++) {
ParseResult<String> rawStringChar = parseLegalRawStringChar(i, i + 1);
if (rawStringChar.hasResult()) {
result.append(rawStringChar.result());
continue;
}
ParseResult<String> preservedEscape = parsePreservedEscape(i, i + 2);
if (preservedEscape.hasResult()) {
result.append(preservedEscape.result());
++i;
continue;
}
ParseResult<String> rawStringEscape = parseRawStringEscape(i, i + 2);
if (rawStringEscape.hasResult()) {
result.append(rawStringEscape.result());
++i;
continue;
}
logError("raw-string", "Unexpected character", i);
return ParseResult.error();
}
return ParseResult.success(result.toString());
}
/**
* %x20-26 / %x28-5B / %x5D-10FFFF
*/
private ParseResult<String> parseLegalRawStringChar(int startPosition, int endPosition) {
if (charsInRange(startPosition, endPosition) != 1) {
logError("raw-string-chars", "Invalid bounds", startPosition);
return ParseResult.error();
}
if (!isLegalRawStringChar(input.charAt(startPosition))) {
logError("raw-string-chars", "Invalid character in sequence", startPosition);
return ParseResult.error();
}
return ParseResult.success(input.substring(startPosition, endPosition));
}
private boolean isLegalRawStringChar(char c) {
return (c >= 0x20 && c <= 0x26) ||
(c >= 0x28 && c <= 0x5B) ||
(c >= 0x5D);
}
/**
* preserved-escape = escape (%x20-26 / %28-5B / %x5D-10FFFF)
*/
private ParseResult<String> parsePreservedEscape(int startPosition, int endPosition) {
if (endPosition > input.length()) {
logError("preserved-escape", "Invalid end position", startPosition);
return ParseResult.error();
}
if (charsInRange(startPosition, endPosition) != 2) {
logError("preserved-escape", "Invalid length", startPosition);
return ParseResult.error();
}
if (!startsWith(startPosition, '\\')) {
logError("preserved-escape", "Expected \\", startPosition);
return ParseResult.error();
}
return parseLegalRawStringChar(startPosition + 1, endPosition).mapResult(v -> "\\" + v);
}
/**
* raw-string-escape = escape ("'" / escape)
*/
private ParseResult<String> parseRawStringEscape(int startPosition, int endPosition) {
if (endPosition > input.length()) {
logError("preserved-escape", "Invalid end position", startPosition);
return ParseResult.error();
}
if (charsInRange(startPosition, endPosition) != 2) {
logError("raw-string-escape", "Invalid length", startPosition);
return ParseResult.error();
}
if (!startsWith(startPosition, '\\')) {
logError("raw-string-escape", "Expected '\\'", startPosition);
return ParseResult.error();
}
if (input.charAt(startPosition + 1) != '\'' && input.charAt(startPosition + 1) != '\\') {
logError("raw-string-escape", "Expected \"'\" or \"\\\"", startPosition);
return ParseResult.error();
}
return ParseResult.success(input.substring(startPosition, endPosition));
}
/**
* literal = "`" json-value "`"
*/
private ParseResult<Literal> parseLiteral(int startPosition, int endPosition) {
startPosition = trimLeftWhitespace(startPosition, endPosition);
endPosition = trimRightWhitespace(startPosition, endPosition);
if (charsInRange(startPosition, endPosition) < 2) {
logError("literal", "Invalid bounds", startPosition);
return ParseResult.error();
}
if (!startsAndEndsWith(startPosition, endPosition, '`', '`')) {
logError("literal", "Expected opening and closing '`'", startPosition);
return ParseResult.error();
}
StringBuilder jsonString = new StringBuilder();
for (int i = startPosition + 1; i < endPosition - 1; i++) {
char character = input.charAt(i);
if (character == '`') {
int lastChar = i - 1;
if (lastChar <= 0) {
logError("literal", "Unexpected '`'", startPosition);
return ParseResult.error();
}
int escapeCount = 0;
for (int j = i - 1; j >= startPosition; j--) {
if (input.charAt(j) == '\\') {
++escapeCount;
} else {
break;
}
}
if (escapeCount % 2 == 0) {
logError("literal", "Unescaped '`'", startPosition);
return ParseResult.error();
}
jsonString.setLength(jsonString.length() - 1); // Remove escape.
jsonString.append('`');
} else {
jsonString.append(character);
}
}
try {
return ParseResult.success(new Literal(Jackson.readJrsValue(jsonString.toString())));
} catch (IOException e) {
logError("literal", "Invalid JSON: " + e.getMessage(), startPosition);
return ParseResult.error();
}
}
/**
* number = ["-"]1*digit
* digit = %x30-39
*/
private ParseResult<Integer> parseNumber(int startPosition, int endPosition) {
startPosition = trimLeftWhitespace(startPosition, endPosition);
endPosition = trimRightWhitespace(startPosition, endPosition);
if (startsWith(startPosition, '-')) {
return parseNonNegativeNumber(startPosition + 1, endPosition).mapResult(i -> -i);
}
return parseNonNegativeNumber(startPosition, endPosition);
}
private ParseResult<Integer> parseNonNegativeNumber(int startPosition, int endPosition) {
startPosition = trimLeftWhitespace(startPosition, endPosition);
endPosition = trimRightWhitespace(startPosition, endPosition);
if (charsInRange(startPosition, endPosition) < 1) {
logError("number", "Expected number", startPosition);
return ParseResult.error();
}
try {
return ParseResult.success(Integer.parseInt(input.substring(startPosition, endPosition)));
} catch (NumberFormatException e) {
logError("number", "Expected number", startPosition);
return ParseResult.error();
}
}
/**
* identifier = unquoted-string / quoted-string
*/
private ParseResult<String> parseIdentifier(int startPosition, int endPosition) {
return CompositeParser.firstTry(this::parseUnquotedString)
.thenTry(this::parseQuotedString)
.parse(startPosition, endPosition);
}
/**
* unquoted-string = (%x41-5A / %x61-7A / %x5F) *( ; A-Za-z_
* %x30-39 / ; 0-9
* %x41-5A / ; A-Z
* %x5F / ; _
* %x61-7A) ; a-z
*/
private ParseResult<String> parseUnquotedString(int startPosition, int endPosition) {
startPosition = trimLeftWhitespace(startPosition, endPosition);
endPosition = trimRightWhitespace(startPosition, endPosition);
if (charsInRange(startPosition, endPosition) < 1) {
logError("unquoted-string", "Invalid unquoted-string", startPosition);
return ParseResult.error();
}
char firstToken = input.charAt(startPosition);
if (!Character.isLetter(firstToken) && firstToken != '_') {
logError("unquoted-string", "Unescaped strings must start with [A-Za-z_]", startPosition);
return ParseResult.error();
}
for (int i = startPosition; i < endPosition; i++) {
char c = input.charAt(i);
if (!Character.isLetterOrDigit(c) && c != '_') {
logError("unquoted-string", "Invalid character in unescaped-string", i);
return ParseResult.error();
}
}
return ParseResult.success(input.substring(startPosition, endPosition));
}
/**
* quoted-string = quote 1*(unescaped-char / escaped-char) quote
* quote = '"'
*/
private ParseResult<String> parseQuotedString(int startPosition, int endPosition) {
startPosition = trimLeftWhitespace(startPosition, endPosition);
endPosition = trimRightWhitespace(startPosition, endPosition);
if (!startsAndEndsWith(startPosition, endPosition, '"', '"')) {
logError("quoted-string", "Expected opening and closing '\"'", startPosition);
return ParseResult.error();
}
int stringStart = startPosition + 1;
int stringEnd = endPosition - 1;
int stringTokenCount = charsInRange(stringStart, stringEnd);
if (stringTokenCount < 1) {
logError("quoted-string", "Invalid quoted-string", startPosition);
return ParseResult.error();
}
StringBuilder result = new StringBuilder();
for (int i = stringStart; i < stringEnd; i++) {
ParseResult<String> unescapedChar = parseUnescapedChar(i, i + 1);
if (unescapedChar.hasResult()) {
result.append(unescapedChar.result());
continue;
}
ParseResult<String> escapedChar = parseEscapedChar(i, i + 2);
if (escapedChar.hasResult()) {
result.append(escapedChar.result());
++i;
continue;
}
ParseResult<String> escapedUnicodeSequence = parseEscapedUnicodeSequence(i, i + 6);
if (escapedUnicodeSequence.hasResult()) {
result.append(escapedUnicodeSequence.result());
i += 5;
continue;
}
if (input.charAt(i) == '\\') {
logError("quoted-string", "Unsupported escape sequence", i);
} else {
logError("quoted-string", "Unexpected character", i);
}
return ParseResult.error();
}
return ParseResult.success(result.toString());
}
/**
* unescaped-char = %x20-21 / %x23-5B / %x5D-10FFFF
*/
private ParseResult<String> parseUnescapedChar(int startPosition, int endPosition) {
for (int i = startPosition; i < endPosition; i++) {
if (!isLegalUnescapedChar(input.charAt(i))) {
logError("unescaped-char", "Invalid character in sequence", startPosition);
return ParseResult.error();
}
}
return ParseResult.success(input.substring(startPosition, endPosition));
}
private boolean isLegalUnescapedChar(char c) {
return (c >= 0x20 && c <= 0x21) ||
(c >= 0x23 && c <= 0x5B) ||
(c >= 0x5D);
}
/**
* escaped-char = escape (
* %x22 / ; " quotation mark U+0022
* %x5C / ; \ reverse solidus U+005C
* %x2F / ; / solidus U+002F
* %x62 / ; b backspace U+0008
* %x66 / ; f form feed U+000C
* %x6E / ; n line feed U+000A
* %x72 / ; r carriage return U+000D
* %x74 / ; t tab U+0009
* %x75 4HEXDIG ) ; uXXXX U+XXXX (this is handled as part of parseEscapedUnicodeSequence)
*/
private ParseResult<String> parseEscapedChar(int startPosition, int endPosition) {
if (endPosition > input.length()) {
logError("escaped-char", "Invalid end position", startPosition);
return ParseResult.error();
}
if (charsInRange(startPosition, endPosition) != 2) {
logError("escaped-char", "Invalid length", startPosition);
return ParseResult.error();
}
if (!startsWith(startPosition, '\\')) {
logError("escaped-char", "Expected '\\'", startPosition);
return ParseResult.error();
}
char escapedChar = input.charAt(startPosition + 1);
switch (escapedChar) {
case '"': return ParseResult.success("\"");
case '\\': return ParseResult.success("\\");
case '/': return ParseResult.success("/");
case 'b': return ParseResult.success("\b");
case 'f': return ParseResult.success("\f");
case 'n': return ParseResult.success("\n");
case 'r': return ParseResult.success("\r");
case 't': return ParseResult.success("\t");
default:
logError("escaped-char", "Invalid escape sequence", startPosition);
return ParseResult.error();
}
}
private ParseResult<String> parseEscapedUnicodeSequence(int startPosition, int endPosition) {
if (endPosition > input.length()) {
logError("escaped-unicode-sequence", "Invalid end position", startPosition);
return ParseResult.error();
}
if (charsInRange(startPosition, endPosition) != 6) {
logError("escaped-unicode-sequence", "Invalid length", startPosition);
return ParseResult.error();
}
if (input.charAt(startPosition) != '\\') {
logError("escaped-unicode-sequence", "Expected '\\'", startPosition);
return ParseResult.error();
}
char escapedChar = input.charAt(startPosition + 1);
if (escapedChar != 'u') {
logError("escaped-unicode-sequence", "Invalid escape sequence", startPosition);
return ParseResult.error();
}
String unicodePattern = input.substring(startPosition + 2, startPosition + 2 + 4);
char unicodeChar;
try {
unicodeChar = (char) Integer.parseInt(unicodePattern, 16);
} catch (NumberFormatException e) {
logError("escaped-unicode-sequence", "Invalid unicode hex sequence", startPosition);
return ParseResult.error();
}
return ParseResult.success(String.valueOf(unicodeChar));
}
/**
* "*"
*/
private ParseResult<WildcardExpression> parseWildcardExpression(int startPosition, int endPosition) {
return parseExpectedToken("star-expression", startPosition, endPosition, '*').mapResult(v -> new WildcardExpression());
}
private int charsInRange(int startPosition, int endPosition) {
return endPosition - startPosition;
}
private List<Integer> findCharacters(int startPosition, int endPosition, String symbol) {
List<Integer> results = new ArrayList<>();
int start = startPosition;
while (true) {
int match = input.indexOf(symbol, start);
if (match < 0 || match >= endPosition) {
break;
}
results.add(match);
start = match + 1;
}
return results;
}
private ParseResult<Character> parseExpectedToken(String parser, int startPosition, int endPosition, char expectedToken) {
if (input.charAt(startPosition) != expectedToken) {
logError(parser, "Expected '" + expectedToken + "'", startPosition);
return ParseResult.error();
}
if (charsInRange(startPosition, endPosition) != 1) {
logError(parser, "Unexpected character", startPosition + 1);
return ParseResult.error();
}
return ParseResult.success(expectedToken);
}
private int trimLeftWhitespace(int startPosition, int endPosition) {
while (input.charAt(startPosition) == ' ' && startPosition < endPosition - 1) {
++startPosition;
}
return startPosition;
}
private int trimRightWhitespace(int startPosition, int endPosition) {
while (input.charAt(endPosition - 1) == ' ' && startPosition < endPosition - 1) {
--endPosition;
}
return endPosition;
}
private boolean startsWith(int startPosition, char character) {
return input.charAt(startPosition) == character;
}
private boolean endsWith(int endPosition, char character) {
return input.charAt(endPosition - 1) == character;
}
private boolean startsAndEndsWith(int startPosition, int endPosition, char startChar, char endChar) {
return startsWith(startPosition, startChar) && endsWith(endPosition, endChar);
}
private void logError(String parser, String message, int position) {
log.debug(() -> parser + " at " + position + ": " + message);
}
} | 3,884 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath/parser/JmesPathVisitor.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.jmespath.parser;
import software.amazon.awssdk.codegen.jmespath.component.AndExpression;
import software.amazon.awssdk.codegen.jmespath.component.BracketSpecifier;
import software.amazon.awssdk.codegen.jmespath.component.BracketSpecifierWithContents;
import software.amazon.awssdk.codegen.jmespath.component.BracketSpecifierWithQuestionMark;
import software.amazon.awssdk.codegen.jmespath.component.BracketSpecifierWithoutContents;
import software.amazon.awssdk.codegen.jmespath.component.ComparatorExpression;
import software.amazon.awssdk.codegen.jmespath.component.CurrentNode;
import software.amazon.awssdk.codegen.jmespath.component.Expression;
import software.amazon.awssdk.codegen.jmespath.component.ExpressionType;
import software.amazon.awssdk.codegen.jmespath.component.FunctionExpression;
import software.amazon.awssdk.codegen.jmespath.component.IndexExpression;
import software.amazon.awssdk.codegen.jmespath.component.Literal;
import software.amazon.awssdk.codegen.jmespath.component.MultiSelectHash;
import software.amazon.awssdk.codegen.jmespath.component.MultiSelectList;
import software.amazon.awssdk.codegen.jmespath.component.NotExpression;
import software.amazon.awssdk.codegen.jmespath.component.OrExpression;
import software.amazon.awssdk.codegen.jmespath.component.ParenExpression;
import software.amazon.awssdk.codegen.jmespath.component.PipeExpression;
import software.amazon.awssdk.codegen.jmespath.component.SliceExpression;
import software.amazon.awssdk.codegen.jmespath.component.SubExpression;
import software.amazon.awssdk.codegen.jmespath.component.SubExpressionRight;
import software.amazon.awssdk.codegen.jmespath.component.WildcardExpression;
/**
* A visitor across all of the JMESPath expression types. This can be passed to any 'union' type visitors, like
* {@link Expression#visit(JmesPathVisitor)}.
*/
public interface JmesPathVisitor {
void visitExpression(Expression input);
void visitSubExpression(SubExpression input);
void visitSubExpressionRight(SubExpressionRight input);
void visitIndexExpression(IndexExpression input);
void visitBracketSpecifier(BracketSpecifier input);
void visitBracketSpecifierWithContents(BracketSpecifierWithContents input);
void visitSliceExpression(SliceExpression input);
void visitBracketSpecifierWithoutContents(BracketSpecifierWithoutContents input);
void visitBracketSpecifierWithQuestionMark(BracketSpecifierWithQuestionMark input);
void visitComparatorExpression(ComparatorExpression input);
void visitOrExpression(OrExpression input);
void visitIdentifier(String input);
void visitAndExpression(AndExpression input);
void visitNotExpression(NotExpression input);
void visitParenExpression(ParenExpression input);
void visitWildcardExpression(WildcardExpression input);
void visitMultiSelectList(MultiSelectList input);
void visitMultiSelectHash(MultiSelectHash input);
void visitExpressionType(ExpressionType asExpressionType);
void visitLiteral(Literal input);
void visitFunctionExpression(FunctionExpression input);
void visitPipeExpression(PipeExpression input);
void visitRawString(String input);
void visitCurrentNode(CurrentNode input);
void visitNumber(int input);
}
| 3,885 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath/parser/ParseResult.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.jmespath.parser;
import java.util.function.Function;
import software.amazon.awssdk.utils.Validate;
/**
* The result of a {@link Parser#parse(int, int)} call. This is either successful ({@link #success}) or an error
* ({@link #error()}).
*/
public final class ParseResult<T> {
private final T result;
private ParseResult(T result) {
this.result = result;
}
/**
* Create a successful result with the provided value.
*/
public static <T> ParseResult<T> success(T result) {
Validate.notNull(result, "result");
return new ParseResult<>(result);
}
/**
* Create an error result.
*/
public static <T> ParseResult<T> error() {
return new ParseResult<>(null);
}
/**
* Convert the value in this parse result (if successful) using the provided function.
*/
public <U> ParseResult<U> mapResult(Function<T, U> mapper) {
if (hasResult()) {
return ParseResult.success(mapper.apply(result));
} else {
return ParseResult.error();
}
}
/**
* Returns true if the parse result was successful.
*/
public boolean hasResult() {
return result != null;
}
/**
* Returns the result of parsing.
*/
public T result() {
Validate.validState(hasResult(), "Result not available");
return result;
}
}
| 3,886 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath/parser | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/jmespath/parser/util/CompositeParser.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.jmespath.parser.util;
import java.util.function.Function;
import software.amazon.awssdk.codegen.jmespath.parser.ParseResult;
import software.amazon.awssdk.codegen.jmespath.parser.Parser;
/**
* A {@link Parser} that invokes a list of converters, returning the first converter that was successful. This is created
* using {@link #firstTry(Parser)} and new converters are added via {@link #thenTry(Parser)}.
*/
public final class CompositeParser<T> implements Parser<T> {
private final Parser<T> parser;
private CompositeParser(Parser<T> parser) {
this.parser = parser;
}
/**
* Create a {@link CompositeParser} that tries the provided parser first.
*/
public static <T> CompositeParser<T> firstTry(Parser<T> parser) {
return new CompositeParser<>(parser);
}
/**
* Create a {@link CompositeParser} that tries the provided parser first, converting the result of that parser using the
* provided function.
*/
public static <T, U> CompositeParser<U> firstTry(Parser<T> parser, Function<T, U> resultConverter) {
return firstTry((start, end) -> parser.parse(start, end).mapResult(resultConverter));
}
/**
* Create a new {@link CompositeParser} that tries the provided parser after all previous parsers.
*/
public CompositeParser<T> thenTry(Parser<T> nextParser) {
return new CompositeParser<>((start, end) -> {
ParseResult<T> parse = parser.parse(start, end);
if (!parse.hasResult()) {
return nextParser.parse(start, end);
}
return parse;
});
}
/**
* Create a new {@link CompositeParser} that tries the provided parser after all previous parsers, converting the result of
* that parser using the provided function.
*/
public <S> CompositeParser<T> thenTry(Parser<S> nextParser, Function<S, T> resultConverter) {
return thenTry((start, end) -> nextParser.parse(start, end).mapResult(resultConverter));
}
@Override
public ParseResult<T> parse(int startPosition, int endPosition) {
return parser.parse(startPosition, endPosition);
}
} | 3,887 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/emitters/GeneratorTaskParams.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.emitters;
import java.util.function.Consumer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import software.amazon.awssdk.codegen.emitters.tasks.SharedModelsTaskParamsValidator;
import software.amazon.awssdk.codegen.model.intermediate.IntermediateModel;
import software.amazon.awssdk.codegen.poet.PoetExtension;
/**
* Parameters for generator tasks.
*/
public class GeneratorTaskParams {
private static final Consumer<GeneratorTaskParams> TASK_PARAMS_VALIDATORS = new SharedModelsTaskParamsValidator();
private final IntermediateModel model;
private final GeneratorPathProvider pathProvider;
private final PoetExtension poetExtensions;
private final Logger log = LoggerFactory.getLogger(GeneratorTaskParams.class);
private GeneratorTaskParams(IntermediateModel model,
GeneratorPathProvider pathProvider) {
this.model = model;
this.pathProvider = pathProvider;
this.poetExtensions = new PoetExtension(model);
}
public static GeneratorTaskParams create(IntermediateModel model, String sourceDirectory, String testDirectory,
String resourcesDirectory) {
GeneratorPathProvider pathProvider = new GeneratorPathProvider(model, sourceDirectory, testDirectory, resourcesDirectory);
GeneratorTaskParams params = new GeneratorTaskParams(model, pathProvider);
TASK_PARAMS_VALIDATORS.accept(params);
return params;
}
/**
* @return Built intermediate model
*/
public IntermediateModel getModel() {
return model;
}
/**
* @return Provider for common paths.
*/
public GeneratorPathProvider getPathProvider() {
return pathProvider;
}
/**
* @return Extensions and convenience methods for Java Poet.
*/
public PoetExtension getPoetExtensions() {
return poetExtensions;
}
/**
* @return Logger
*/
public Logger getLog() {
return log;
}
}
| 3,888 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/emitters/GeneratorPathProvider.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.emitters;
import software.amazon.awssdk.codegen.internal.Utils;
import software.amazon.awssdk.codegen.model.intermediate.IntermediateModel;
/**
* Common paths used by generator tasks.
*/
public class GeneratorPathProvider {
private final IntermediateModel model;
private final String sourceDirectory;
private final String resourcesDirectory;
private final String testDirectory;
public GeneratorPathProvider(IntermediateModel model, String sourceDirectory, String testDirectory,
String resourcesDirectory) {
this.model = model;
this.sourceDirectory = sourceDirectory;
this.resourcesDirectory = resourcesDirectory;
this.testDirectory = testDirectory;
}
public String getSourceDirectory() {
return sourceDirectory;
}
public String getResourcesDirectory() {
return resourcesDirectory;
}
public String getTestDirectory() {
return testDirectory;
}
public String getModelDirectory() {
return sourceDirectory + "/" + Utils.packageToDirectory(model.getMetadata().getFullModelPackageName());
}
public String getTransformDirectory() {
return sourceDirectory + "/" + Utils.packageToDirectory(model.getMetadata().getFullTransformPackageName());
}
public String getClientDirectory() {
return sourceDirectory + "/" + Utils.packageToDirectory(model.getMetadata().getFullClientPackageName());
}
public String getClientInternalDirectory() {
return sourceDirectory + "/" + Utils.packageToDirectory(model.getMetadata().getFullClientInternalPackageName());
}
public String getPaginatorsDirectory() {
return sourceDirectory + "/" + Utils.packageToDirectory(model.getMetadata().getFullPaginatorsPackageName());
}
public String getAuthorizerDirectory() {
return sourceDirectory + "/" + Utils.packageToDirectory(model.getMetadata().getFullAuthPolicyPackageName());
}
public String getWaitersDirectory() {
return sourceDirectory + "/" + Utils.packageToDirectory(model.getMetadata().getFullWaitersPackageName());
}
public String getWaitersInternalDirectory() {
return sourceDirectory + "/" + Utils.packageToDirectory(model.getMetadata().getFullWaitersInternalPackageName());
}
public String getEndpointRulesDirectory() {
return sourceDirectory + "/" + Utils.packageToDirectory(model.getMetadata().getFullEndpointRulesPackageName());
}
public String getEndpointRulesInternalDirectory() {
return sourceDirectory + "/" + Utils.packageToDirectory(model.getMetadata().getFullInternalEndpointRulesPackageName());
}
public String getEndpointRulesInternalResourcesDirectory() {
return resourcesDirectory + "/" + Utils.packageToDirectory(model.getMetadata().getFullInternalEndpointRulesPackageName());
}
public String getEndpointRulesTestDirectory() {
return testDirectory + "/" + Utils.packageToDirectory(model.getMetadata().getFullEndpointRulesPackageName());
}
public String getAuthSchemeDirectory() {
return sourceDirectory + "/" + Utils.packageToDirectory(model.getMetadata().getFullAuthSchemePackageName());
}
public String getAuthSchemeInternalDirectory() {
return sourceDirectory + "/" + Utils.packageToDirectory(model.getMetadata().getFullInternalAuthSchemePackageName());
}
}
| 3,889 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/emitters/CodeWriter.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.emitters;
import static software.amazon.awssdk.codegen.internal.Constant.JAVA_FILE_NAME_SUFFIX;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.StringWriter;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.nio.file.Paths;
import software.amazon.awssdk.codegen.internal.Utils;
import software.amazon.awssdk.utils.StringUtils;
/**
* Formats the generated code and write it to the underlying file. The caller should call the flush
* method to write the contents to the file. This class is intended to be used only by the code
* generation system and is not to be used for public use.
*/
public class CodeWriter extends StringWriter {
/**
* The code transformation that should be applied before code is written.
*/
private final CodeTransformer codeWriteTransformer;
/**
* The code transformation that should be applied before source code is "compared" for equality. This is only used when
* attempting to clobber a file that has already been generated.
*/
private final CodeTransformer codeComparisonTransformer = new LinkRemover();
private final String dir;
private final String file;
/**
* Constructor to use for .java files.
* @param dir
* output directory where the file is to be created.
* @param file
* name of the file without .java suffix.
*/
public CodeWriter(String dir, String file) {
this(dir, file, JAVA_FILE_NAME_SUFFIX, false);
}
public CodeWriter(String dir, String file, boolean disableFormatter) {
this(dir, file, JAVA_FILE_NAME_SUFFIX, disableFormatter);
}
/**
* Constructor to use for custom file suffixes.
*
* @param dir
* output directory where the file is to be created.
* @param file
* name of the file excluding suffix.
* @param fileNameSuffix
* suffix to be appended at the end of file name.
*/
public CodeWriter(String dir, String file, String fileNameSuffix, boolean disableFormatter) {
if (dir == null) {
throw new IllegalArgumentException(
"Output Directory cannot be null.");
}
if (file == null) {
throw new IllegalArgumentException("File name cannot be null.");
}
if (fileNameSuffix == null) {
throw new IllegalArgumentException("File name suffix cannot be null.");
}
if (!file.endsWith(fileNameSuffix)) {
file = file + fileNameSuffix;
}
this.dir = dir;
this.file = file;
Utils.createDirectory(dir);
if (disableFormatter) {
codeWriteTransformer = CodeTransformer.chain(new UnusedImportRemover());
} else {
codeWriteTransformer = CodeTransformer.chain(new UnusedImportRemover(),
new JavaCodeFormatter());
}
}
/**
* This method is expected to be called only once during the code generation process after the
* template processing is done.
*/
@Override
public void flush() {
try {
Path outputFile = Paths.get(dir, this.file);
String contents = getBuffer().toString();
String formattedContents = codeWriteTransformer.apply(contents);
if (fileSize(outputFile) == 0) {
try (BufferedWriter writer = Files.newBufferedWriter(outputFile, StandardCharsets.UTF_8)) {
writer.write(formattedContents);
}
} else {
validateFileContentMatches(outputFile, formattedContents);
}
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
private long fileSize(Path outputFile) throws IOException {
try {
return Files.size(outputFile);
} catch (NoSuchFileException e) {
return 0;
}
}
private void validateFileContentMatches(Path outputFile, String newFileContents) throws IOException {
byte[] currentFileBytes = Files.readAllBytes(outputFile);
String currentFileContents = new String(currentFileBytes, StandardCharsets.UTF_8);
String currentContentForComparison = codeComparisonTransformer.apply(currentFileContents);
String newContentForComparison = codeComparisonTransformer.apply(newFileContents);
if (!StringUtils.equals(currentContentForComparison, newContentForComparison)) {
throw new IllegalStateException("Attempted to clobber existing file (" + outputFile + ") with a new file that has " +
"different content. This may indicate forgetting to clean up old generated files " +
"before running the generator?\n" +
"Existing file: \n" + currentContentForComparison + "\n\n" +
"New file: \n" + newContentForComparison);
}
}
}
| 3,890 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/emitters/LinkRemover.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.emitters;
import java.util.regex.Pattern;
/**
* Removes HTML "anchor" tags from a string. This is used to compare files during clobbering while ignoring their documentation
* links, which will pretty much always differ.
*/
public class LinkRemover implements CodeTransformer {
private static final Pattern LINK_PATTERN = Pattern.compile("(<a[ \n]*/>|<a[> \n].*?</a>)", Pattern.DOTALL);
@Override
public String apply(String input) {
return LINK_PATTERN.matcher(input).replaceAll("");
}
}
| 3,891 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/emitters/GeneratorTask.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.emitters;
import java.util.concurrent.RecursiveAction;
/**
* Base class for tasks.
*/
public abstract class GeneratorTask extends RecursiveAction {
}
| 3,892 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/emitters/PoetGeneratorTask.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.emitters;
import static software.amazon.awssdk.codegen.internal.Utils.closeQuietly;
import static software.amazon.awssdk.codegen.poet.PoetUtils.buildJavaFile;
import java.io.IOException;
import java.io.Writer;
import software.amazon.awssdk.codegen.poet.ClassSpec;
public final class PoetGeneratorTask extends GeneratorTask {
private final Writer writer;
private final ClassSpec classSpec;
private final String fileHeader;
public PoetGeneratorTask(String outputDirectory, String fileHeader, ClassSpec classSpec) {
this (outputDirectory, fileHeader, classSpec, false);
}
public PoetGeneratorTask(String outputDirectory, String fileHeader, ClassSpec classSpec, boolean disableFormatting) {
this.fileHeader = fileHeader;
this.writer = new CodeWriter(outputDirectory, classSpec.className().simpleName(), disableFormatting);
this.classSpec = classSpec;
}
@Override
public void compute() {
try {
writer.write(fileHeader);
writer.write("\n");
buildJavaFile(classSpec).writeTo(writer);
writer.flush();
} catch (IOException e) {
throw new RuntimeException(String.format("Error creating class %s", classSpec.className().simpleName()), e);
} finally {
closeQuietly(writer);
}
}
}
| 3,893 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/emitters/JavaCodeFormatter.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.emitters;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.ToolFactory;
import org.eclipse.jdt.core.formatter.CodeFormatter;
import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
import org.eclipse.text.edits.TextEdit;
import software.amazon.awssdk.codegen.internal.Constant;
/**
* Formats the generated java source code. Uses Eclipse JDT core plugin from the Eclipse SDK.
*/
@SuppressWarnings("unchecked")
public class JavaCodeFormatter implements CodeTransformer {
private static final Map<String, Object> DEFAULT_FORMATTER_OPTIONS;
static {
DEFAULT_FORMATTER_OPTIONS = DefaultCodeFormatterConstants.getEclipseDefaultSettings();
DEFAULT_FORMATTER_OPTIONS.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_8);
DEFAULT_FORMATTER_OPTIONS.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_8);
DEFAULT_FORMATTER_OPTIONS.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_8);
DEFAULT_FORMATTER_OPTIONS.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR,
JavaCore.SPACE);
DEFAULT_FORMATTER_OPTIONS.put(
DefaultCodeFormatterConstants.FORMATTER_COMMENT_INDENT_PARAMETER_DESCRIPTION,
DefaultCodeFormatterConstants.FALSE);
DEFAULT_FORMATTER_OPTIONS.put(
DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ENUM_CONSTANTS,
DefaultCodeFormatterConstants.createAlignmentValue(true,
DefaultCodeFormatterConstants.WRAP_ONE_PER_LINE,
DefaultCodeFormatterConstants.INDENT_ON_COLUMN));
DEFAULT_FORMATTER_OPTIONS.put(
DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_PARAMETERS_IN_CONSTRUCTOR_DECLARATION,
DefaultCodeFormatterConstants.createAlignmentValue(false,
DefaultCodeFormatterConstants.WRAP_COMPACT,
DefaultCodeFormatterConstants.INDENT_DEFAULT));
// Formats custom file headers if provided
DEFAULT_FORMATTER_OPTIONS
.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_HEADER,
DefaultCodeFormatterConstants.TRUE);
DEFAULT_FORMATTER_OPTIONS.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "130");
DEFAULT_FORMATTER_OPTIONS.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "120");
}
private final CodeFormatter codeFormatter;
/**
* Creates a JavaCodeFormatter using the default formatter options.
*/
public JavaCodeFormatter() {
this(new HashMap<>());
}
/**
* Creates a JavaCodeFormatter using the default formatter options and
* optionally applying user provided options on top.
*
* @param overrideOptions user provided options to apply on top of defaults
*/
public JavaCodeFormatter(final Map<String, Object> overrideOptions) {
Map formatterOptions = new HashMap<>(DEFAULT_FORMATTER_OPTIONS);
if (overrideOptions != null) {
formatterOptions.putAll(overrideOptions);
}
this.codeFormatter = ToolFactory.createCodeFormatter(formatterOptions,
ToolFactory.M_FORMAT_EXISTING);
}
@Override
public String apply(String contents) {
TextEdit edit = codeFormatter.format(
CodeFormatter.K_COMPILATION_UNIT
| CodeFormatter.F_INCLUDE_COMMENTS, contents, 0,
contents.length(), 0, Constant.LF);
if (edit == null) {
// TODO log a fatal or warning here. Throwing an exception is causing the actual freemarker error to be lost
return contents;
}
IDocument document = new Document(contents);
try {
edit.apply(document);
} catch (Exception e) {
throw new RuntimeException(
"Failed to format the generated source code.", e);
}
return document.get();
}
}
| 3,894 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/emitters/CodeTransformer.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.emitters;
import java.util.function.Function;
import java.util.stream.Stream;
public interface CodeTransformer extends Function<String, String> {
static CodeTransformer chain(CodeTransformer... processors) {
return input -> Stream.of(processors).map(p -> (Function<String, String>) p)
.reduce(Function.identity(), Function::andThen).apply(input);
}
@Override
String apply(String input);
}
| 3,895 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/emitters/SimpleGeneratorTask.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.emitters;
import static software.amazon.awssdk.codegen.internal.Utils.closeQuietly;
import java.io.IOException;
import java.io.Writer;
import java.util.function.Supplier;
/**
* Simple generator task that writes a string to a file.
*/
public final class SimpleGeneratorTask extends GeneratorTask {
private final Writer writer;
private final String fileHeader;
private final String fileName;
private final Supplier<String> contents;
public SimpleGeneratorTask(String outputDirectory,
String fileName,
String fileHeader,
Supplier<String> contents) {
this.fileHeader = fileHeader;
this.writer = new CodeWriter(outputDirectory, fileName);
this.fileName = fileName;
this.contents = contents;
}
public SimpleGeneratorTask(String outputDirectory,
String fileName,
String filenameSuffix,
String fileHeader,
Supplier<String> contents) {
this.fileHeader = fileHeader;
this.writer = new CodeWriter(outputDirectory, fileName, filenameSuffix, false);
this.fileName = fileName;
this.contents = contents;
}
@Override
public void compute() {
try {
writer.write(fileHeader + "\n");
writer.write(contents.get());
writer.flush();
} catch (IOException e) {
throw new RuntimeException(String.format("Error creating file %s", fileName), e);
} finally {
closeQuietly(writer);
}
}
}
| 3,896 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/emitters/UnusedImportRemover.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.emitters;
import static java.util.stream.Collectors.toSet;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class UnusedImportRemover implements CodeTransformer {
private static Pattern IMPORT_PATTERN = Pattern.compile("import(?:\\s+)(?:static\\s+)?(.*)(?:\\s*);");
@Override
public String apply(String content) {
return findUnusedImports(content).stream().map(this::removeImportFunction).reduce(Function.identity(),
Function::andThen).apply(content);
}
private Function<String, String> removeImportFunction(String importToRemove) {
return c -> c.replaceFirst(findSpecificImportRegex(importToRemove), "");
}
private Set<String> findUnusedImports(String content) {
return findImports(content).stream().filter(isUnused(content)).collect(toSet());
}
private List<String> findImports(String content) {
Matcher m = IMPORT_PATTERN.matcher(content);
List<String> imports = new ArrayList<>();
while (m.find()) {
imports.add(m.group(1));
}
return imports;
}
private String removeAllImports(String content) {
return content.replaceAll(IMPORT_PATTERN.pattern(), "");
}
private Predicate<String> isUnused(String content) {
String contentWithoutImports = removeAllImports(content);
return importToCheck -> !importToCheck.contains("*")
&& (isNotReferenced(contentWithoutImports, importToCheck) || isDuplicate(content, importToCheck));
}
private boolean isNotReferenced(String contentWithoutImports, String importToCheck) {
String symbol = importToCheck.substring(importToCheck.lastIndexOf('.') + 1);
return !Pattern.compile(String.format("\\b%s\\b", symbol)).matcher(contentWithoutImports).find();
}
private boolean isDuplicate(String content, String importToCheck) {
Matcher m = Pattern.compile(findSpecificImportRegex(importToCheck)).matcher(content);
return m.find() && m.find();
}
private String findSpecificImportRegex(String specificImport) {
return String.format("import(?:\\s+)(?:static )?(?:%s)(?:\\s*);", specificImport);
}
}
| 3,897 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/emitters | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/emitters/tasks/CommonClientGeneratorTasks.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.emitters.tasks;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import software.amazon.awssdk.codegen.emitters.GeneratorTask;
import software.amazon.awssdk.codegen.emitters.GeneratorTaskParams;
import software.amazon.awssdk.codegen.poet.builder.BaseClientBuilderClass;
import software.amazon.awssdk.codegen.poet.builder.BaseClientBuilderInterface;
import software.amazon.awssdk.codegen.poet.model.ServiceClientConfigurationBuilderClass;
import software.amazon.awssdk.codegen.poet.model.ServiceClientConfigurationClass;
/**
* Task for classes shared by {@link AsyncClientGeneratorTasks} and {@link SyncClientGeneratorTasks}.
*/
public class CommonClientGeneratorTasks extends BaseGeneratorTasks {
public CommonClientGeneratorTasks(GeneratorTaskParams dependencies) {
super(dependencies);
}
@Override
protected List<GeneratorTask> createTasks() throws Exception {
return Arrays.asList(createBaseBuilderTask(),
createBaseBuilderInterfaceTask(),
createServiceClientConfigurationTask(),
createServiceClientConfigurationBuilderTask());
}
private GeneratorTask createBaseBuilderTask() throws IOException {
return createPoetGeneratorTask(new BaseClientBuilderClass(model));
}
private GeneratorTask createBaseBuilderInterfaceTask() throws IOException {
return createPoetGeneratorTask(new BaseClientBuilderInterface(model));
}
private GeneratorTask createServiceClientConfigurationTask() throws IOException {
return createPoetGeneratorTask(new ServiceClientConfigurationClass(model));
}
private GeneratorTask createServiceClientConfigurationBuilderTask() throws IOException {
return createPoetGeneratorTask(new ServiceClientConfigurationBuilderClass(model));
}
}
| 3,898 |
0 | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/emitters | Create_ds/aws-sdk-java-v2/codegen/src/main/java/software/amazon/awssdk/codegen/emitters/tasks/SharedModelsTaskParamsValidator.java | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package software.amazon.awssdk.codegen.emitters.tasks;
import java.io.File;
import java.util.function.Consumer;
import software.amazon.awssdk.codegen.emitters.CodeWriter;
import software.amazon.awssdk.codegen.emitters.GeneratorTaskParams;
import software.amazon.awssdk.codegen.model.config.customization.CustomizationConfig;
import software.amazon.awssdk.codegen.model.config.customization.ShareModelConfig;
/**
* This validates that services with the {@link CustomizationConfig#shareModelConfig} attribute specified are being generated
* after the service they are attempting to share models with. This ensures that the services are kept together in the same
* module and allows us to verify (in {@link CodeWriter}) that their models are compatible with each other.
*/
public class SharedModelsTaskParamsValidator implements Consumer<GeneratorTaskParams> {
@Override
public void accept(GeneratorTaskParams params) {
ShareModelConfig sharedModelService = params.getModel().getCustomizationConfig().getShareModelConfig();
if (sharedModelService != null) {
// Validate the service we're sharing models with has been generated already.
File modelPackageDirectory = new File(params.getPathProvider().getModelDirectory());
if (!modelPackageDirectory.exists()) {
String error = String.format("Unable to share models with '%s', because that service's models haven't been "
+ "generated yet ('%s' doesn't exist). You must generate that service before "
+ "generating '%s'.",
sharedModelService,
modelPackageDirectory,
params.getModel().getMetadata().getDescriptiveServiceName());
throw new IllegalStateException(error);
}
}
}
}
| 3,899 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.