Fix StmtContext.get{Original,PreviousCopy}Ctx() return type
[yangtools.git] / yang / yang-parser-spi / src / main / java / org / opendaylight / yangtools / yang / parser / spi / meta / CopyHistory.java
index 10eb0fa252dee83ab45005fe449642cd034f68e4..5b0e1340dd40a7e96d3b40540ad075cf765ed3ca 100644 (file)
@@ -9,7 +9,10 @@ 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.MoreObjects;
 import com.google.common.base.Verify;
+import java.util.Arrays;
+import java.util.stream.Collectors;
 import org.opendaylight.yangtools.concepts.Immutable;
 
 @Beta
@@ -17,6 +20,7 @@ public final class CopyHistory implements Immutable {
     private static final CopyType[] VALUES = CopyType.values();
 
     private static final CopyHistory[][] CACHE = new CopyHistory[VALUES.length][];
+
     static {
         /*
          * Cache size is dependent on number of items in CopyType, it costs N * 2^N objects.
@@ -113,4 +117,12 @@ public final class CopyHistory implements Immutable {
         final CopyHistory other = (CopyHistory) obj;
         return operations == other.operations && lastOperation == other.lastOperation;
     }
+
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(this).add("lastOperation", getLastOperation())
+                .add("operations", Arrays.stream(VALUES).filter(value -> (value.bit() & operations) != 0)
+                    .collect(Collectors.toList()))
+                .toString();
+    }
 }