software.amazon.awssdk.services.iam.model.Statement Maven / Gradle / Ivy
Show all versions of iam Show documentation
/*
* 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.services.iam.model;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.core.SdkField;
import software.amazon.awssdk.core.SdkPojo;
import software.amazon.awssdk.core.protocol.MarshallLocation;
import software.amazon.awssdk.core.protocol.MarshallingType;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Contains a reference to a Statement
element in a policy document that determines the result of the
* simulation.
*
*
* This data type is used by the MatchedStatements
member of the EvaluationResult
* type.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class Statement implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField SOURCE_POLICY_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("SourcePolicyId").getter(getter(Statement::sourcePolicyId)).setter(setter(Builder::sourcePolicyId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SourcePolicyId").build()).build();
private static final SdkField SOURCE_POLICY_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("SourcePolicyType").getter(getter(Statement::sourcePolicyTypeAsString))
.setter(setter(Builder::sourcePolicyType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SourcePolicyType").build()).build();
private static final SdkField START_POSITION_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("StartPosition").getter(getter(Statement::startPosition)).setter(setter(Builder::startPosition))
.constructor(Position::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StartPosition").build()).build();
private static final SdkField END_POSITION_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("EndPosition").getter(getter(Statement::endPosition)).setter(setter(Builder::endPosition))
.constructor(Position::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EndPosition").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(SOURCE_POLICY_ID_FIELD,
SOURCE_POLICY_TYPE_FIELD, START_POSITION_FIELD, END_POSITION_FIELD));
private static final long serialVersionUID = 1L;
private final String sourcePolicyId;
private final String sourcePolicyType;
private final Position startPosition;
private final Position endPosition;
private Statement(BuilderImpl builder) {
this.sourcePolicyId = builder.sourcePolicyId;
this.sourcePolicyType = builder.sourcePolicyType;
this.startPosition = builder.startPosition;
this.endPosition = builder.endPosition;
}
/**
*
* The identifier of the policy that was provided as an input.
*
*
* @return The identifier of the policy that was provided as an input.
*/
public final String sourcePolicyId() {
return sourcePolicyId;
}
/**
*
* The type of the policy.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #sourcePolicyType}
* will return {@link PolicySourceType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #sourcePolicyTypeAsString}.
*
*
* @return The type of the policy.
* @see PolicySourceType
*/
public final PolicySourceType sourcePolicyType() {
return PolicySourceType.fromValue(sourcePolicyType);
}
/**
*
* The type of the policy.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #sourcePolicyType}
* will return {@link PolicySourceType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #sourcePolicyTypeAsString}.
*
*
* @return The type of the policy.
* @see PolicySourceType
*/
public final String sourcePolicyTypeAsString() {
return sourcePolicyType;
}
/**
*
* The row and column of the beginning of the Statement
in an IAM policy.
*
*
* @return The row and column of the beginning of the Statement
in an IAM policy.
*/
public final Position startPosition() {
return startPosition;
}
/**
*
* The row and column of the end of a Statement
in an IAM policy.
*
*
* @return The row and column of the end of a Statement
in an IAM policy.
*/
public final Position endPosition() {
return endPosition;
}
@Override
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public static Class extends Builder> serializableBuilderClass() {
return BuilderImpl.class;
}
@Override
public final int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(sourcePolicyId());
hashCode = 31 * hashCode + Objects.hashCode(sourcePolicyTypeAsString());
hashCode = 31 * hashCode + Objects.hashCode(startPosition());
hashCode = 31 * hashCode + Objects.hashCode(endPosition());
return hashCode;
}
@Override
public final boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public final boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof Statement)) {
return false;
}
Statement other = (Statement) obj;
return Objects.equals(sourcePolicyId(), other.sourcePolicyId())
&& Objects.equals(sourcePolicyTypeAsString(), other.sourcePolicyTypeAsString())
&& Objects.equals(startPosition(), other.startPosition()) && Objects.equals(endPosition(), other.endPosition());
}
/**
* Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be
* redacted from this string using a placeholder value.
*/
@Override
public final String toString() {
return ToString.builder("Statement").add("SourcePolicyId", sourcePolicyId())
.add("SourcePolicyType", sourcePolicyTypeAsString()).add("StartPosition", startPosition())
.add("EndPosition", endPosition()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "SourcePolicyId":
return Optional.ofNullable(clazz.cast(sourcePolicyId()));
case "SourcePolicyType":
return Optional.ofNullable(clazz.cast(sourcePolicyTypeAsString()));
case "StartPosition":
return Optional.ofNullable(clazz.cast(startPosition()));
case "EndPosition":
return Optional.ofNullable(clazz.cast(endPosition()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function