blob: ac2e05eca8fa2807ef9d78ff72079eea2e0cf54d [file] [log] [blame]
/*
* Copyright 2021-present Open Networking Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License 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 org.onosproject.segmentrouting.policy.api;
import java.util.Objects;
import static com.google.common.base.MoreObjects.toStringHelper;
/**
* Implementation of the drop policy.
*/
public final class DropPolicy extends AbstractPolicy {
/**
* Builds up a DROP policy.
*/
public DropPolicy() {
super(PolicyType.DROP);
policyId = computePolicyId();
}
@Override
protected PolicyId computePolicyId() {
return PolicyId.of(policyType().name());
}
@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof DropPolicy)) {
return false;
}
final DropPolicy other = (DropPolicy) obj;
return Objects.equals(policyType(), other.policyType()) &&
Objects.equals(policyId(), other.policyId());
}
@Override
public int hashCode() {
return Objects.hash(policyId(), policyType());
}
@Override
public String toString() {
return toStringHelper(this)
.add("policyId", policyId())
.add("policyType", policyType())
.toString();
}
}