本文整理了Java中software.amazon.awssdk.utils.Validate.validState()
方法的一些代码示例,展示了Validate.validState()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Validate.validState()
方法的具体详情如下:
包路径:software.amazon.awssdk.utils.Validate
类名称:Validate
方法名:validState
[英]Validate the stateful predicate is true for the given object and return the object; otherwise throw an exception with the specified message.
String value = Validate.validState(someString, s -> s.length() == 0, "must be blank got: %s", someString);
[中]验证给定对象的有状态谓词是否为真,并返回该对象;否则,将使用指定的消息引发异常。
字符串值=验证。validState(someString,s->s.length()==0,“必须为空,获取:%s”,someString);
代码示例来源:origin: software.amazon.awssdk/sdk-core
private RequestBody(ContentStreamProvider contentStreamProvider, long contentLength, String contentType) {
this.contentStreamProvider = paramNotNull(contentStreamProvider, "contentStreamProvider");
this.contentLength = contentLength;
this.contentType = paramNotNull(contentType, "contentType");
validState(contentLength >= 0, "Content length must be greater than or equal to zero");
}
代码示例来源:origin: aws/aws-sdk-java-v2
@Override
public Builder content(Path contentLocation) {
Validate.paramNotNull(contentLocation, "profileLocation");
Validate.validState(contentLocation.toFile().exists(), "Profile file '%s' does not exist.", contentLocation);
this.content = null;
this.contentLocation = contentLocation;
return this;
}
代码示例来源:origin: software.amazon.awssdk/profiles
@Override
public Builder content(Path contentLocation) {
Validate.paramNotNull(contentLocation, "profileLocation");
Validate.validState(contentLocation.toFile().exists(), "Profile file '%s' does not exist.", contentLocation);
this.content = null;
this.contentLocation = contentLocation;
return this;
}
代码示例来源:origin: software.amazon.awssdk/sdk-core
/**
* Validate the result of calling an interceptor method that is attempting to modify the message to make sure its result is
* valid.
*/
private void validateInterceptorResult(Object originalMessage, Object newMessage,
ExecutionInterceptor interceptor, String methodName) {
if (!Objects.equals(originalMessage, newMessage)) {
LOG.debug(() -> "Interceptor '" + interceptor + "' modified the message with its " + methodName + " method.");
LOG.trace(() -> "Old: " + originalMessage + "\nNew: " + newMessage);
}
Validate.validState(newMessage != null,
"Request interceptor '%s' returned null from its %s interceptor.",
interceptor, methodName);
Validate.isInstanceOf(originalMessage.getClass(), newMessage,
"Request interceptor '%s' returned '%s' from its %s method, but '%s' was expected.",
interceptor, newMessage.getClass(), methodName, originalMessage.getClass());
}
代码示例来源:origin: aws/aws-sdk-java-v2
/**
* Load an assumed-role credentials provider that has been configured in this profile. This will attempt to locate the STS
* module in order to generate the credentials provider. If it's not available, an illegal state exception will be raised.
*
* @param children The child profiles that source credentials from this profile.
*/
private AwsCredentialsProvider roleBasedProfileCredentialsProvider(Set<String> children) {
requireProperties(ProfileProperty.SOURCE_PROFILE);
Validate.validState(!children.contains(name),
"Invalid profile file: Circular relationship detected with profiles %s.", children);
Validate.validState(credentialsSourceResolver != null,
"The profile '%s' must be configured with a source profile in order to use assumed roles.", name);
children.add(name);
AwsCredentialsProvider sourceCredentialsProvider =
credentialsSourceResolver.apply(properties.get(ProfileProperty.SOURCE_PROFILE))
.flatMap(p -> new ProfileCredentialsUtils(p, credentialsSourceResolver)
.credentialsProvider(children))
.orElseThrow(this::noSourceCredentialsException);
return stsCredentialsProviderFactory().create(sourceCredentialsProvider, profile);
}
代码示例来源:origin: software.amazon.awssdk/codegen
static MethodSpec consumerBuilderVariant(MethodSpec spec, String javadoc) {
Validate.validState(spec.parameters.size() > 0, "A first parameter is required to generate a consumer-builder method.");
Validate.validState(spec.parameters.get(0).type instanceof ClassName, "The first parameter must be a class.");
ParameterSpec firstParameter = spec.parameters.get(0);
ClassName firstParameterClass = (ClassName) firstParameter.type;
TypeName consumer = ParameterizedTypeName.get(ClassName.get(Consumer.class), firstParameterClass.nestedClass("Builder"));
MethodSpec.Builder result = MethodSpec.methodBuilder(spec.name)
.returns(spec.returnType)
.addExceptions(spec.exceptions)
.addJavadoc(javadoc)
.addModifiers(Modifier.PUBLIC, Modifier.DEFAULT)
.addTypeVariables(spec.typeVariables)
.addParameter(ParameterSpec.builder(consumer, firstParameter.name).build());
// Parameters
StringBuilder methodBody = new StringBuilder("return $L($T.builder().applyMutation($L).build()");
for (int i = 1; i < spec.parameters.size(); i++) {
ParameterSpec parameter = spec.parameters.get(i);
methodBody.append(", ").append(parameter.name);
result.addParameter(parameter);
}
methodBody.append(")");
result.addStatement(methodBody.toString(), spec.name, firstParameterClass, firstParameter.name);
return result.build();
}
代码示例来源:origin: aws/aws-sdk-java-v2
static MethodSpec consumerBuilderVariant(MethodSpec spec, String javadoc) {
Validate.validState(spec.parameters.size() > 0, "A first parameter is required to generate a consumer-builder method.");
Validate.validState(spec.parameters.get(0).type instanceof ClassName, "The first parameter must be a class.");
ParameterSpec firstParameter = spec.parameters.get(0);
ClassName firstParameterClass = (ClassName) firstParameter.type;
TypeName consumer = ParameterizedTypeName.get(ClassName.get(Consumer.class), firstParameterClass.nestedClass("Builder"));
MethodSpec.Builder result = MethodSpec.methodBuilder(spec.name)
.returns(spec.returnType)
.addExceptions(spec.exceptions)
.addJavadoc(javadoc)
.addModifiers(Modifier.PUBLIC, Modifier.DEFAULT)
.addTypeVariables(spec.typeVariables)
.addParameter(ParameterSpec.builder(consumer, firstParameter.name).build());
// Parameters
StringBuilder methodBody = new StringBuilder("return $L($T.builder().applyMutation($L).build()");
for (int i = 1; i < spec.parameters.size(); i++) {
ParameterSpec parameter = spec.parameters.get(i);
methodBody.append(", ").append(parameter.name);
result.addParameter(parameter);
}
methodBody.append(")");
result.addStatement(methodBody.toString(), spec.name, firstParameterClass, firstParameter.name);
return result.build();
}
代码示例来源:origin: software.amazon.awssdk/auth
/**
* Load an assumed-role credentials provider that has been configured in this profile. This will attempt to locate the STS
* module in order to generate the credentials provider. If it's not available, an illegal state exception will be raised.
*
* @param children The child profiles that source credentials from this profile.
*/
private AwsCredentialsProvider roleBasedProfileCredentialsProvider(Set<String> children) {
requireProperties(ProfileProperty.SOURCE_PROFILE);
Validate.validState(!children.contains(name),
"Invalid profile file: Circular relationship detected with profiles %s.", children);
Validate.validState(credentialsSourceResolver != null,
"The profile '%s' must be configured with a source profile in order to use assumed roles.", name);
children.add(name);
AwsCredentialsProvider sourceCredentialsProvider =
credentialsSourceResolver.apply(properties.get(ProfileProperty.SOURCE_PROFILE))
.flatMap(p -> new ProfileCredentialsUtils(p, credentialsSourceResolver)
.credentialsProvider(children))
.orElseThrow(this::noSourceCredentialsException);
return stsCredentialsProviderFactory().create(sourceCredentialsProvider, profile);
}
代码示例来源:origin: aws/aws-sdk-java-v2
Validate.validState(credentials != null, "Credential providers must never return null.");
内容来源于网络,如有侵权,请联系作者删除!