X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=yang%2Fyang-parser-spi%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fparser%2Fspi%2Fmeta%2FModelProcessingPhase.java;h=196f3ee86f0380e810a79a2ef9a4929c42e394e7;hb=f271abeab81db4ae7808d5824b16dcf289023fc1;hp=918163148970d5b6086882f3a5598a0713471589;hpb=dfafad2e9bd41a21d8cc34e396916a1c4b833221;p=yangtools.git diff --git a/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/ModelProcessingPhase.java b/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/ModelProcessingPhase.java index 9181631489..196f3ee86f 100644 --- a/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/ModelProcessingPhase.java +++ b/yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/ModelProcessingPhase.java @@ -7,14 +7,15 @@ */ package org.opendaylight.yangtools.yang.parser.spi.meta; +import static java.util.Objects.requireNonNull; + import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; @NonNullByDefault -@SuppressFBWarnings("NP_NULL_PARAM_DEREF_NONVIRTUAL") public enum ModelProcessingPhase { - INIT(null), + INIT(), /** * Preliminary cross-source relationship resolution phase which collects available module names and module @@ -41,11 +42,34 @@ public enum ModelProcessingPhase { private final @Nullable ModelProcessingPhase previousPhase; - ModelProcessingPhase(final @Nullable ModelProcessingPhase previous) { - this.previousPhase = previous; + @SuppressFBWarnings(value = "NP_STORE_INTO_NONNULL_FIELD", + justification = "https://github.com/spotbugs/spotbugs/issues/743") + ModelProcessingPhase() { + previousPhase = null; + } + + ModelProcessingPhase(final ModelProcessingPhase previousPhase) { + this.previousPhase = requireNonNull(previousPhase); } + /** + * Return the preceding phase, or null if this phase is the first one. + * + * @return Preceding phase, if there is one + */ public @Nullable ModelProcessingPhase getPreviousPhase() { return previousPhase; } + + /** + * Determine whether this processing phase is implied to have completed by completion of some other phase. + * Algebraically this means that other is not null and is either this phase or its {@link #getPreviousPhase()} chain + * contains this phase. + * + * @param other Other phase + * @return True if this phase completes no later than specified phase. + */ + public boolean isCompletedBy(final @Nullable ModelProcessingPhase other) { + return other != null && ordinal() <= other.ordinal(); + } }