本文整理了Java中software.amazon.awssdk.utils.Validate
类的一些代码示例,展示了Validate
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Validate
类的具体详情如下:
包路径:software.amazon.awssdk.utils.Validate
类名称:Validate
[英]This class assists in validating arguments. The validation methods are based along the following principles:
All exceptions messages are format strings as defined by the Java platform. For example:
Validate.isTrue(i > 0, "The value must be greater than zero: %d", i);
Validate.notNull(surname, "The surname must not be %s", null);
This class's source was modified from the Apache commons-lang library: https://github.com/apache/commons-lang/
#ThreadSafe#
[中]此类帮助验证参数。验证方法基于以下原则:
*无效的null参数会导致NullPointerException。
*非null参数会导致IllegalArgumentException。
*数组/集合/映射/字符串中的无效索引会导致IndexOutOfBoundsException。
所有异常消息都是Java平台定义的{$0$}。例如:
Validate.isTrue(i > 0, "The value must be greater than zero: %d", i);
Validate.notNull(surname, "The surname must not be %s", null);
该类的源代码是从Apache commons lang库中修改的:https://github.com/apache/commons-lang/
#线程安全#
代码示例来源:origin: aws/aws-sdk-java-v2
@Override
public SdkHttpFullRequest marshall(GetClassifiersRequest getClassifiersRequest) {
Validate.paramNotNull(getClassifiersRequest, "getClassifiersRequest");
try {
ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory
.createProtocolMarshaller(SDK_OPERATION_BINDING);
return protocolMarshaller.marshall(getClassifiersRequest);
} catch (Exception e) {
throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build();
}
}
}
代码示例来源:origin: aws/aws-sdk-java-v2
private String standardizeProtocol(String protocol) {
Validate.paramNotNull(protocol, "protocol");
String standardizedProtocol = StringUtils.lowerCase(protocol);
Validate.isTrue(standardizedProtocol.equals("http") || standardizedProtocol.equals("https"),
"Protocol must be 'http' or 'https', but was %s", protocol);
return standardizedProtocol;
}
代码示例来源:origin: aws/aws-sdk-java-v2
private SdkEventLoopGroup eventLoopGroup(DefaultBuilder builder) {
Validate.isTrue(builder.eventLoopGroup == null || builder.eventLoopGroupBuilder == null,
"The eventLoopGroup and the eventLoopGroupFactory can't both be configured.");
return Either.fromNullable(builder.eventLoopGroup, builder.eventLoopGroupBuilder)
.map(e -> e.map(this::nonManagedEventLoopGroup, SdkEventLoopGroup.Builder::build))
.orElseGet(SharedSdkEventLoopGroup::get);
}
代码示例来源:origin: aws/aws-sdk-java-v2
protected StsCredentialsProvider(BaseBuilder<?, ?> builder, String asyncThreadName) {
this.stsClient = Validate.notNull(builder.stsClient, "STS client must not be null.");
CachedSupplier.Builder<SessionCredentialsHolder> cacheBuilder = CachedSupplier.builder(this::updateSessionCredentials);
if (builder.asyncCredentialUpdateEnabled) {
cacheBuilder.prefetchStrategy(new NonBlocking(asyncThreadName));
}
this.sessionCache = cacheBuilder.build();
}
代码示例来源:origin: aws/aws-sdk-java-v2
public void run() throws Exception {
Validate.isTrue(Files.isRegularFile(serviceJson), serviceJson + " is not a file.");
Path codegenFileLocation = codegenFileLocation(serviceModuleName);
copyFile(serviceJson, codegenFileLocation.resolve("service-2.json"));
copyFile(paginatorsJson, codegenFileLocation.resolve("paginators-1.json"));
copyFile(waitersJson, codegenFileLocation.resolve("waiters-2.json"));
}
代码示例来源:origin: aws/aws-sdk-java-v2
@Override
public SdkHttpFullRequest marshall(GetCrawlerMetricsRequest getCrawlerMetricsRequest) {
Validate.paramNotNull(getCrawlerMetricsRequest, "getCrawlerMetricsRequest");
try {
ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory
.createProtocolMarshaller(SDK_OPERATION_BINDING);
return protocolMarshaller.marshall(getCrawlerMetricsRequest);
} catch (Exception e) {
throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build();
}
}
}
代码示例来源:origin: aws/aws-sdk-java-v2
@Override
public SdkHttpFullRequest marshall(CreateAuthorizerRequest createAuthorizerRequest) {
Validate.paramNotNull(createAuthorizerRequest, "createAuthorizerRequest");
try {
ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory
.createProtocolMarshaller(SDK_OPERATION_BINDING);
return protocolMarshaller.marshall(createAuthorizerRequest);
} catch (Exception e) {
throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build();
}
}
}
代码示例来源:origin: aws/aws-sdk-java-v2
@Override
public SdkHttpFullRequest marshall(CancelJobRequest cancelJobRequest) {
Validate.paramNotNull(cancelJobRequest, "cancelJobRequest");
try {
ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory
.createProtocolMarshaller(SDK_OPERATION_BINDING);
return protocolMarshaller.marshall(cancelJobRequest);
} catch (Exception e) {
throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build();
}
}
}
代码示例来源:origin: aws/aws-sdk-java-v2
@Override
public SdkHttpFullRequest marshall(CreatePolicyRequest createPolicyRequest) {
Validate.paramNotNull(createPolicyRequest, "createPolicyRequest");
try {
ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory
.createProtocolMarshaller(SDK_OPERATION_BINDING);
return protocolMarshaller.marshall(createPolicyRequest);
} catch (Exception e) {
throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build();
}
}
}
代码示例来源:origin: aws/aws-sdk-java-v2
@Override
public SdkHttpFullRequest marshall(UpdateJobRequest updateJobRequest) {
Validate.paramNotNull(updateJobRequest, "updateJobRequest");
try {
ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory
.createProtocolMarshaller(SDK_OPERATION_BINDING);
return protocolMarshaller.marshall(updateJobRequest);
} catch (Exception e) {
throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build();
}
}
}
代码示例来源:origin: aws/aws-sdk-java-v2
@Override
public SdkHttpFullRequest marshall(UpdateThingRequest updateThingRequest) {
Validate.paramNotNull(updateThingRequest, "updateThingRequest");
try {
ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory
.createProtocolMarshaller(SDK_OPERATION_BINDING);
return protocolMarshaller.marshall(updateThingRequest);
} catch (Exception e) {
throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build();
}
}
}
代码示例来源:origin: aws/aws-sdk-java-v2
@Override
public SdkHttpFullRequest marshall(GetPendingJobExecutionsRequest getPendingJobExecutionsRequest) {
Validate.paramNotNull(getPendingJobExecutionsRequest, "getPendingJobExecutionsRequest");
try {
ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory
.createProtocolMarshaller(SDK_OPERATION_BINDING);
return protocolMarshaller.marshall(getPendingJobExecutionsRequest);
} catch (Exception e) {
throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build();
}
}
}
代码示例来源:origin: aws/aws-sdk-java-v2
@Override
public SdkHttpFullRequest marshall(ListReusableDelegationSetsRequest listReusableDelegationSetsRequest) {
Validate.paramNotNull(listReusableDelegationSetsRequest, "listReusableDelegationSetsRequest");
try {
ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory
.createProtocolMarshaller(SDK_OPERATION_BINDING);
return protocolMarshaller.marshall(listReusableDelegationSetsRequest);
} catch (Exception e) {
throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build();
}
}
}
代码示例来源:origin: aws/aws-sdk-java-v2
@Override
public SdkHttpFullRequest marshall(GetGroupRequest getGroupRequest) {
Validate.paramNotNull(getGroupRequest, "getGroupRequest");
try {
ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory
.createProtocolMarshaller(SDK_OPERATION_BINDING);
return protocolMarshaller.marshall(getGroupRequest);
} catch (Exception e) {
throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build();
}
}
}
代码示例来源:origin: aws/aws-sdk-java-v2
@Override
public SdkHttpFullRequest marshall(CreateJobRequest createJobRequest) {
Validate.paramNotNull(createJobRequest, "createJobRequest");
try {
ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory
.createProtocolMarshaller(SDK_OPERATION_BINDING);
return protocolMarshaller.marshall(createJobRequest);
} catch (Exception e) {
throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build();
}
}
}
代码示例来源:origin: aws/aws-sdk-java-v2
@Override
public SdkHttpFullRequest marshall(GetDevicesInPlacementRequest getDevicesInPlacementRequest) {
Validate.paramNotNull(getDevicesInPlacementRequest, "getDevicesInPlacementRequest");
try {
ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory
.createProtocolMarshaller(SDK_OPERATION_BINDING);
return protocolMarshaller.marshall(getDevicesInPlacementRequest);
} catch (Exception e) {
throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build();
}
}
}
代码示例来源:origin: aws/aws-sdk-java-v2
@Override
public SdkHttpFullRequest marshall(DescribePlacementRequest describePlacementRequest) {
Validate.paramNotNull(describePlacementRequest, "describePlacementRequest");
try {
ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory
.createProtocolMarshaller(SDK_OPERATION_BINDING);
return protocolMarshaller.marshall(describePlacementRequest);
} catch (Exception e) {
throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build();
}
}
}
代码示例来源:origin: aws/aws-sdk-java-v2
@Override
public SdkHttpFullRequest marshall(ListDatastoresRequest listDatastoresRequest) {
Validate.paramNotNull(listDatastoresRequest, "listDatastoresRequest");
try {
ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory
.createProtocolMarshaller(SDK_OPERATION_BINDING);
return protocolMarshaller.marshall(listDatastoresRequest);
} catch (Exception e) {
throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build();
}
}
}
代码示例来源:origin: aws/aws-sdk-java-v2
@Override
public SdkHttpFullRequest marshall(DecreaseStreamRetentionPeriodRequest decreaseStreamRetentionPeriodRequest) {
Validate.paramNotNull(decreaseStreamRetentionPeriodRequest, "decreaseStreamRetentionPeriodRequest");
try {
ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory
.createProtocolMarshaller(SDK_OPERATION_BINDING);
return protocolMarshaller.marshall(decreaseStreamRetentionPeriodRequest);
} catch (Exception e) {
throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build();
}
}
}
代码示例来源:origin: aws/aws-sdk-java-v2
@Override
public SdkHttpFullRequest marshall(CreateThingRequest createThingRequest) {
Validate.paramNotNull(createThingRequest, "createThingRequest");
try {
ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory
.createProtocolMarshaller(SDK_OPERATION_BINDING);
return protocolMarshaller.marshall(createThingRequest);
} catch (Exception e) {
throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build();
}
}
}
内容来源于网络,如有侵权,请联系作者删除!