
software.amazon.awssdk.services.iotthingsgraph.model.SearchEntitiesRequest 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.iotthingsgraph.model;
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.awscore.AwsRequestOverrideConfiguration;
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;
/**
*/
@Generated("software.amazon.awssdk:codegen")
public final class SearchEntitiesRequest extends IoTThingsGraphRequest implements
ToCopyableBuilder {
private static final SdkField> ENTITY_TYPES_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("entityTypes")
.getter(getter(SearchEntitiesRequest::entityTypesAsStrings))
.setter(setter(Builder::entityTypesWithStrings))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("entityTypes").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.STRING)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField> FILTERS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("filters")
.getter(getter(SearchEntitiesRequest::filters))
.setter(setter(Builder::filters))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("filters").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(EntityFilter::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField NEXT_TOKEN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("nextToken").getter(getter(SearchEntitiesRequest::nextToken)).setter(setter(Builder::nextToken))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("nextToken").build()).build();
private static final SdkField MAX_RESULTS_FIELD = SdkField. builder(MarshallingType.INTEGER)
.memberName("maxResults").getter(getter(SearchEntitiesRequest::maxResults)).setter(setter(Builder::maxResults))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("maxResults").build()).build();
private static final SdkField NAMESPACE_VERSION_FIELD = SdkField. builder(MarshallingType.LONG)
.memberName("namespaceVersion").getter(getter(SearchEntitiesRequest::namespaceVersion))
.setter(setter(Builder::namespaceVersion))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("namespaceVersion").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ENTITY_TYPES_FIELD,
FILTERS_FIELD, NEXT_TOKEN_FIELD, MAX_RESULTS_FIELD, NAMESPACE_VERSION_FIELD));
private final List entityTypes;
private final List filters;
private final String nextToken;
private final Integer maxResults;
private final Long namespaceVersion;
private SearchEntitiesRequest(BuilderImpl builder) {
super(builder);
this.entityTypes = builder.entityTypes;
this.filters = builder.filters;
this.nextToken = builder.nextToken;
this.maxResults = builder.maxResults;
this.namespaceVersion = builder.namespaceVersion;
}
/**
*
* The entity types for which to search.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* You can use {@link #hasEntityTypes()} to see if a value was sent in this field.
*
*
* @return The entity types for which to search.
*/
public final List entityTypes() {
return EntityTypesCopier.copyStringToEnum(entityTypes);
}
/**
* Returns true if the EntityTypes 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 final boolean hasEntityTypes() {
return entityTypes != null && !(entityTypes instanceof SdkAutoConstructList);
}
/**
*
* The entity types for which to search.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* You can use {@link #hasEntityTypes()} to see if a value was sent in this field.
*
*
* @return The entity types for which to search.
*/
public final List entityTypesAsStrings() {
return entityTypes;
}
/**
* Returns true if the Filters 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 final boolean hasFilters() {
return filters != null && !(filters instanceof SdkAutoConstructList);
}
/**
*
* Optional filter to apply to the search. Valid filters are NAME
NAMESPACE
,
* SEMANTIC_TYPE_PATH
and REFERENCED_ENTITY_ID
. REFERENCED_ENTITY_ID
filters
* on entities that are used by the entity in the result set. For example, you can filter on the ID of a property
* that is used in a state.
*
*
* Multiple filters function as OR criteria in the query. Multiple values passed inside the filter function as AND
* criteria.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* You can use {@link #hasFilters()} to see if a value was sent in this field.
*
*
* @return Optional filter to apply to the search. Valid filters are NAME
NAMESPACE
,
* SEMANTIC_TYPE_PATH
and REFERENCED_ENTITY_ID
. REFERENCED_ENTITY_ID
* filters on entities that are used by the entity in the result set. For example, you can filter on the ID
* of a property that is used in a state.
*
* Multiple filters function as OR criteria in the query. Multiple values passed inside the filter function
* as AND criteria.
*/
public final List filters() {
return filters;
}
/**
*
* The string that specifies the next page of results. Use this when you're paginating results.
*
*
* @return The string that specifies the next page of results. Use this when you're paginating results.
*/
public final String nextToken() {
return nextToken;
}
/**
*
* The maximum number of results to return in the response.
*
*
* @return The maximum number of results to return in the response.
*/
public final Integer maxResults() {
return maxResults;
}
/**
*
* The version of the user's namespace. Defaults to the latest version of the user's namespace.
*
*
* @return The version of the user's namespace. Defaults to the latest version of the user's namespace.
*/
public final Long namespaceVersion() {
return namespaceVersion;
}
@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 + super.hashCode();
hashCode = 31 * hashCode + Objects.hashCode(hasEntityTypes() ? entityTypesAsStrings() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasFilters() ? filters() : null);
hashCode = 31 * hashCode + Objects.hashCode(nextToken());
hashCode = 31 * hashCode + Objects.hashCode(maxResults());
hashCode = 31 * hashCode + Objects.hashCode(namespaceVersion());
return hashCode;
}
@Override
public final boolean equals(Object obj) {
return super.equals(obj) && equalsBySdkFields(obj);
}
@Override
public final boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof SearchEntitiesRequest)) {
return false;
}
SearchEntitiesRequest other = (SearchEntitiesRequest) obj;
return hasEntityTypes() == other.hasEntityTypes() && Objects.equals(entityTypesAsStrings(), other.entityTypesAsStrings())
&& hasFilters() == other.hasFilters() && Objects.equals(filters(), other.filters())
&& Objects.equals(nextToken(), other.nextToken()) && Objects.equals(maxResults(), other.maxResults())
&& Objects.equals(namespaceVersion(), other.namespaceVersion());
}
/**
* 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("SearchEntitiesRequest").add("EntityTypes", hasEntityTypes() ? entityTypesAsStrings() : null)
.add("Filters", hasFilters() ? filters() : null).add("NextToken", nextToken()).add("MaxResults", maxResults())
.add("NamespaceVersion", namespaceVersion()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "entityTypes":
return Optional.ofNullable(clazz.cast(entityTypesAsStrings()));
case "filters":
return Optional.ofNullable(clazz.cast(filters()));
case "nextToken":
return Optional.ofNullable(clazz.cast(nextToken()));
case "maxResults":
return Optional.ofNullable(clazz.cast(maxResults()));
case "namespaceVersion":
return Optional.ofNullable(clazz.cast(namespaceVersion()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function
*
* Multiple filters function as OR criteria in the query. Multiple values passed inside the filter
* function as AND criteria.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder filters(Collection filters);
/**
*
* Optional filter to apply to the search. Valid filters are NAME
NAMESPACE
,
* SEMANTIC_TYPE_PATH
and REFERENCED_ENTITY_ID
. REFERENCED_ENTITY_ID
* filters on entities that are used by the entity in the result set. For example, you can filter on the ID of a
* property that is used in a state.
*
*
* Multiple filters function as OR criteria in the query. Multiple values passed inside the filter function as
* AND criteria.
*
*
* @param filters
* Optional filter to apply to the search. Valid filters are NAME
NAMESPACE
,
* SEMANTIC_TYPE_PATH
and REFERENCED_ENTITY_ID
.
* REFERENCED_ENTITY_ID
filters on entities that are used by the entity in the result set.
* For example, you can filter on the ID of a property that is used in a state.
*
* Multiple filters function as OR criteria in the query. Multiple values passed inside the filter
* function as AND criteria.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder filters(EntityFilter... filters);
/**
*
* Optional filter to apply to the search. Valid filters are NAME
NAMESPACE
,
* SEMANTIC_TYPE_PATH
and REFERENCED_ENTITY_ID
. REFERENCED_ENTITY_ID
* filters on entities that are used by the entity in the result set. For example, you can filter on the ID of a
* property that is used in a state.
*
*
* Multiple filters function as OR criteria in the query. Multiple values passed inside the filter function as
* AND criteria.
*
* 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 #filters(List)}.
*
* @param filters
* 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 #filters(List)
*/
Builder filters(Consumer... filters);
/**
*
* The string that specifies the next page of results. Use this when you're paginating results.
*
*
* @param nextToken
* The string that specifies the next page of results. Use this when you're paginating results.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder nextToken(String nextToken);
/**
*
* The maximum number of results to return in the response.
*
*
* @param maxResults
* The maximum number of results to return in the response.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder maxResults(Integer maxResults);
/**
*
* The version of the user's namespace. Defaults to the latest version of the user's namespace.
*
*
* @param namespaceVersion
* The version of the user's namespace. Defaults to the latest version of the user's namespace.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder namespaceVersion(Long namespaceVersion);
@Override
Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration);
@Override
Builder overrideConfiguration(Consumer builderConsumer);
}
static final class BuilderImpl extends IoTThingsGraphRequest.BuilderImpl implements Builder {
private List entityTypes = DefaultSdkAutoConstructList.getInstance();
private List filters = DefaultSdkAutoConstructList.getInstance();
private String nextToken;
private Integer maxResults;
private Long namespaceVersion;
private BuilderImpl() {
}
private BuilderImpl(SearchEntitiesRequest model) {
super(model);
entityTypesWithStrings(model.entityTypes);
filters(model.filters);
nextToken(model.nextToken);
maxResults(model.maxResults);
namespaceVersion(model.namespaceVersion);
}
public final Collection getEntityTypes() {
if (entityTypes instanceof SdkAutoConstructList) {
return null;
}
return entityTypes;
}
@Override
public final Builder entityTypesWithStrings(Collection entityTypes) {
this.entityTypes = EntityTypesCopier.copy(entityTypes);
return this;
}
@Override
@SafeVarargs
public final Builder entityTypesWithStrings(String... entityTypes) {
entityTypesWithStrings(Arrays.asList(entityTypes));
return this;
}
@Override
public final Builder entityTypes(Collection entityTypes) {
this.entityTypes = EntityTypesCopier.copyEnumToString(entityTypes);
return this;
}
@Override
@SafeVarargs
public final Builder entityTypes(EntityType... entityTypes) {
entityTypes(Arrays.asList(entityTypes));
return this;
}
public final void setEntityTypes(Collection entityTypes) {
this.entityTypes = EntityTypesCopier.copy(entityTypes);
}
public final List getFilters() {
List result = EntityFiltersCopier.copyToBuilder(this.filters);
if (result instanceof SdkAutoConstructList) {
return null;
}
return result;
}
@Override
public final Builder filters(Collection filters) {
this.filters = EntityFiltersCopier.copy(filters);
return this;
}
@Override
@SafeVarargs
public final Builder filters(EntityFilter... filters) {
filters(Arrays.asList(filters));
return this;
}
@Override
@SafeVarargs
public final Builder filters(Consumer... filters) {
filters(Stream.of(filters).map(c -> EntityFilter.builder().applyMutation(c).build()).collect(Collectors.toList()));
return this;
}
public final void setFilters(Collection filters) {
this.filters = EntityFiltersCopier.copyFromBuilder(filters);
}
public final String getNextToken() {
return nextToken;
}
@Override
public final Builder nextToken(String nextToken) {
this.nextToken = nextToken;
return this;
}
public final void setNextToken(String nextToken) {
this.nextToken = nextToken;
}
public final Integer getMaxResults() {
return maxResults;
}
@Override
public final Builder maxResults(Integer maxResults) {
this.maxResults = maxResults;
return this;
}
public final void setMaxResults(Integer maxResults) {
this.maxResults = maxResults;
}
public final Long getNamespaceVersion() {
return namespaceVersion;
}
@Override
public final Builder namespaceVersion(Long namespaceVersion) {
this.namespaceVersion = namespaceVersion;
return this;
}
public final void setNamespaceVersion(Long namespaceVersion) {
this.namespaceVersion = namespaceVersion;
}
@Override
public Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration) {
super.overrideConfiguration(overrideConfiguration);
return this;
}
@Override
public Builder overrideConfiguration(Consumer builderConsumer) {
super.overrideConfiguration(builderConsumer);
return this;
}
@Override
public SearchEntitiesRequest build() {
return new SearchEntitiesRequest(this);
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
}
}