com.amazonaws.services.wafv2.model.Filter Maven / Gradle / Ivy
/*
* Copyright 2018-2023 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.wafv2.model;
import java.io.Serializable;
import javax.annotation.Generated;
import com.amazonaws.protocol.StructuredPojo;
import com.amazonaws.protocol.ProtocolMarshaller;
/**
*
* A single logging filter, used in LoggingFilter.
*
*
* @see AWS API Documentation
*/
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class Filter implements Serializable, Cloneable, StructuredPojo {
/**
*
* How to handle logs that satisfy the filter's conditions and requirement.
*
*/
private String behavior;
/**
*
* Logic to apply to the filtering conditions. You can specify that, in order to satisfy the filter, a log must
* match all conditions or must match at least one condition.
*
*/
private String requirement;
/**
*
* Match conditions for the filter.
*
*/
private java.util.List conditions;
/**
*
* How to handle logs that satisfy the filter's conditions and requirement.
*
*
* @param behavior
* How to handle logs that satisfy the filter's conditions and requirement.
* @see FilterBehavior
*/
public void setBehavior(String behavior) {
this.behavior = behavior;
}
/**
*
* How to handle logs that satisfy the filter's conditions and requirement.
*
*
* @return How to handle logs that satisfy the filter's conditions and requirement.
* @see FilterBehavior
*/
public String getBehavior() {
return this.behavior;
}
/**
*
* How to handle logs that satisfy the filter's conditions and requirement.
*
*
* @param behavior
* How to handle logs that satisfy the filter's conditions and requirement.
* @return Returns a reference to this object so that method calls can be chained together.
* @see FilterBehavior
*/
public Filter withBehavior(String behavior) {
setBehavior(behavior);
return this;
}
/**
*
* How to handle logs that satisfy the filter's conditions and requirement.
*
*
* @param behavior
* How to handle logs that satisfy the filter's conditions and requirement.
* @return Returns a reference to this object so that method calls can be chained together.
* @see FilterBehavior
*/
public Filter withBehavior(FilterBehavior behavior) {
this.behavior = behavior.toString();
return this;
}
/**
*
* Logic to apply to the filtering conditions. You can specify that, in order to satisfy the filter, a log must
* match all conditions or must match at least one condition.
*
*
* @param requirement
* Logic to apply to the filtering conditions. You can specify that, in order to satisfy the filter, a log
* must match all conditions or must match at least one condition.
* @see FilterRequirement
*/
public void setRequirement(String requirement) {
this.requirement = requirement;
}
/**
*
* Logic to apply to the filtering conditions. You can specify that, in order to satisfy the filter, a log must
* match all conditions or must match at least one condition.
*
*
* @return Logic to apply to the filtering conditions. You can specify that, in order to satisfy the filter, a log
* must match all conditions or must match at least one condition.
* @see FilterRequirement
*/
public String getRequirement() {
return this.requirement;
}
/**
*
* Logic to apply to the filtering conditions. You can specify that, in order to satisfy the filter, a log must
* match all conditions or must match at least one condition.
*
*
* @param requirement
* Logic to apply to the filtering conditions. You can specify that, in order to satisfy the filter, a log
* must match all conditions or must match at least one condition.
* @return Returns a reference to this object so that method calls can be chained together.
* @see FilterRequirement
*/
public Filter withRequirement(String requirement) {
setRequirement(requirement);
return this;
}
/**
*
* Logic to apply to the filtering conditions. You can specify that, in order to satisfy the filter, a log must
* match all conditions or must match at least one condition.
*
*
* @param requirement
* Logic to apply to the filtering conditions. You can specify that, in order to satisfy the filter, a log
* must match all conditions or must match at least one condition.
* @return Returns a reference to this object so that method calls can be chained together.
* @see FilterRequirement
*/
public Filter withRequirement(FilterRequirement requirement) {
this.requirement = requirement.toString();
return this;
}
/**
*
* Match conditions for the filter.
*
*
* @return Match conditions for the filter.
*/
public java.util.List getConditions() {
return conditions;
}
/**
*
* Match conditions for the filter.
*
*
* @param conditions
* Match conditions for the filter.
*/
public void setConditions(java.util.Collection conditions) {
if (conditions == null) {
this.conditions = null;
return;
}
this.conditions = new java.util.ArrayList(conditions);
}
/**
*
* Match conditions for the filter.
*
*
* NOTE: 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.
*
*
* @param conditions
* Match conditions for the filter.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public Filter withConditions(Condition... conditions) {
if (this.conditions == null) {
setConditions(new java.util.ArrayList(conditions.length));
}
for (Condition ele : conditions) {
this.conditions.add(ele);
}
return this;
}
/**
*
* Match conditions for the filter.
*
*
* @param conditions
* Match conditions for the filter.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public Filter withConditions(java.util.Collection conditions) {
setConditions(conditions);
return this;
}
/**
* 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.
*
* @return A string representation of this object.
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{");
if (getBehavior() != null)
sb.append("Behavior: ").append(getBehavior()).append(",");
if (getRequirement() != null)
sb.append("Requirement: ").append(getRequirement()).append(",");
if (getConditions() != null)
sb.append("Conditions: ").append(getConditions());
sb.append("}");
return sb.toString();
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (obj instanceof Filter == false)
return false;
Filter other = (Filter) obj;
if (other.getBehavior() == null ^ this.getBehavior() == null)
return false;
if (other.getBehavior() != null && other.getBehavior().equals(this.getBehavior()) == false)
return false;
if (other.getRequirement() == null ^ this.getRequirement() == null)
return false;
if (other.getRequirement() != null && other.getRequirement().equals(this.getRequirement()) == false)
return false;
if (other.getConditions() == null ^ this.getConditions() == null)
return false;
if (other.getConditions() != null && other.getConditions().equals(this.getConditions()) == false)
return false;
return true;
}
@Override
public int hashCode() {
final int prime = 31;
int hashCode = 1;
hashCode = prime * hashCode + ((getBehavior() == null) ? 0 : getBehavior().hashCode());
hashCode = prime * hashCode + ((getRequirement() == null) ? 0 : getRequirement().hashCode());
hashCode = prime * hashCode + ((getConditions() == null) ? 0 : getConditions().hashCode());
return hashCode;
}
@Override
public Filter clone() {
try {
return (Filter) super.clone();
} catch (CloneNotSupportedException e) {
throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone() " + "even though we're Cloneable!", e);
}
}
@com.amazonaws.annotation.SdkInternalApi
@Override
public void marshall(ProtocolMarshaller protocolMarshaller) {
com.amazonaws.services.wafv2.model.transform.FilterMarshaller.getInstance().marshall(this, protocolMarshaller);
}
}