
software.amazon.awssdk.services.accessanalyzer.model.PathElement Maven / Gradle / Ivy
/*
* 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.accessanalyzer.model;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
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.core.util.SdkAutoConstructList;
import software.amazon.awssdk.core.util.SdkAutoConstructMap;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* A single element in a path through the JSON representation of a policy.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class PathElement implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField INDEX_FIELD = SdkField. builder(MarshallingType.INTEGER).memberName("index")
.getter(getter(PathElement::index)).setter(setter(Builder::index))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("index").build()).build();
private static final SdkField KEY_FIELD = SdkField. builder(MarshallingType.STRING).memberName("key")
.getter(getter(PathElement::key)).setter(setter(Builder::key))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("key").build()).build();
private static final SdkField SUBSTRING_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("substring").getter(getter(PathElement::substring)).setter(setter(Builder::substring))
.constructor(Substring::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("substring").build()).build();
private static final SdkField VALUE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("value")
.getter(getter(PathElement::value)).setter(setter(Builder::value))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("value").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(INDEX_FIELD, KEY_FIELD,
SUBSTRING_FIELD, VALUE_FIELD));
private static final long serialVersionUID = 1L;
private final Integer index;
private final String key;
private final Substring substring;
private final String value;
private final Type type;
private PathElement(BuilderImpl builder) {
this.index = builder.index;
this.key = builder.key;
this.substring = builder.substring;
this.value = builder.value;
this.type = builder.type;
}
/**
*
* Refers to an index in a JSON array.
*
*
* @return Refers to an index in a JSON array.
*/
public final Integer index() {
return index;
}
/**
*
* Refers to a key in a JSON object.
*
*
* @return Refers to a key in a JSON object.
*/
public final String key() {
return key;
}
/**
*
* Refers to a substring of a literal string in a JSON object.
*
*
* @return Refers to a substring of a literal string in a JSON object.
*/
public final Substring substring() {
return substring;
}
/**
*
* Refers to the value associated with a given key in a JSON object.
*
*
* @return Refers to the value associated with a given key in a JSON object.
*/
public final String value() {
return value;
}
@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(index());
hashCode = 31 * hashCode + Objects.hashCode(key());
hashCode = 31 * hashCode + Objects.hashCode(substring());
hashCode = 31 * hashCode + Objects.hashCode(value());
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 PathElement)) {
return false;
}
PathElement other = (PathElement) obj;
return Objects.equals(index(), other.index()) && Objects.equals(key(), other.key())
&& Objects.equals(substring(), other.substring()) && Objects.equals(value(), other.value());
}
/**
* 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("PathElement").add("Index", index()).add("Key", key()).add("Substring", substring())
.add("Value", value()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "index":
return Optional.ofNullable(clazz.cast(index()));
case "key":
return Optional.ofNullable(clazz.cast(key()));
case "substring":
return Optional.ofNullable(clazz.cast(substring()));
case "value":
return Optional.ofNullable(clazz.cast(value()));
default:
return Optional.empty();
}
}
/**
* Create an instance of this class with {@link #index()} initialized to the given value.
*
*
* Refers to an index in a JSON array.
*
*
* @param index
* Refers to an index in a JSON array.
*/
public static PathElement fromIndex(Integer index) {
return builder().index(index).build();
}
/**
* Create an instance of this class with {@link #key()} initialized to the given value.
*
*
* Refers to a key in a JSON object.
*
*
* @param key
* Refers to a key in a JSON object.
*/
public static PathElement fromKey(String key) {
return builder().key(key).build();
}
/**
* Create an instance of this class with {@link #substring()} initialized to the given value.
*
*
* Refers to a substring of a literal string in a JSON object.
*
*
* @param substring
* Refers to a substring of a literal string in a JSON object.
*/
public static PathElement fromSubstring(Substring substring) {
return builder().substring(substring).build();
}
/**
* Create an instance of this class with {@link #substring()} initialized to the given value.
*
*
* Refers to a substring of a literal string in a JSON object.
*
*
* @param substring
* Refers to a substring of a literal string in a JSON object.
*/
public static PathElement fromSubstring(Consumer substring) {
Substring.Builder builder = Substring.builder();
substring.accept(builder);
return fromSubstring(builder.build());
}
/**
* Create an instance of this class with {@link #value()} initialized to the given value.
*
*
* Refers to the value associated with a given key in a JSON object.
*
*
* @param value
* Refers to the value associated with a given key in a JSON object.
*/
public static PathElement fromValue(String value) {
return builder().value(value).build();
}
/**
* Retrieve an enum value representing which member of this object is populated.
*
* 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.
*
* 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.
*/
public Type type() {
return type;
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function
© 2015 - 2025 Weber Informatics LLC | Privacy Policy