BUG-6972: inline copy operation modifications
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / spi / meta / CopyHistory.java
index eb1e26765b0a2baaca4a147b8d3655aec8599e37..10eb0fa252dee83ab45005fe449642cd034f68e4 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.yangtools.yang.parser.spi.meta;
 
 import com.google.common.annotations.Beta;
+import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Verify;
 import org.opendaylight.yangtools.concepts.Immutable;
 
@@ -42,6 +43,10 @@ public final class CopyHistory implements Immutable {
         return ORIGINAL;
     }
 
+    public static CopyHistory of(final CopyType copyType, final CopyHistory copyHistory) {
+        return ORIGINAL.append(copyType, copyHistory);
+    }
+
     private static CopyHistory[] cacheArray(final CopyType lastOperation) {
         final int ordinal = lastOperation.ordinal();
         CopyHistory[] ret = CACHE[ordinal];
@@ -82,7 +87,8 @@ public final class CopyHistory implements Immutable {
         return VALUES[lastOperation];
     }
 
-    public CopyHistory append(final CopyType typeOfCopy, final CopyHistory toAppend) {
+    @VisibleForTesting
+    CopyHistory append(final CopyType typeOfCopy, final CopyHistory toAppend) {
         final int newOperations = operations | toAppend.operations | typeOfCopy.bit();
         if (newOperations == operations && typeOfCopy.ordinal() == lastOperation) {
             return this;
@@ -93,7 +99,7 @@ public final class CopyHistory implements Immutable {
 
     @Override
     public int hashCode() {
-        return Integer.hashCode(operations | (lastOperation << Short.SIZE));
+        return Integer.hashCode(operations | lastOperation << Short.SIZE);
     }
 
     @Override