2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.yangtools.yang.parser.spi.meta;
10 import static java.util.Objects.requireNonNull;
12 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
13 import org.eclipse.jdt.annotation.NonNullByDefault;
14 import org.eclipse.jdt.annotation.Nullable;
17 public enum ModelProcessingPhase {
21 * Preliminary cross-source relationship resolution phase which collects available module names and module
22 * namespaces. It is necessary in order to correct resolution of unknown statements used in linkage phase (e.g.
23 * semantic version of yang modules).
25 SOURCE_PRE_LINKAGE(INIT),
28 * Cross-source relationship resolution phase.
31 * In this phase of processing only statements which affects cross-source relationship (e.g. imports / includes)
35 * At end of this phase all source related contexts should be bind to their imports and includes to allow
36 * visibility of custom defined statements in subsequent phases.
38 SOURCE_LINKAGE(SOURCE_PRE_LINKAGE),
39 STATEMENT_DEFINITION(SOURCE_LINKAGE),
40 FULL_DECLARATION(STATEMENT_DEFINITION),
41 EFFECTIVE_MODEL(FULL_DECLARATION);
43 private final @Nullable ModelProcessingPhase previousPhase;
45 @SuppressFBWarnings(value = "NP_STORE_INTO_NONNULL_FIELD",
46 justification = "https://github.com/spotbugs/spotbugs/issues/743")
47 ModelProcessingPhase() {
51 ModelProcessingPhase(final ModelProcessingPhase previousPhase) {
52 this.previousPhase = requireNonNull(previousPhase);
56 * Return the preceding phase, or null if this phase is the first one.
58 * @return Preceding phase, if there is one
60 public @Nullable ModelProcessingPhase getPreviousPhase() {
65 * Determine whether this processing phase is implied to have completed by completion of some other phase.
66 * Algebraically this means that other is not null and is either this phase or its {@link #getPreviousPhase()} chain
67 * contains this phase.
69 * @param other Other phase
70 * @return True if this phase completes no later than specified phase.
72 public boolean isCompletedBy(final @Nullable ModelProcessingPhase other) {
73 return other != null && ordinal() <= other.ordinal();