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

software.amazon.awssdk.services.quicksight.model.LogicalTable 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.quicksight.model;

import java.beans.Transient;
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 logical table is a unit that joins and that data transformations operate on. A logical table has a source, * which can be either a physical table or result of a join. When a logical table points to a physical table, the * logical table acts as a mutable copy of that physical table through transform operations. *

*/ @Generated("software.amazon.awssdk:codegen") public final class LogicalTable implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField ALIAS_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Alias") .getter(getter(LogicalTable::alias)).setter(setter(Builder::alias)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Alias").build()).build(); private static final SdkField> DATA_TRANSFORMS_FIELD = SdkField .> builder(MarshallingType.LIST) .memberName("DataTransforms") .getter(getter(LogicalTable::dataTransforms)) .setter(setter(Builder::dataTransforms)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DataTransforms").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField. builder(MarshallingType.SDK_POJO) .constructor(TransformOperation::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()).build()).build(); private static final SdkField SOURCE_FIELD = SdkField . builder(MarshallingType.SDK_POJO).memberName("Source").getter(getter(LogicalTable::source)) .setter(setter(Builder::source)).constructor(LogicalTableSource::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Source").build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ALIAS_FIELD, DATA_TRANSFORMS_FIELD, SOURCE_FIELD)); private static final long serialVersionUID = 1L; private final String alias; private final List dataTransforms; private final LogicalTableSource source; private LogicalTable(BuilderImpl builder) { this.alias = builder.alias; this.dataTransforms = builder.dataTransforms; this.source = builder.source; } /** *

* A display name for the logical table. *

* * @return A display name for the logical table. */ public final String alias() { return alias; } /** * For responses, this returns true if the service returned a value for the DataTransforms property. This DOES NOT * check that the value is non-empty (for which, you should check the {@code isEmpty()} method on the property). * This is useful because the SDK will never return a null collection or map, but you may need to differentiate * between the service returning nothing (or null) and the service returning an empty collection or map. For * requests, this returns true if a value for the property was specified in the request builder, and false if a * value was not specified. */ public final boolean hasDataTransforms() { return dataTransforms != null && !(dataTransforms instanceof SdkAutoConstructList); } /** *

* Transform operations that act on this logical table. *

*

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

*

* This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasDataTransforms} method. *

* * @return Transform operations that act on this logical table. */ public final List dataTransforms() { return dataTransforms; } /** *

* Source of this logical table. *

* * @return Source of this logical table. */ public final LogicalTableSource source() { return source; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class serializableBuilderClass() { return BuilderImpl.class; } @Override public final int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + Objects.hashCode(alias()); hashCode = 31 * hashCode + Objects.hashCode(hasDataTransforms() ? dataTransforms() : null); hashCode = 31 * hashCode + Objects.hashCode(source()); 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 LogicalTable)) { return false; } LogicalTable other = (LogicalTable) obj; return Objects.equals(alias(), other.alias()) && hasDataTransforms() == other.hasDataTransforms() && Objects.equals(dataTransforms(), other.dataTransforms()) && Objects.equals(source(), other.source()); } /** * 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("LogicalTable").add("Alias", alias()) .add("DataTransforms", hasDataTransforms() ? dataTransforms() : null).add("Source", source()).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "Alias": return Optional.ofNullable(clazz.cast(alias())); case "DataTransforms": return Optional.ofNullable(clazz.cast(dataTransforms())); case "Source": return Optional.ofNullable(clazz.cast(source())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((LogicalTable) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* A display name for the logical table. *

* * @param alias * A display name for the logical table. * @return Returns a reference to this object so that method calls can be chained together. */ Builder alias(String alias); /** *

* Transform operations that act on this logical table. *

* * @param dataTransforms * Transform operations that act on this logical table. * @return Returns a reference to this object so that method calls can be chained together. */ Builder dataTransforms(Collection dataTransforms); /** *

* Transform operations that act on this logical table. *

* * @param dataTransforms * Transform operations that act on this logical table. * @return Returns a reference to this object so that method calls can be chained together. */ Builder dataTransforms(TransformOperation... dataTransforms); /** *

* Transform operations that act on this logical table. *

* 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 #dataTransforms(List)}. * * @param dataTransforms * 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 #dataTransforms(List) */ Builder dataTransforms(Consumer... dataTransforms); /** *

* Source of this logical table. *

* * @param source * Source of this logical table. * @return Returns a reference to this object so that method calls can be chained together. */ Builder source(LogicalTableSource source); /** *

* Source of this logical table. *

* This is a convenience that creates an instance of the {@link LogicalTableSource.Builder} avoiding the need to * create one manually via {@link LogicalTableSource#builder()}. * * When the {@link Consumer} completes, {@link LogicalTableSource.Builder#build()} is called immediately and its * result is passed to {@link #source(LogicalTableSource)}. * * @param source * a consumer that will call methods on {@link LogicalTableSource.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #source(LogicalTableSource) */ default Builder source(Consumer source) { return source(LogicalTableSource.builder().applyMutation(source).build()); } } static final class BuilderImpl implements Builder { private String alias; private List dataTransforms = DefaultSdkAutoConstructList.getInstance(); private LogicalTableSource source; private BuilderImpl() { } private BuilderImpl(LogicalTable model) { alias(model.alias); dataTransforms(model.dataTransforms); source(model.source); } public final String getAlias() { return alias; } public final void setAlias(String alias) { this.alias = alias; } @Override @Transient public final Builder alias(String alias) { this.alias = alias; return this; } public final List getDataTransforms() { List result = TransformOperationListCopier.copyToBuilder(this.dataTransforms); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setDataTransforms(Collection dataTransforms) { this.dataTransforms = TransformOperationListCopier.copyFromBuilder(dataTransforms); } @Override @Transient public final Builder dataTransforms(Collection dataTransforms) { this.dataTransforms = TransformOperationListCopier.copy(dataTransforms); return this; } @Override @Transient @SafeVarargs public final Builder dataTransforms(TransformOperation... dataTransforms) { dataTransforms(Arrays.asList(dataTransforms)); return this; } @Override @Transient @SafeVarargs public final Builder dataTransforms(Consumer... dataTransforms) { dataTransforms(Stream.of(dataTransforms).map(c -> TransformOperation.builder().applyMutation(c).build()) .collect(Collectors.toList())); return this; } public final LogicalTableSource.Builder getSource() { return source != null ? source.toBuilder() : null; } public final void setSource(LogicalTableSource.BuilderImpl source) { this.source = source != null ? source.build() : null; } @Override @Transient public final Builder source(LogicalTableSource source) { this.source = source; return this; } @Override public LogicalTable build() { return new LogicalTable(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy