blob: ac2e05eca8fa2807ef9d78ff72079eea2e0cf54d [file] [log] [blame]
pierventre30368ab2021-02-24 23:23:22 +01001/*
2 * Copyright 2021-present Open Networking Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.segmentrouting.policy.api;
17
18import java.util.Objects;
19
20import static com.google.common.base.MoreObjects.toStringHelper;
21
22/**
23 * Implementation of the drop policy.
24 */
25public final class DropPolicy extends AbstractPolicy {
26 /**
27 * Builds up a DROP policy.
28 */
29 public DropPolicy() {
30 super(PolicyType.DROP);
31 policyId = computePolicyId();
32 }
33
34 @Override
35 protected PolicyId computePolicyId() {
36 return PolicyId.of(policyType().name());
37 }
38
39 @Override
40 public boolean equals(final Object obj) {
41 if (this == obj) {
42 return true;
43 }
44 if (!(obj instanceof DropPolicy)) {
45 return false;
46 }
47 final DropPolicy other = (DropPolicy) obj;
48 return Objects.equals(policyType(), other.policyType()) &&
49 Objects.equals(policyId(), other.policyId());
50 }
51
52 @Override
53 public int hashCode() {
54 return Objects.hash(policyId(), policyType());
55 }
56
57 @Override
58 public String toString() {
59 return toStringHelper(this)
60 .add("policyId", policyId())
61 .add("policyType", policyType())
62 .toString();
63 }
64}