301d8cd6880248de4734684cb95ffbbfbf992cf3
[yangtools.git] / yang / yang-parser-spi / src / main / java / org / opendaylight / yangtools / yang / parser / spi / meta / EffectiveSchemaTreeStatementState.java
1 /*
2  * Copyright (c) 2021 PANTHEON.tech, s.r.o. 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.yangtools.yang.parser.spi.meta;
9
10 import com.google.common.annotations.Beta;
11 import com.google.common.base.MoreObjects.ToStringHelper;
12 import org.eclipse.jdt.annotation.NonNull;
13 import org.opendaylight.yangtools.concepts.Immutable;
14
15 @Beta
16 public final class EffectiveSchemaTreeStatementState extends EffectiveStatementState {
17     private final int flags;
18
19     public EffectiveSchemaTreeStatementState(final @NonNull Immutable identity, final int flags) {
20         super(identity);
21         this.flags = flags;
22     }
23
24     @Override
25     public int hashCode() {
26         return identity().hashCode() * 31 + Integer.hashCode(flags);
27     }
28
29     @Override
30     public boolean equals(final Object obj) {
31         if (this == obj) {
32             return true;
33         }
34         if (!(obj instanceof EffectiveSchemaTreeStatementState)) {
35             return false;
36         }
37         final EffectiveSchemaTreeStatementState other = (EffectiveSchemaTreeStatementState) obj;
38         return flags == other.flags && identity().equals(other.identity());
39     }
40
41     @Override
42     protected ToStringHelper addToStringAttributes(final ToStringHelper helper) {
43         return super.addToStringAttributes(helper).add("flags", flags);
44     }
45 }