Remove EffectiveStatementStateAware
[yangtools.git] / yang / yang-parser-spi / src / main / java / org / opendaylight / yangtools / yang / parser / spi / meta / EffectiveStatementState.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 static java.util.Objects.requireNonNull;
11
12 import com.google.common.annotations.Beta;
13 import com.google.common.base.MoreObjects;
14 import com.google.common.base.MoreObjects.ToStringHelper;
15 import org.eclipse.jdt.annotation.NonNull;
16 import org.opendaylight.yangtools.concepts.Immutable;
17 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
18
19 /**
20  * Effective summary of a {@link EffectiveStatement}'s implementation state. This class serves as a shared concept
21  * between {@link StatementFactory} and common reactor, driving statement reuse.
22  *
23  * <p>
24  * {@link StatementFactory} implementations are expected to subclass {@link EffectiveStatementState}, adding whatever
25  * additional state is needed and implement {@link #hashCode()} and {@link #equals(Object)} accordingly.
26  */
27 @Beta
28 public abstract class EffectiveStatementState implements Immutable {
29     private final @NonNull Immutable identity;
30
31     protected EffectiveStatementState(final @NonNull Immutable identity) {
32         this.identity = requireNonNull(identity);
33     }
34
35     protected final @NonNull Immutable identity() {
36         return identity;
37     }
38
39     @Override
40     public abstract int hashCode();
41
42     @Override
43     public abstract boolean equals(Object obj);
44
45     @Override
46     public final String toString() {
47         return addToStringAttributes(MoreObjects.toStringHelper(this)).toString();
48     }
49
50     protected @NonNull ToStringHelper addToStringAttributes(final @NonNull ToStringHelper helper) {
51         return helper.add("identity", identity);
52     }
53 }