Merge "Improve generation of node/link identifiers"
[bgpcep.git] / pcep / spi / src / main / java / org / opendaylight / protocol / pcep / spi / ObjectHeaderImpl.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.protocol.pcep.spi;
9
10 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader;
11 import org.opendaylight.yangtools.yang.binding.DataContainer;
12
13 /**
14  * Header parser for PCEP object
15  */
16 public class ObjectHeaderImpl implements ObjectHeader {
17
18         private final boolean processed;
19         private final boolean ignored;
20
21         public ObjectHeaderImpl(final boolean processed, final boolean ignore) {
22                 this.processed = processed;
23                 this.ignored = ignore;
24         }
25
26         @Override
27         public Class<? extends DataContainer> getImplementedInterface() {
28                 return ObjectHeader.class;
29         }
30
31         @Override
32         public Boolean isIgnore() {
33                 return this.ignored;
34         }
35
36         @Override
37         public Boolean isProcessingRule() {
38                 return this.processed;
39         }
40
41         @Override
42         public String toString() {
43                 final StringBuilder builder = new StringBuilder();
44                 builder.append("ObjectHeader [objClass=");
45                 builder.append(", processed=");
46                 builder.append(this.processed);
47                 builder.append(", ignored=");
48                 builder.append(this.ignored);
49                 builder.append("]");
50                 return builder.toString();
51         }
52
53         @Override
54         public int hashCode() {
55                 final int prime = 31;
56                 int result = 1;
57                 result = prime * result + (this.ignored ? 1231 : 1237);
58                 result = prime * result + (this.processed ? 1231 : 1237);
59                 return result;
60         }
61
62         @Override
63         public boolean equals(final Object obj) {
64                 if (this == obj) {
65                         return true;
66                 }
67                 if (obj == null) {
68                         return false;
69                 }
70                 if (this.getClass() != obj.getClass()) {
71                         return false;
72                 }
73                 final ObjectHeaderImpl other = (ObjectHeaderImpl) obj;
74                 if (this.ignored != other.ignored) {
75                         return false;
76                 }
77                 if (this.processed != other.processed) {
78                         return false;
79                 }
80                 return true;
81         }
82 }