All Downloads are FREE. Search and download functionalities are using the official Maven repository.

software.amazon.awssdk.services.xray.model.ErrorRootCauseEntity 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.xray.model;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Collection;
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 java.util.stream.Collectors;
import java.util.stream.Stream;
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.ListTrait;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList;
import software.amazon.awssdk.core.util.SdkAutoConstructList;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;

/**
 * 

* A collection of segments and corresponding subsegments associated to a trace summary error. *

*/ @Generated("software.amazon.awssdk:codegen") public final class ErrorRootCauseEntity implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField NAME_FIELD = SdkField. builder(MarshallingType.STRING) .getter(getter(ErrorRootCauseEntity::name)).setter(setter(Builder::name)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Name").build()).build(); private static final SdkField> EXCEPTIONS_FIELD = SdkField .> builder(MarshallingType.LIST) .getter(getter(ErrorRootCauseEntity::exceptions)) .setter(setter(Builder::exceptions)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Exceptions").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField. builder(MarshallingType.SDK_POJO) .constructor(RootCauseException::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()).build()).build(); private static final SdkField REMOTE_FIELD = SdkField. builder(MarshallingType.BOOLEAN) .getter(getter(ErrorRootCauseEntity::remote)).setter(setter(Builder::remote)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Remote").build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(NAME_FIELD, EXCEPTIONS_FIELD, REMOTE_FIELD)); private static final long serialVersionUID = 1L; private final String name; private final List exceptions; private final Boolean remote; private ErrorRootCauseEntity(BuilderImpl builder) { this.name = builder.name; this.exceptions = builder.exceptions; this.remote = builder.remote; } /** *

* The name of the entity. *

* * @return The name of the entity. */ public String name() { return name; } /** * Returns true if the Exceptions property was specified by the sender (it may be empty), or false if the sender did * not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS service. */ public boolean hasExceptions() { return exceptions != null && !(exceptions instanceof SdkAutoConstructList); } /** *

* The types and messages of the exceptions. *

*

* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. *

*

* You can use {@link #hasExceptions()} to see if a value was sent in this field. *

* * @return The types and messages of the exceptions. */ public List exceptions() { return exceptions; } /** *

* A flag that denotes a remote subsegment. *

* * @return A flag that denotes a remote subsegment. */ public Boolean remote() { return remote; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class serializableBuilderClass() { return BuilderImpl.class; } @Override public int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + Objects.hashCode(name()); hashCode = 31 * hashCode + Objects.hashCode(exceptions()); hashCode = 31 * hashCode + Objects.hashCode(remote()); return hashCode; } @Override public boolean equals(Object obj) { return equalsBySdkFields(obj); } @Override public boolean equalsBySdkFields(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof ErrorRootCauseEntity)) { return false; } ErrorRootCauseEntity other = (ErrorRootCauseEntity) obj; return Objects.equals(name(), other.name()) && Objects.equals(exceptions(), other.exceptions()) && Objects.equals(remote(), other.remote()); } /** * 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 String toString() { return ToString.builder("ErrorRootCauseEntity").add("Name", name()).add("Exceptions", exceptions()) .add("Remote", remote()).build(); } public Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "Name": return Optional.ofNullable(clazz.cast(name())); case "Exceptions": return Optional.ofNullable(clazz.cast(exceptions())); case "Remote": return Optional.ofNullable(clazz.cast(remote())); default: return Optional.empty(); } } @Override public List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((ErrorRootCauseEntity) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* The name of the entity. *

* * @param name * The name of the entity. * @return Returns a reference to this object so that method calls can be chained together. */ Builder name(String name); /** *

* The types and messages of the exceptions. *

* * @param exceptions * The types and messages of the exceptions. * @return Returns a reference to this object so that method calls can be chained together. */ Builder exceptions(Collection exceptions); /** *

* The types and messages of the exceptions. *

* * @param exceptions * The types and messages of the exceptions. * @return Returns a reference to this object so that method calls can be chained together. */ Builder exceptions(RootCauseException... exceptions); /** *

* The types and messages of the exceptions. *

* This is a convenience that creates an instance of the {@link List.Builder} avoiding the * need to create one manually via {@link List#builder()}. * * When the {@link Consumer} completes, {@link List.Builder#build()} is called immediately * and its result is passed to {@link #exceptions(List)}. * * @param exceptions * a consumer that will call methods on {@link List.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #exceptions(List) */ Builder exceptions(Consumer... exceptions); /** *

* A flag that denotes a remote subsegment. *

* * @param remote * A flag that denotes a remote subsegment. * @return Returns a reference to this object so that method calls can be chained together. */ Builder remote(Boolean remote); } static final class BuilderImpl implements Builder { private String name; private List exceptions = DefaultSdkAutoConstructList.getInstance(); private Boolean remote; private BuilderImpl() { } private BuilderImpl(ErrorRootCauseEntity model) { name(model.name); exceptions(model.exceptions); remote(model.remote); } public final String getName() { return name; } @Override public final Builder name(String name) { this.name = name; return this; } public final void setName(String name) { this.name = name; } public final Collection getExceptions() { return exceptions != null ? exceptions.stream().map(RootCauseException::toBuilder).collect(Collectors.toList()) : null; } @Override public final Builder exceptions(Collection exceptions) { this.exceptions = RootCauseExceptionsCopier.copy(exceptions); return this; } @Override @SafeVarargs public final Builder exceptions(RootCauseException... exceptions) { exceptions(Arrays.asList(exceptions)); return this; } @Override @SafeVarargs public final Builder exceptions(Consumer... exceptions) { exceptions(Stream.of(exceptions).map(c -> RootCauseException.builder().applyMutation(c).build()) .collect(Collectors.toList())); return this; } public final void setExceptions(Collection exceptions) { this.exceptions = RootCauseExceptionsCopier.copyFromBuilder(exceptions); } public final Boolean getRemote() { return remote; } @Override public final Builder remote(Boolean remote) { this.remote = remote; return this; } public final void setRemote(Boolean remote) { this.remote = remote; } @Override public ErrorRootCauseEntity build() { return new ErrorRootCauseEntity(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy