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

software.amazon.awssdk.services.iot.model.TopicRule Maven / Gradle / Ivy

Go to download

The AWS Java SDK for AWS Iot Service module holds the client classes that are used for communicating with AWS IoT Service

There is a newer version: 2.30.1
Show newest version
/*
 * 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.iot.model;

import java.io.Serializable;
import java.time.Instant;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
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;

/**
 * 

* Describes a rule. *

*/ @Generated("software.amazon.awssdk:codegen") public final class TopicRule implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField RULE_NAME_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("ruleName").getter(getter(TopicRule::ruleName)).setter(setter(Builder::ruleName)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ruleName").build()).build(); private static final SdkField SQL_FIELD = SdkField. builder(MarshallingType.STRING).memberName("sql") .getter(getter(TopicRule::sql)).setter(setter(Builder::sql)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("sql").build()).build(); private static final SdkField DESCRIPTION_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("description").getter(getter(TopicRule::description)).setter(setter(Builder::description)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("description").build()).build(); private static final SdkField CREATED_AT_FIELD = SdkField. builder(MarshallingType.INSTANT) .memberName("createdAt").getter(getter(TopicRule::createdAt)).setter(setter(Builder::createdAt)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("createdAt").build()).build(); private static final SdkField> ACTIONS_FIELD = SdkField .> builder(MarshallingType.LIST) .memberName("actions") .getter(getter(TopicRule::actions)) .setter(setter(Builder::actions)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("actions").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField. builder(MarshallingType.SDK_POJO) .constructor(Action::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()).build()).build(); private static final SdkField RULE_DISABLED_FIELD = SdkField. builder(MarshallingType.BOOLEAN) .memberName("ruleDisabled").getter(getter(TopicRule::ruleDisabled)).setter(setter(Builder::ruleDisabled)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ruleDisabled").build()).build(); private static final SdkField AWS_IOT_SQL_VERSION_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("awsIotSqlVersion").getter(getter(TopicRule::awsIotSqlVersion)).setter(setter(Builder::awsIotSqlVersion)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("awsIotSqlVersion").build()).build(); private static final SdkField ERROR_ACTION_FIELD = SdkField. builder(MarshallingType.SDK_POJO) .memberName("errorAction").getter(getter(TopicRule::errorAction)).setter(setter(Builder::errorAction)) .constructor(Action::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("errorAction").build()).build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(RULE_NAME_FIELD, SQL_FIELD, DESCRIPTION_FIELD, CREATED_AT_FIELD, ACTIONS_FIELD, RULE_DISABLED_FIELD, AWS_IOT_SQL_VERSION_FIELD, ERROR_ACTION_FIELD)); private static final Map> SDK_NAME_TO_FIELD = memberNameToFieldInitializer(); private static final long serialVersionUID = 1L; private final String ruleName; private final String sql; private final String description; private final Instant createdAt; private final List actions; private final Boolean ruleDisabled; private final String awsIotSqlVersion; private final Action errorAction; private TopicRule(BuilderImpl builder) { this.ruleName = builder.ruleName; this.sql = builder.sql; this.description = builder.description; this.createdAt = builder.createdAt; this.actions = builder.actions; this.ruleDisabled = builder.ruleDisabled; this.awsIotSqlVersion = builder.awsIotSqlVersion; this.errorAction = builder.errorAction; } /** *

* The name of the rule. *

* * @return The name of the rule. */ public final String ruleName() { return ruleName; } /** *

* The SQL statement used to query the topic. When using a SQL query with multiple lines, be sure to escape the * newline characters. *

* * @return The SQL statement used to query the topic. When using a SQL query with multiple lines, be sure to escape * the newline characters. */ public final String sql() { return sql; } /** *

* The description of the rule. *

* * @return The description of the rule. */ public final String description() { return description; } /** *

* The date and time the rule was created. *

* * @return The date and time the rule was created. */ public final Instant createdAt() { return createdAt; } /** * For responses, this returns true if the service returned a value for the Actions 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 hasActions() { return actions != null && !(actions instanceof SdkAutoConstructList); } /** *

* The actions associated with the rule. *

*

* 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 #hasActions} method. *

* * @return The actions associated with the rule. */ public final List actions() { return actions; } /** *

* Specifies whether the rule is disabled. *

* * @return Specifies whether the rule is disabled. */ public final Boolean ruleDisabled() { return ruleDisabled; } /** *

* The version of the SQL rules engine to use when evaluating the rule. *

* * @return The version of the SQL rules engine to use when evaluating the rule. */ public final String awsIotSqlVersion() { return awsIotSqlVersion; } /** *

* The action to perform when an error occurs. *

* * @return The action to perform when an error occurs. */ public final Action errorAction() { return errorAction; } @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(ruleName()); hashCode = 31 * hashCode + Objects.hashCode(sql()); hashCode = 31 * hashCode + Objects.hashCode(description()); hashCode = 31 * hashCode + Objects.hashCode(createdAt()); hashCode = 31 * hashCode + Objects.hashCode(hasActions() ? actions() : null); hashCode = 31 * hashCode + Objects.hashCode(ruleDisabled()); hashCode = 31 * hashCode + Objects.hashCode(awsIotSqlVersion()); hashCode = 31 * hashCode + Objects.hashCode(errorAction()); 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 TopicRule)) { return false; } TopicRule other = (TopicRule) obj; return Objects.equals(ruleName(), other.ruleName()) && Objects.equals(sql(), other.sql()) && Objects.equals(description(), other.description()) && Objects.equals(createdAt(), other.createdAt()) && hasActions() == other.hasActions() && Objects.equals(actions(), other.actions()) && Objects.equals(ruleDisabled(), other.ruleDisabled()) && Objects.equals(awsIotSqlVersion(), other.awsIotSqlVersion()) && Objects.equals(errorAction(), other.errorAction()); } /** * 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("TopicRule").add("RuleName", ruleName()).add("Sql", sql()).add("Description", description()) .add("CreatedAt", createdAt()).add("Actions", hasActions() ? actions() : null) .add("RuleDisabled", ruleDisabled()).add("AwsIotSqlVersion", awsIotSqlVersion()) .add("ErrorAction", errorAction()).build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "ruleName": return Optional.ofNullable(clazz.cast(ruleName())); case "sql": return Optional.ofNullable(clazz.cast(sql())); case "description": return Optional.ofNullable(clazz.cast(description())); case "createdAt": return Optional.ofNullable(clazz.cast(createdAt())); case "actions": return Optional.ofNullable(clazz.cast(actions())); case "ruleDisabled": return Optional.ofNullable(clazz.cast(ruleDisabled())); case "awsIotSqlVersion": return Optional.ofNullable(clazz.cast(awsIotSqlVersion())); case "errorAction": return Optional.ofNullable(clazz.cast(errorAction())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } @Override public final Map> sdkFieldNameToField() { return SDK_NAME_TO_FIELD; } private static Map> memberNameToFieldInitializer() { Map> map = new HashMap<>(); map.put("ruleName", RULE_NAME_FIELD); map.put("sql", SQL_FIELD); map.put("description", DESCRIPTION_FIELD); map.put("createdAt", CREATED_AT_FIELD); map.put("actions", ACTIONS_FIELD); map.put("ruleDisabled", RULE_DISABLED_FIELD); map.put("awsIotSqlVersion", AWS_IOT_SQL_VERSION_FIELD); map.put("errorAction", ERROR_ACTION_FIELD); return Collections.unmodifiableMap(map); } private static Function getter(Function g) { return obj -> g.apply((TopicRule) 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 rule. *

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

* The SQL statement used to query the topic. When using a SQL query with multiple lines, be sure to escape the * newline characters. *

* * @param sql * The SQL statement used to query the topic. When using a SQL query with multiple lines, be sure to * escape the newline characters. * @return Returns a reference to this object so that method calls can be chained together. */ Builder sql(String sql); /** *

* The description of the rule. *

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

* The date and time the rule was created. *

* * @param createdAt * The date and time the rule was created. * @return Returns a reference to this object so that method calls can be chained together. */ Builder createdAt(Instant createdAt); /** *

* The actions associated with the rule. *

* * @param actions * The actions associated with the rule. * @return Returns a reference to this object so that method calls can be chained together. */ Builder actions(Collection actions); /** *

* The actions associated with the rule. *

* * @param actions * The actions associated with the rule. * @return Returns a reference to this object so that method calls can be chained together. */ Builder actions(Action... actions); /** *

* The actions associated with the rule. *

* This is a convenience method that creates an instance of the * {@link software.amazon.awssdk.services.iot.model.Action.Builder} avoiding the need to create one manually via * {@link software.amazon.awssdk.services.iot.model.Action#builder()}. * *

* When the {@link Consumer} completes, {@link software.amazon.awssdk.services.iot.model.Action.Builder#build()} * is called immediately and its result is passed to {@link #actions(List)}. * * @param actions * a consumer that will call methods on {@link software.amazon.awssdk.services.iot.model.Action.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #actions(java.util.Collection) */ Builder actions(Consumer... actions); /** *

* Specifies whether the rule is disabled. *

* * @param ruleDisabled * Specifies whether the rule is disabled. * @return Returns a reference to this object so that method calls can be chained together. */ Builder ruleDisabled(Boolean ruleDisabled); /** *

* The version of the SQL rules engine to use when evaluating the rule. *

* * @param awsIotSqlVersion * The version of the SQL rules engine to use when evaluating the rule. * @return Returns a reference to this object so that method calls can be chained together. */ Builder awsIotSqlVersion(String awsIotSqlVersion); /** *

* The action to perform when an error occurs. *

* * @param errorAction * The action to perform when an error occurs. * @return Returns a reference to this object so that method calls can be chained together. */ Builder errorAction(Action errorAction); /** *

* The action to perform when an error occurs. *

* This is a convenience method that creates an instance of the {@link Action.Builder} avoiding the need to * create one manually via {@link Action#builder()}. * *

* When the {@link Consumer} completes, {@link Action.Builder#build()} is called immediately and its result is * passed to {@link #errorAction(Action)}. * * @param errorAction * a consumer that will call methods on {@link Action.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #errorAction(Action) */ default Builder errorAction(Consumer errorAction) { return errorAction(Action.builder().applyMutation(errorAction).build()); } } static final class BuilderImpl implements Builder { private String ruleName; private String sql; private String description; private Instant createdAt; private List actions = DefaultSdkAutoConstructList.getInstance(); private Boolean ruleDisabled; private String awsIotSqlVersion; private Action errorAction; private BuilderImpl() { } private BuilderImpl(TopicRule model) { ruleName(model.ruleName); sql(model.sql); description(model.description); createdAt(model.createdAt); actions(model.actions); ruleDisabled(model.ruleDisabled); awsIotSqlVersion(model.awsIotSqlVersion); errorAction(model.errorAction); } public final String getRuleName() { return ruleName; } public final void setRuleName(String ruleName) { this.ruleName = ruleName; } @Override public final Builder ruleName(String ruleName) { this.ruleName = ruleName; return this; } public final String getSql() { return sql; } public final void setSql(String sql) { this.sql = sql; } @Override public final Builder sql(String sql) { this.sql = sql; return this; } public final String getDescription() { return description; } public final void setDescription(String description) { this.description = description; } @Override public final Builder description(String description) { this.description = description; return this; } public final Instant getCreatedAt() { return createdAt; } public final void setCreatedAt(Instant createdAt) { this.createdAt = createdAt; } @Override public final Builder createdAt(Instant createdAt) { this.createdAt = createdAt; return this; } public final List getActions() { List result = ActionListCopier.copyToBuilder(this.actions); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setActions(Collection actions) { this.actions = ActionListCopier.copyFromBuilder(actions); } @Override public final Builder actions(Collection actions) { this.actions = ActionListCopier.copy(actions); return this; } @Override @SafeVarargs public final Builder actions(Action... actions) { actions(Arrays.asList(actions)); return this; } @Override @SafeVarargs public final Builder actions(Consumer... actions) { actions(Stream.of(actions).map(c -> Action.builder().applyMutation(c).build()).collect(Collectors.toList())); return this; } public final Boolean getRuleDisabled() { return ruleDisabled; } public final void setRuleDisabled(Boolean ruleDisabled) { this.ruleDisabled = ruleDisabled; } @Override public final Builder ruleDisabled(Boolean ruleDisabled) { this.ruleDisabled = ruleDisabled; return this; } public final String getAwsIotSqlVersion() { return awsIotSqlVersion; } public final void setAwsIotSqlVersion(String awsIotSqlVersion) { this.awsIotSqlVersion = awsIotSqlVersion; } @Override public final Builder awsIotSqlVersion(String awsIotSqlVersion) { this.awsIotSqlVersion = awsIotSqlVersion; return this; } public final Action.Builder getErrorAction() { return errorAction != null ? errorAction.toBuilder() : null; } public final void setErrorAction(Action.BuilderImpl errorAction) { this.errorAction = errorAction != null ? errorAction.build() : null; } @Override public final Builder errorAction(Action errorAction) { this.errorAction = errorAction; return this; } @Override public TopicRule build() { return new TopicRule(this); } @Override public List> sdkFields() { return SDK_FIELDS; } @Override public Map> sdkFieldNameToField() { return SDK_NAME_TO_FIELD; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy