/*
* Copyright 2012-2017 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 com.amazonaws.services.elasticloadbalancingv2.model;
import java.io.Serializable;
import javax.annotation.Generated;
/**
* <p>
* Information about a rule.
* </p>
*
* @see <a href="http://docs.aws.amazon.com/goto/WebAPI/elasticloadbalancingv2-2015-12-01/Rule" target="_top">AWS API
* Documentation</a>
*/
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class Rule implements Serializable, Cloneable {
/**
* <p>
* The Amazon Resource Name (ARN) of the rule.
* </p>
*/
private String ruleArn;
/**
* <p>
* The priority.
* </p>
*/
private String priority;
/**
* <p>
* The conditions.
* </p>
*/
private java.util.List<RuleCondition> conditions;
/**
* <p>
* The actions.
* </p>
*/
private java.util.List<Action> actions;
/**
* <p>
* Indicates whether this is the default rule.
* </p>
*/
private Boolean isDefault;
/**
* <p>
* The Amazon Resource Name (ARN) of the rule.
* </p>
*
* @param ruleArn
* The Amazon Resource Name (ARN) of the rule.
*/
public void setRuleArn(String ruleArn) {
this.ruleArn = ruleArn;
}
/**
* <p>
* The Amazon Resource Name (ARN) of the rule.
* </p>
*
* @return The Amazon Resource Name (ARN) of the rule.
*/
public String getRuleArn() {
return this.ruleArn;
}
/**
* <p>
* The Amazon Resource Name (ARN) of the rule.
* </p>
*
* @param ruleArn
* The Amazon Resource Name (ARN) of the rule.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public Rule withRuleArn(String ruleArn) {
setRuleArn(ruleArn);
return this;
}
/**
* <p>
* The priority.
* </p>
*
* @param priority
* The priority.
*/
public void setPriority(String priority) {
this.priority = priority;
}
/**
* <p>
* The priority.
* </p>
*
* @return The priority.
*/
public String getPriority() {
return this.priority;
}
/**
* <p>
* The priority.
* </p>
*
* @param priority
* The priority.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public Rule withPriority(String priority) {
setPriority(priority);
return this;
}
/**
* <p>
* The conditions.
* </p>
*
* @return The conditions.
*/
public java.util.List<RuleCondition> getConditions() {
return conditions;
}
/**
* <p>
* The conditions.
* </p>
*
* @param conditions
* The conditions.
*/
public void setConditions(java.util.Collection<RuleCondition> conditions) {
if (conditions == null) {
this.conditions = null;
return;
}
this.conditions = new java.util.ArrayList<RuleCondition>(conditions);
}
/**
* <p>
* The conditions.
* </p>
* <p>
* <b>NOTE:</b> This method appends the values to the existing list (if any). Use
* {@link #setConditions(java.util.Collection)} or {@link #withConditions(java.util.Collection)} if you want to
* override the existing values.
* </p>
*
* @param conditions
* The conditions.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public Rule withConditions(RuleCondition... conditions) {
if (this.conditions == null) {
setConditions(new java.util.ArrayList<RuleCondition>(conditions.length));
}
for (RuleCondition ele : conditions) {
this.conditions.add(ele);
}
return this;
}
/**
* <p>
* The conditions.
* </p>
*
* @param conditions
* The conditions.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public Rule withConditions(java.util.Collection<RuleCondition> conditions) {
setConditions(conditions);
return this;
}
/**
* <p>
* The actions.
* </p>
*
* @return The actions.
*/
public java.util.List<Action> getActions() {
return actions;
}
/**
* <p>
* The actions.
* </p>
*
* @param actions
* The actions.
*/
public void setActions(java.util.Collection<Action> actions) {
if (actions == null) {
this.actions = null;
return;
}
this.actions = new java.util.ArrayList<Action>(actions);
}
/**
* <p>
* The actions.
* </p>
* <p>
* <b>NOTE:</b> This method appends the values to the existing list (if any). Use
* {@link #setActions(java.util.Collection)} or {@link #withActions(java.util.Collection)} if you want to override
* the existing values.
* </p>
*
* @param actions
* The actions.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public Rule withActions(Action... actions) {
if (this.actions == null) {
setActions(new java.util.ArrayList<Action>(actions.length));
}
for (Action ele : actions) {
this.actions.add(ele);
}
return this;
}
/**
* <p>
* The actions.
* </p>
*
* @param actions
* The actions.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public Rule withActions(java.util.Collection<Action> actions) {
setActions(actions);
return this;
}
/**
* <p>
* Indicates whether this is the default rule.
* </p>
*
* @param isDefault
* Indicates whether this is the default rule.
*/
public void setIsDefault(Boolean isDefault) {
this.isDefault = isDefault;
}
/**
* <p>
* Indicates whether this is the default rule.
* </p>
*
* @return Indicates whether this is the default rule.
*/
public Boolean getIsDefault() {
return this.isDefault;
}
/**
* <p>
* Indicates whether this is the default rule.
* </p>
*
* @param isDefault
* Indicates whether this is the default rule.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public Rule withIsDefault(Boolean isDefault) {
setIsDefault(isDefault);
return this;
}
/**
* <p>
* Indicates whether this is the default rule.
* </p>
*
* @return Indicates whether this is the default rule.
*/
public Boolean isDefault() {
return this.isDefault;
}
/**
* Returns a string representation of this object; useful for testing and debugging.
*
* @return A string representation of this object.
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{");
if (getRuleArn() != null)
sb.append("RuleArn: ").append(getRuleArn()).append(",");
if (getPriority() != null)
sb.append("Priority: ").append(getPriority()).append(",");
if (getConditions() != null)
sb.append("Conditions: ").append(getConditions()).append(",");
if (getActions() != null)
sb.append("Actions: ").append(getActions()).append(",");
if (getIsDefault() != null)
sb.append("IsDefault: ").append(getIsDefault());
sb.append("}");
return sb.toString();
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (obj instanceof Rule == false)
return false;
Rule other = (Rule) obj;
if (other.getRuleArn() == null ^ this.getRuleArn() == null)
return false;
if (other.getRuleArn() != null && other.getRuleArn().equals(this.getRuleArn()) == false)
return false;
if (other.getPriority() == null ^ this.getPriority() == null)
return false;
if (other.getPriority() != null && other.getPriority().equals(this.getPriority()) == false)
return false;
if (other.getConditions() == null ^ this.getConditions() == null)
return false;
if (other.getConditions() != null && other.getConditions().equals(this.getConditions()) == false)
return false;
if (other.getActions() == null ^ this.getActions() == null)
return false;
if (other.getActions() != null && other.getActions().equals(this.getActions()) == false)
return false;
if (other.getIsDefault() == null ^ this.getIsDefault() == null)
return false;
if (other.getIsDefault() != null && other.getIsDefault().equals(this.getIsDefault()) == false)
return false;
return true;
}
@Override
public int hashCode() {
final int prime = 31;
int hashCode = 1;
hashCode = prime * hashCode + ((getRuleArn() == null) ? 0 : getRuleArn().hashCode());
hashCode = prime * hashCode + ((getPriority() == null) ? 0 : getPriority().hashCode());
hashCode = prime * hashCode + ((getConditions() == null) ? 0 : getConditions().hashCode());
hashCode = prime * hashCode + ((getActions() == null) ? 0 : getActions().hashCode());
hashCode = prime * hashCode + ((getIsDefault() == null) ? 0 : getIsDefault().hashCode());
return hashCode;
}
@Override
public Rule clone() {
try {
return (Rule) super.clone();
} catch (CloneNotSupportedException e) {
throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone() " + "even though we're Cloneable!", e);
}
}
}