ctf: add equals and hashcodes to Declarations
authorMatthew Khouzam <matthew.khouzam@ericsson.com>
Thu, 6 Nov 2014 20:24:16 +0000 (15:24 -0500)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Fri, 28 Nov 2014 18:09:21 +0000 (13:09 -0500)
Change-Id: I15d8030d2f75979012b87caae4dfc08bbda3ee7a
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/36093
Tested-by: Hudson CI
Reviewed-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Tested-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
20 files changed:
org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/types/ArrayDeclaration2Test.java
org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/types/ArrayDefinition2Test.java
org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/types/EnumDeclarationTest.java
org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/types/FloatDeclarationTest.java
org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/types/IntegerDeclarationTest.java
org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/types/SequenceDeclaration2Test.java
org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/types/StringDeclarationTest.java
org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/types/StructDeclarationTest.java
org.eclipse.tracecompass.ctf.core.tests/src/org/eclipse/tracecompass/ctf/core/tests/types/VariantDeclarationTest.java
org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/EnumDeclaration.java
org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/FloatDeclaration.java
org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/IDeclaration.java
org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/IntegerDeclaration.java
org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/StringDeclaration.java
org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/StructDeclaration.java
org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/ctf/core/event/types/VariantDeclaration.java
org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/types/ArrayDeclaration.java
org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/types/SequenceDeclaration.java
org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/types/composite/EventHeaderCompactDeclaration.java
org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/types/composite/EventHeaderLargeDeclaration.java

index 985d2db887cf0f734bcdb7aa78169268774b995b..9e83311025631adf0ed0397b19293627481f1fa5 100644 (file)
@@ -13,6 +13,7 @@ package org.eclipse.tracecompass.ctf.core.tests.types;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
@@ -87,8 +88,6 @@ public class ArrayDeclaration2Test {
         assertNotNull(result);
     }
 
-
-
     /**
      * Run the Declaration getElementType() method test.
      */
@@ -141,4 +140,34 @@ public class ArrayDeclaration2Test {
 
         assertEquals(left, right);
     }
+
+    /**
+     * Test the hashcode
+     */
+    @Test
+    public void hashcodeTest() {
+        assertEquals(2016, fixture.hashCode());
+        assertEquals(new ArrayDeclaration(1, new StringDeclaration()).hashCode(), fixture.hashCode());
+    }
+
+    /**
+     * Test the equals
+     */
+    @Test
+    public void equalsTest() {
+        ArrayDeclaration a = new ArrayDeclaration(1, IntegerDeclaration.INT_32B_DECL);
+        ArrayDeclaration b = new ArrayDeclaration(2, IntegerDeclaration.INT_32B_DECL);
+        ArrayDeclaration c = new ArrayDeclaration(1, new StringDeclaration());
+        ArrayDeclaration d = new ArrayDeclaration(1, IntegerDeclaration.INT_32B_DECL);
+        assertNotEquals(a, null);
+        assertNotEquals(a, new Object());
+        assertNotEquals(a, b);
+        assertNotEquals(a, c);
+        assertEquals(a, d);
+        assertEquals(a, a);
+        assertNotEquals(b, a);
+        assertNotEquals(c, a);
+        assertEquals(d, a);
+        assertEquals(a, a);
+    }
 }
index fef7455881583b6a042693940dbb0947fec9a650..76366c8a1fde0dddcb7ef586c89092b6f4d1c260 100644 (file)
@@ -11,7 +11,7 @@
 
 package org.eclipse.tracecompass.ctf.core.tests.types;
 
-import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.*;
 
 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
@@ -86,7 +86,7 @@ public class ArrayDefinition2Test {
         return temp;
     }
 
-    private ArrayDefinition setUpDeclaration(IDeclaration decl,
+    private ArrayDefinition setUpDeclaration(@NonNull IDeclaration decl,
             @NonNull List<Definition> defs) {
         CompoundDeclaration ad = new ArrayDeclaration(0, decl);
         ArrayDefinition temp = new ArrayDefinition(ad, this.trace, "Testx", defs);
index cce60ef3c502d9782e08aba31b5f8d4a5f4aaa97..cb891cd89df81039a02c269091005970dbd082e1 100644 (file)
@@ -12,6 +12,7 @@
 package org.eclipse.tracecompass.ctf.core.tests.types;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
@@ -120,4 +121,52 @@ public class EnumDeclarationTest {
         String left = "[declaration] enum[";
         assertEquals(left, result.substring(0, left.length()));
     }
+
+    /**
+     * Test the hashcode
+     */
+    @Test
+    public void hashcodeTest() {
+        assertEquals(-709790042, fixture.hashCode());
+        EnumDeclaration a = new EnumDeclaration(IntegerDeclaration.INT_8_DECL);
+        a.add(0, 1, "hello");
+        a.add(2, 3, "kitty");
+        assertEquals(-82535941, a.hashCode());
+        EnumDeclaration b = new EnumDeclaration(IntegerDeclaration.createDeclaration(1, false, 1,
+                ByteOrder.BIG_ENDIAN, Encoding.ASCII, "", 8));
+        assertEquals(b.hashCode(), fixture.hashCode());
+        assertNotEquals(a.hashCode(), fixture.hashCode());
+    }
+
+    /**
+     * Test the equals
+     */
+    @Test
+    public void equalsTest() {
+        EnumDeclaration a = new EnumDeclaration(IntegerDeclaration.INT_8_DECL);
+        EnumDeclaration b = new EnumDeclaration(IntegerDeclaration.INT_8_DECL);
+        b.add(2, 19, "hi");
+        EnumDeclaration c = new EnumDeclaration(IntegerDeclaration.INT_32B_DECL);
+        EnumDeclaration d = new EnumDeclaration(IntegerDeclaration.INT_8_DECL);
+        assertNotEquals(a, null);
+        assertNotEquals(a, new Object());
+        assertNotEquals(a, b);
+        assertNotEquals(a, c);
+        assertNotEquals(b, c);
+        assertEquals(a, d);
+        assertNotEquals(b, a);
+        assertNotEquals(c, a);
+        assertNotEquals(c, b);
+        assertEquals(d, a);
+        a.add(2, 19, "hi");
+        assertEquals(a, a);
+        assertEquals(a, b);
+        assertEquals(b, a);
+        assertNotEquals(a, d);
+        assertNotEquals(d, a);
+        d.add(2, 22, "hi");
+        assertNotEquals(a, d);
+        assertNotEquals(d, a);
+    }
+
 }
index 0bc3d4146afbc1492795598e672c39395b650e42..0ca5ce299454caefa4448af94caf010688204da0 100644 (file)
@@ -12,6 +12,7 @@
 package org.eclipse.tracecompass.ctf.core.tests.types;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
@@ -24,11 +25,10 @@ import org.junit.Test;
 public class FloatDeclarationTest {
     private FloatDeclaration fixture;
 
-
     @Test
     public void ctorTest() {
-        forint i = 1; i < 20; i++) {
-            fixture = new FloatDeclaration(i, 32-i, ByteOrder.nativeOrder(),  0);
+        for (int i = 1; i < 20; i++) {
+            fixture = new FloatDeclaration(i, 32 - i, ByteOrder.nativeOrder(), 0);
             assertNotNull(fixture);
         }
     }
@@ -36,10 +36,10 @@ public class FloatDeclarationTest {
     @Test
     public void getterTest() {
         fixture = new FloatDeclaration(8, 24, ByteOrder.nativeOrder(), 1);
-        assertEquals( fixture.getAlignment(), 1);
-        assertEquals( fixture.getByteOrder(), ByteOrder.nativeOrder());
-        assertEquals( fixture.getExponent(), 8);
-        assertEquals( fixture.getMantissa(), 24);
+        assertEquals(fixture.getAlignment(), 1);
+        assertEquals(fixture.getByteOrder(), ByteOrder.nativeOrder());
+        assertEquals(fixture.getExponent(), 8);
+        assertEquals(fixture.getMantissa(), 24);
     }
 
     @Test
@@ -47,4 +47,44 @@ public class FloatDeclarationTest {
         fixture = new FloatDeclaration(8, 24, ByteOrder.nativeOrder(), 0);
         assertTrue(fixture.toString().contains("float"));
     }
+
+    /**
+     * Test the hashcode
+     */
+    @Test
+    public void hashcodeTest() {
+        FloatDeclaration floatDeclaration = new FloatDeclaration(8, 24, ByteOrder.BIG_ENDIAN, 0);
+        FloatDeclaration a = new FloatDeclaration(8, 24, ByteOrder.BIG_ENDIAN, 0);
+        FloatDeclaration b = new FloatDeclaration(8, 24, ByteOrder.LITTLE_ENDIAN, 0);
+        assertEquals(5106065, floatDeclaration.hashCode());
+        assertEquals(a.hashCode(), floatDeclaration.hashCode());
+        assertNotEquals(b.hashCode(), floatDeclaration.hashCode());
+    }
+
+    /**
+     * Test the equals
+     */
+    @Test
+    public void equalsTest() {
+        FloatDeclaration a = new FloatDeclaration(8, 24, ByteOrder.BIG_ENDIAN, 0);
+        FloatDeclaration b = new FloatDeclaration(8, 24, ByteOrder.LITTLE_ENDIAN, 0);
+        FloatDeclaration c = new FloatDeclaration(8, 24, ByteOrder.BIG_ENDIAN, 8);
+        FloatDeclaration d = new FloatDeclaration(8, 8, ByteOrder.BIG_ENDIAN, 0);
+        FloatDeclaration e = new FloatDeclaration(24, 24, ByteOrder.BIG_ENDIAN, 0);
+        FloatDeclaration f = new FloatDeclaration(8, 24, ByteOrder.BIG_ENDIAN, 0);
+        assertNotEquals(a, null);
+        assertNotEquals(a, new Object());
+        assertNotEquals(a, b);
+        assertNotEquals(a, c);
+        assertNotEquals(a, d);
+        assertNotEquals(b, a);
+        assertNotEquals(c, a);
+        assertNotEquals(d, a);
+        assertNotEquals(e, a);
+        assertNotEquals(a, e);
+
+        assertEquals(a, f);
+        assertEquals(f, a);
+        assertEquals(a, a);
+    }
 }
index 3c5e6b2299ce12a44fcac36bb3752969a9826a54..8b26c5a25aecbddcd9bee978f18d7d3b34988c87 100644 (file)
@@ -13,6 +13,7 @@
 package org.eclipse.tracecompass.ctf.core.tests.types;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertNotNull;
 
 import java.math.BigInteger;
@@ -277,4 +278,48 @@ public class IntegerDeclarationTest {
         IntegerDeclaration unsigned64bit = IntegerDeclaration.createDeclaration(64, false, 1, ByteOrder.BIG_ENDIAN, Encoding.ASCII, "", 32);
         assertEquals(BigInteger.ZERO, unsigned64bit.getMinValue());
     }
+
+    /**
+     * Test the hashcode
+     */
+    @Test
+    public void hashcodeTest() {
+        assertEquals(234767053, IntegerDeclaration.createDeclaration(8, false, 10, ByteOrder.BIG_ENDIAN, Encoding.NONE, "", 8).hashCode());
+    }
+
+    /**
+     * Test the equals
+     */
+    @Test
+    public void equalsTest() {
+        IntegerDeclaration a = IntegerDeclaration.createDeclaration(32, false, 10, ByteOrder.BIG_ENDIAN, Encoding.NONE, "", 32);
+        IntegerDeclaration b = IntegerDeclaration.createDeclaration(8, false, 10, ByteOrder.BIG_ENDIAN, Encoding.NONE, "", 32);
+        IntegerDeclaration c = IntegerDeclaration.createDeclaration(32, true, 10, ByteOrder.BIG_ENDIAN, Encoding.NONE, "", 32);
+        IntegerDeclaration d = IntegerDeclaration.createDeclaration(32, false, 16, ByteOrder.BIG_ENDIAN, Encoding.NONE, "", 32);
+        IntegerDeclaration e = IntegerDeclaration.createDeclaration(32, false, 10, ByteOrder.LITTLE_ENDIAN, Encoding.NONE, "", 32);
+        IntegerDeclaration f = IntegerDeclaration.createDeclaration(32, false, 10, ByteOrder.BIG_ENDIAN, Encoding.UTF8, "", 32);
+        IntegerDeclaration g = IntegerDeclaration.createDeclaration(32, false, 10, ByteOrder.BIG_ENDIAN, Encoding.NONE, "hi", 32);
+        IntegerDeclaration h = IntegerDeclaration.createDeclaration(32, false, 10, ByteOrder.BIG_ENDIAN, Encoding.NONE, "", 16);
+        IntegerDeclaration i = IntegerDeclaration.createDeclaration(32, false, 10, ByteOrder.BIG_ENDIAN, Encoding.NONE, "", 32);
+        assertNotEquals(a, null);
+        assertNotEquals(a, new Object());
+        assertNotEquals(a, b);
+        assertNotEquals(a, c);
+        assertNotEquals(a, d);
+        assertNotEquals(a, e);
+        assertNotEquals(a, f);
+        assertNotEquals(a, g);
+        assertNotEquals(a, h);
+        assertEquals(a, i);
+        assertNotEquals(b, a);
+        assertNotEquals(c, a);
+        assertNotEquals(d, a);
+        assertNotEquals(e, a);
+        assertNotEquals(f, a);
+        assertNotEquals(g, a);
+        assertNotEquals(h, a);
+        assertEquals(i, a);
+        assertEquals(a, a);
+    }
+
 }
\ No newline at end of file
index 9ffed7e93ead1c3267d37fa2e5b9231038dbaa8a..4eaf405f9201161cff97086c91e3191ef66f0be6 100644 (file)
@@ -12,6 +12,7 @@
 package org.eclipse.tracecompass.ctf.core.tests.types;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertNotNull;
 
 import java.nio.ByteBuffer;
@@ -45,17 +46,19 @@ import com.google.common.collect.ImmutableList;
 @SuppressWarnings("javadoc")
 public class SequenceDeclaration2Test {
 
-    @NonNull private static final String FIELD_NAME = "LengthName";
+    @NonNull
+    private static final String FIELD_NAME = "LengthName";
 
     private SequenceDeclaration fixture;
-    @NonNull private BitBuffer input = new BitBuffer();
+    @NonNull
+    private BitBuffer input = new BitBuffer();
 
     @Before
     public void setUp() {
         fixture = new SequenceDeclaration(FIELD_NAME, new StringDeclaration());
         byte array[] = { 't', 'e', 's', 't', '\0', 't', 'h', 'i', 's', '\0' };
         ByteBuffer byb = ByteBuffer.wrap(array);
-        if( byb == null){
+        if (byb == null) {
             throw new IllegalStateException("Failed to allocate memory");
         }
         input = new BitBuffer(byb);
@@ -123,4 +126,40 @@ public class SequenceDeclaration2Test {
         String left = "[declaration] sequence[";
         assertEquals(left, result.substring(0, left.length()));
     }
+
+    /**
+     * Test the hashcode
+     */
+    @Test
+    public void hashcodeTest() {
+        assertEquals(-1140774256, fixture.hashCode());
+        SequenceDeclaration a = new SequenceDeclaration("Hi", IntegerDeclaration.INT_32B_DECL);
+        SequenceDeclaration b = new SequenceDeclaration("Hello", IntegerDeclaration.INT_32B_DECL);
+        SequenceDeclaration c = new SequenceDeclaration("Hi", new StringDeclaration());
+        SequenceDeclaration d = new SequenceDeclaration("Hi", IntegerDeclaration.INT_32B_DECL);
+        assertNotEquals(a.hashCode(), b.hashCode());
+        assertNotEquals(a.hashCode(), c.hashCode());
+        assertEquals(a.hashCode(), d.hashCode());
+    }
+
+    /**
+     * Test the equals
+     */
+    @Test
+    public void equalsTest() {
+        SequenceDeclaration a = new SequenceDeclaration("Hi", IntegerDeclaration.INT_32B_DECL);
+        SequenceDeclaration b = new SequenceDeclaration("Hello", IntegerDeclaration.INT_32B_DECL);
+        SequenceDeclaration c = new SequenceDeclaration("Hi", new StringDeclaration());
+        SequenceDeclaration d = new SequenceDeclaration("Hi", IntegerDeclaration.INT_32B_DECL);
+        assertNotEquals(a, null);
+        assertNotEquals(a, new Object());
+        assertNotEquals(a, b);
+        assertNotEquals(a, c);
+        assertEquals(a, d);
+        assertNotEquals(b, a);
+        assertNotEquals(c, a);
+        assertEquals(d, a);
+        assertEquals(a, a);
+    }
+
 }
index f4f17bedff2e73367c43f22f3e7d3dc117350e54..d723f488ea131f3ea4032bc4a351811af7fd1dd2 100644 (file)
@@ -12,6 +12,7 @@
 package org.eclipse.tracecompass.ctf.core.tests.types;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertNotNull;
 
 import java.nio.ByteBuffer;
@@ -115,4 +116,39 @@ public class StringDeclarationTest {
 
         assertEquals(left, right);
     }
+
+    /**
+     * Test the hashcode
+     */
+    @Test
+    public void hashcodeTest() {
+        assertEquals(32, fixture.hashCode());
+        StringDeclaration a = new StringDeclaration(Encoding.ASCII);
+        StringDeclaration b = new StringDeclaration();
+        StringDeclaration c = new StringDeclaration(Encoding.UTF8);
+        StringDeclaration d = new StringDeclaration(Encoding.ASCII);
+        assertNotEquals(a.hashCode(), b.hashCode());
+        assertNotEquals(a.hashCode(), c.hashCode());
+        assertEquals(a.hashCode(), d.hashCode());
+    }
+
+    /**
+     * Test the equals
+     */
+    @Test
+    public void equalsTest() {
+        StringDeclaration a = new StringDeclaration(Encoding.ASCII);
+        StringDeclaration b = new StringDeclaration();
+        StringDeclaration c = new StringDeclaration(Encoding.UTF8);
+        StringDeclaration d = new StringDeclaration(Encoding.ASCII);
+        assertNotEquals(a, null);
+        assertNotEquals(a, new Object());
+        assertNotEquals(a, b);
+        assertNotEquals(a, c);
+        assertEquals(a, d);
+        assertNotEquals(b, a);
+        assertNotEquals(c, a);
+        assertEquals(d, a);
+        assertEquals(a, a);
+    }
 }
\ No newline at end of file
index a8578b4a94a20b6aefea48c9b0a64b4fe2a0b40b..ca0bf7844eafdaad6b5ff45cc81c40692fa34fd9 100644 (file)
@@ -12,6 +12,7 @@
 package org.eclipse.tracecompass.ctf.core.tests.types;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
@@ -20,6 +21,7 @@ import java.nio.ByteBuffer;
 
 import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
 import org.eclipse.tracecompass.ctf.core.event.types.IDeclaration;
+import org.eclipse.tracecompass.ctf.core.event.types.IntegerDeclaration;
 import org.eclipse.tracecompass.ctf.core.event.types.StringDeclaration;
 import org.eclipse.tracecompass.ctf.core.event.types.StructDeclaration;
 import org.eclipse.tracecompass.ctf.core.event.types.StructDefinition;
@@ -79,7 +81,7 @@ public class StructDeclarationTest {
     public void testCreateDefinition() throws CTFReaderException {
         String fieldName = "";
         ByteBuffer allocate = ByteBuffer.allocate(100);
-        if( allocate == null){
+        if (allocate == null) {
             throw new IllegalStateException("Failed to allocate memory");
         }
         BitBuffer bb = new BitBuffer(allocate);
@@ -138,4 +140,59 @@ public class StructDeclarationTest {
 
         assertEquals("[declaration] struct[", trunc);
     }
+
+    /**
+     * Test the hashcode
+     */
+    @Test
+    public void hashcodeTest() {
+        assertEquals(32, fixture.hashCode());
+        StructDeclaration a = new StructDeclaration(8);
+        fixture.addField("hello", a);
+        a.addField("Time", IntegerDeclaration.INT_32B_DECL);
+        assertEquals(-864123628, fixture.hashCode());
+        StructDeclaration b = new StructDeclaration(8);
+        StructDeclaration c = new StructDeclaration(8);
+        b.addField("hello", c);
+        c.addField("Time", IntegerDeclaration.INT_32B_DECL);
+        assertEquals(b.hashCode(), fixture.hashCode());
+        c.addField("Space", IntegerDeclaration.INT_32L_DECL);
+        assertNotEquals(b.hashCode(), fixture.hashCode());
+    }
+
+    /**
+     * Test the equals
+     */
+    @Test
+    public void equalsTest() {
+        StructDeclaration a = new StructDeclaration(8);
+        StructDeclaration b = new StructDeclaration(16);
+        StructDeclaration c = new StructDeclaration(8);
+        StructDeclaration d = new StructDeclaration(8);
+        StructDeclaration e = new StructDeclaration(8);
+        StructDeclaration f = new StructDeclaration(8);
+        c.addField("hi", new StringDeclaration());
+        assertNotEquals(a, null);
+        assertNotEquals(a, new Object());
+        assertNotEquals(a, b);
+        assertNotEquals(a, c);
+        assertEquals(a, d);
+        assertNotEquals(b, a);
+        assertNotEquals(c, a);
+        assertEquals(d, a);
+        assertEquals(a, a);
+        a.addField("hi", new StringDeclaration());
+        f.addField("hi", new StringDeclaration());
+        e.addField("hello", new StringDeclaration());
+        assertEquals(a, c);
+        assertEquals(c, a);
+        assertNotEquals(a, d);
+        d.addField("hi", IntegerDeclaration.INT_32B_DECL);
+        assertNotEquals(a, d);
+        a.addField("hello", new StringDeclaration());
+        e.addField("hi", new StringDeclaration());
+        f.addField("hello", IntegerDeclaration.INT_32B_DECL);
+        assertNotEquals(a, e);
+        assertNotEquals(a, f);
+    }
 }
index d505ba021a190ca966810093552cf4e9552293fd..b3b0a8d32d3595544f655bc04ac7500c54da68c3 100644 (file)
@@ -12,6 +12,7 @@
 package org.eclipse.tracecompass.ctf.core.tests.types;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assume.assumeTrue;
 
@@ -141,7 +142,7 @@ public class VariantDeclarationTest {
         IDefinitionScope definitionScope = createDefinitionScope();
         String fieldName = "";
         ByteBuffer allocate = ByteBuffer.allocate(100);
-        if( allocate == null){
+        if (allocate == null) {
             throw new IllegalStateException("Failed to allocate memory");
         }
         BitBuffer bb = new BitBuffer(allocate);
@@ -206,4 +207,78 @@ public class VariantDeclarationTest {
 
         assertEquals(left, right);
     }
+
+    /**
+     * Test the hashcode
+     */
+    @Test
+    public void hashcodeTest() {
+        assertEquals(923521, fixture.hashCode());
+        assertEquals(fixture.hashCode(), new VariantDeclaration().hashCode());
+    }
+
+    /**
+     * Test the equals
+     */
+    @Test
+    public void equalsTest() {
+        VariantDeclaration a = new VariantDeclaration();
+        VariantDeclaration b = new VariantDeclaration();
+        b.addField("hi", new StringDeclaration());
+        VariantDeclaration c = new VariantDeclaration();
+        c.addField("hi", new StringDeclaration());
+        VariantDeclaration d = new VariantDeclaration();
+        assertNotEquals(a, null);
+        assertNotEquals(a, new Object());
+        assertNotEquals(a, b);
+        assertNotEquals(a, c);
+        assertEquals(a, d);
+        assertEquals(a, a);
+        assertEquals(b, c);
+        assertNotEquals(b, a);
+        assertNotEquals(c, a);
+        assertEquals(d, a);
+        assertEquals(c, b);
+        b.setTag("hi");
+        assertNotEquals(b, c);
+        c.setTag("Hello");
+        assertNotEquals(b, c);
+        c.setTag("hi");
+        assertEquals(b, c);
+        b.addField("hello", IntegerDeclaration.INT_32B_DECL);
+        d.addField("hello", IntegerDeclaration.INT_32B_DECL);
+        d.addField("hi", new StringDeclaration());
+        d.setTag("hi");
+        assertEquals(b, d);
+        assertEquals(d, b);
+    }
+
+    /**
+     * Test the equals out of order
+     */
+    @Test
+    public void equalsOutOfOrderTest() {
+        VariantDeclaration a = new VariantDeclaration();
+        VariantDeclaration b = new VariantDeclaration();
+        b.addField("hi", new StringDeclaration());
+        b.addField("hello", new VariantDeclaration());
+        a.addField("hello", new VariantDeclaration());
+        a.addField("hi", new StringDeclaration());
+        assertEquals(b, a);
+    }
+
+    /**
+     * Test the equals out of order
+     */
+    @Test
+    public void equalsAddTwiceTest() {
+        VariantDeclaration a = new VariantDeclaration();
+        VariantDeclaration b = new VariantDeclaration();
+        b.addField("hi", new StringDeclaration());
+        a.addField("hi", new StringDeclaration());
+        assertEquals(b, a);
+        b.addField("hi", new VariantDeclaration());
+        assertNotEquals(b, a);
+    }
+
 }
\ No newline at end of file
index 79447f8d99971dfafd757c928b50f689b000c3b3..5cec591dbdc72b9b8b55e7ec93e613536d242e54 100644 (file)
@@ -151,7 +151,7 @@ public final class EnumDeclaration extends Declaration implements ISimpleDatatyp
         public EnumTable() {
         }
 
-        public boolean add(long low, long high, @Nullable String label) {
+        public synchronized boolean add(long low, long high, @Nullable String label) {
             LabelAndRange newRange = new LabelAndRange(low, high, label);
 
             for (LabelAndRange r : ranges) {
@@ -172,7 +172,7 @@ public final class EnumDeclaration extends Declaration implements ISimpleDatatyp
          *            the value to query
          * @return the label corresponding to that value
          */
-        public @Nullable String query(long value) {
+        public synchronized @Nullable String query(long value) {
             for (LabelAndRange r : ranges) {
                 if (r.intersects(value)) {
                     return r.getLabel();
@@ -181,6 +181,39 @@ public final class EnumDeclaration extends Declaration implements ISimpleDatatyp
             return null;
         }
 
+        @Override
+        public synchronized int hashCode() {
+            final int prime = 31;
+            int result = 1;
+            for (LabelAndRange range : ranges) {
+                result = prime * result + range.hashCode();
+            }
+            return result;
+        }
+
+        @Override
+        public synchronized boolean equals(@Nullable Object obj) {
+            if (this == obj) {
+                return true;
+            }
+            if (obj == null) {
+                return false;
+            }
+            if (getClass() != obj.getClass()) {
+                return false;
+            }
+            EnumTable other = (EnumTable) obj;
+            if (ranges.size() != other.ranges.size()) {
+                return false;
+            }
+            for (int i = 0; i < ranges.size(); i++) {
+                if (!ranges.get(i).equals(other.ranges.get(i))) {
+                    return false;
+                }
+            }
+            return true;
+        }
+
     }
 
     private static class LabelAndRange {
@@ -193,8 +226,7 @@ public final class EnumDeclaration extends Declaration implements ISimpleDatatyp
          *
          * @return the label
          */
-        @Nullable
-        public String getLabel() {
+        public @Nullable String getLabel() {
             return fLabel;
         }
 
@@ -212,6 +244,46 @@ public final class EnumDeclaration extends Declaration implements ISimpleDatatyp
             return this.intersects(other.low)
                     || this.intersects(other.high);
         }
+
+        @Override
+        public int hashCode() {
+            final int prime = 31;
+            int result = 1;
+            final String label = fLabel;
+            result = prime * result + ((label == null) ? 0 : label.hashCode());
+            result = prime * result + (int) (high ^ (high >>> 32));
+            result = prime * result + (int) (low ^ (low >>> 32));
+            return result;
+        }
+
+        @Override
+        public boolean equals(@Nullable Object obj) {
+            if (this == obj) {
+                return true;
+            }
+            if (obj == null) {
+                return false;
+            }
+            if (getClass() != obj.getClass()) {
+                return false;
+            }
+            LabelAndRange other = (LabelAndRange) obj;
+            final String label = fLabel;
+            if (label == null) {
+                if (other.fLabel != null) {
+                    return false;
+                }
+            } else if (!label.equals(other.fLabel)) {
+                return false;
+            }
+            if (high != other.high) {
+                return false;
+            }
+            if (low != other.low) {
+                return false;
+            }
+            return true;
+        }
     }
 
     @Override
@@ -220,4 +292,42 @@ public final class EnumDeclaration extends Declaration implements ISimpleDatatyp
         return "[declaration] enum[" + Integer.toHexString(hashCode()) + ']'; //$NON-NLS-1$
     }
 
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = prime + fContainerType.hashCode();
+        for (String label : fLabels) {
+            result = prime * result + label.hashCode();
+        }
+        result = prime * result + fTable.hashCode();
+        return result;
+    }
+
+    @Override
+    public boolean equals(@Nullable Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        EnumDeclaration other = (EnumDeclaration) obj;
+        if (!fContainerType.equals(other.fContainerType)) {
+            return false;
+        }
+        if (fLabels.size() != other.fLabels.size()) {
+            return false;
+        }
+        if (!fLabels.containsAll(other.fLabels)) {
+            return false;
+        }
+        if (!fTable.equals(other.fTable)) {
+            return false;
+        }
+        return true;
+    }
+
 }
index 26ed60f8a2a93f0f5aa968d9e302aaff90be0b65..992e9fef228c10e5911cbb0adbbd30eacc8b8477 100644 (file)
@@ -181,4 +181,43 @@ public final class FloatDeclaration extends Declaration implements ISimpleDataty
         ret *= expPow;
         return ret;
     }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + (int) (fAlignement ^ (fAlignement >>> 32));
+        result = prime * result + (fByteOrder.equals(ByteOrder.BIG_ENDIAN) ? 4321 : 1234);
+        result = prime * result + fExponent;
+        result = prime * result + fMantissa;
+        return result;
+    }
+
+    @Override
+    public boolean equals(@Nullable Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        FloatDeclaration other = (FloatDeclaration) obj;
+        if (fAlignement != other.fAlignement) {
+            return false;
+        }
+        if (!fByteOrder.equals(other.fByteOrder)) {
+            return false;
+        }
+        if (fExponent != other.fExponent) {
+            return false;
+        }
+        if (fMantissa != other.fMantissa) {
+            return false;
+        }
+        return true;
+    }
+
 }
index ab670cc52c9c063a99843ef6c4761a3b1264e27b..feb739690fefdbc11365be292384e413c0235dbd 100644 (file)
@@ -78,4 +78,10 @@ public interface IDeclaration {
      */
     int getMaximumSize();
 
+    @Override
+    public abstract int hashCode();
+
+    @Override
+    public abstract boolean equals(Object other);
+
 }
index 95bc7c8825c9235ea673c26a1c660aad6c3f0176..092850be38d113954dd5ea18f2a168b8a3a20c7e 100644 (file)
@@ -471,4 +471,67 @@ public class IntegerDeclaration extends Declaration implements ISimpleDatatypeDe
         return bits;
     }
 
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + (int) (fAlignment ^ (fAlignment >>> 32));
+        result = prime * result + fBase;
+        result = prime * result + (fByteOrder.equals(ByteOrder.BIG_ENDIAN) ? 4321 : 1234);
+        result = prime * result + (fClock.hashCode());
+        switch (fEncoding) {
+        case ASCII:
+            result = prime * result + 1;
+            break;
+        case NONE:
+            result = prime * result + 2;
+            break;
+        case UTF8:
+            result = prime * result + 3;
+            break;
+        default:
+            result = prime * result + 4;
+            break;
+        }
+        result = prime * result + fLength;
+        result = prime * result + (fSigned ? 1231 : 1237);
+        return result;
+    }
+
+    @Override
+    public boolean equals(@Nullable Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        IntegerDeclaration other = (IntegerDeclaration) obj;
+        if (fAlignment != other.fAlignment) {
+            return false;
+        }
+        if (fBase != other.fBase) {
+            return false;
+        }
+        if (!fByteOrder.equals(other.fByteOrder)) {
+            return false;
+        }
+        if (!fClock.equals(other.fClock)) {
+            return false;
+        }
+        if (fEncoding != other.fEncoding) {
+            return false;
+        }
+        if (fLength != other.fLength) {
+            return false;
+        }
+        if (fSigned != other.fSigned) {
+            return false;
+        }
+        return true;
+    }
+
 }
index f687b7ae2c877cd3bc3dfa84b9c887c2906643f2..086f0705d753e249c216df203e2a11b808765bb9 100644 (file)
@@ -48,7 +48,9 @@ public class StringDeclaration extends Declaration {
 
     /**
      * Generate an encoded string declaration
-     * @param encoding the encoding, utf8 or ascii
+     *
+     * @param encoding
+     *            the encoding, utf8 or ascii
      */
     public StringDeclaration(Encoding encoding) {
         fEncoding = encoding;
@@ -79,6 +81,7 @@ public class StringDeclaration extends Declaration {
     public int getMaximumSize() {
         return Integer.MAX_VALUE;
     }
+
     // ------------------------------------------------------------------------
     // Operations
     // ------------------------------------------------------------------------
@@ -105,10 +108,51 @@ public class StringDeclaration extends Declaration {
         }
         return sb.toString();
     }
+
     @Override
     public String toString() {
         /* Only used for debugging */
         return "[declaration] string[" + Integer.toHexString(hashCode()) + ']'; //$NON-NLS-1$
     }
 
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = prime;
+        if (fEncoding != null) {
+            switch (fEncoding) {
+            case ASCII:
+                result += 1;
+                break;
+            case NONE:
+                result += 2;
+                break;
+            case UTF8:
+                result += 3;
+                break;
+            default:
+                break;
+            }
+        }
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        StringDeclaration other = (StringDeclaration) obj;
+        if (fEncoding != other.fEncoding) {
+            return false;
+        }
+        return true;
+    }
+
 }
index ca73296ec9e3c14a9b08c02f7eaea24467bfa510..a88b26e744a2362b3425b582c83ef07200cb7a3d 100644 (file)
 
 package org.eclipse.tracecompass.ctf.core.event.types;
 
+import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
+import java.util.List;
 import java.util.Map;
+import java.util.Map.Entry;
 
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
@@ -232,7 +235,10 @@ public class StructDeclaration extends Declaration {
     public int hashCode() {
         final int prime = 31;
         int result = 1;
-        result = (prime * result) + fFieldMap.entrySet().hashCode();
+        for (Entry<String, IDeclaration> field : fFieldMap.entrySet()) {
+            result = prime * result + field.getKey().hashCode();
+            result = prime * result + field.getValue().hashCode();
+        }
         result = (prime * result) + (int) (fMaxAlign ^ (fMaxAlign >>> 32));
         return result;
     }
@@ -249,9 +255,30 @@ public class StructDeclaration extends Declaration {
             return false;
         }
         StructDeclaration other = (StructDeclaration) obj;
-        if (!fFieldMap.entrySet().equals(other.fFieldMap.entrySet())) {
+        if (fFieldMap.size() != other.fFieldMap.size()) {
             return false;
         }
+
+        List<String> localFieldNames = new ArrayList<>();
+        localFieldNames.addAll(fFieldMap.keySet());
+
+        List<IDeclaration> localDecs = new ArrayList<>();
+        localDecs.addAll(fFieldMap.values());
+
+        List<String> otherFieldNames = new ArrayList<>();
+        otherFieldNames.addAll(other.fFieldMap.keySet());
+
+        List<IDeclaration> otherDecs = new ArrayList<>();
+        otherDecs.addAll(other.fFieldMap.values());
+
+        //check fields in order
+        for (int i = 0; i < fFieldMap.size(); i++) {
+            if ((!localFieldNames.get(i).equals(otherFieldNames.get(i))) ||
+                    (!otherDecs.get(i).equals(localDecs.get(i)))) {
+                return false;
+            }
+        }
+
         if (fMaxAlign != other.fMaxAlign) {
             return false;
         }
index 618cc5d28339a97c00e9a6807a803fbc1979d2b2..f8c119e23abdd641d466923eb4c4da3c12e437b1 100644 (file)
@@ -16,6 +16,7 @@ import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Map.Entry;
 
 import org.eclipse.tracecompass.ctf.core.event.io.BitBuffer;
 import org.eclipse.tracecompass.ctf.core.event.scope.IDefinitionScope;
@@ -186,4 +187,76 @@ public class VariantDeclaration extends Declaration {
         return "[declaration] variant[" + Integer.toHexString(hashCode()) + ']'; //$NON-NLS-1$
     }
 
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((fDeclarationToPopulate == null) ? 0 : fDeclarationToPopulate.hashCode());
+        if (fFields == null) {
+            result = prime * result;
+        } else {
+            for (Entry<String, IDeclaration> field : fFields.entrySet()) {
+                result = prime * result + field.getValue().hashCode();
+            }
+        }
+        result = prime * result + ((fPrevDefinitionScope == null) ? 0 : fPrevDefinitionScope.hashCode());
+        result = prime * result + ((fTag == null) ? 0 : fTag.hashCode());
+        result = prime * result + ((fTagDef == null) ? 0 : fTagDef.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        VariantDeclaration other = (VariantDeclaration) obj;
+        if (fDeclarationToPopulate == null) {
+            if (other.fDeclarationToPopulate != null) {
+                return false;
+            }
+        } else if (!fDeclarationToPopulate.equals(other.fDeclarationToPopulate)) {
+            return false;
+        }
+        // do not check the order of the fields
+
+        if (fFields == null) {
+            if (other.fFields != null) {
+                return false;
+            }
+        } else {
+            if( !fFields.equals(other.fFields)) {
+                return false;
+            }
+        }
+        if (fPrevDefinitionScope == null) {
+            if (other.fPrevDefinitionScope != null) {
+                return false;
+            }
+        } else if (!fPrevDefinitionScope.equals(other.fPrevDefinitionScope)) {
+            return false;
+        }
+        if (fTag == null) {
+            if (other.fTag != null) {
+                return false;
+            }
+        } else if (!fTag.equals(other.fTag)) {
+            return false;
+        }
+        if (fTagDef == null) {
+            if (other.fTagDef != null) {
+                return false;
+            }
+        } else if (!fTagDef.equals(other.fTagDef)) {
+            return false;
+        }
+        return true;
+    }
+
 }
index 713308bdef881abb61f60ffa3a701eed948a4928..dba627d3fa8e60a581610187436eb45043867075 100644 (file)
@@ -58,7 +58,7 @@ public final class ArrayDeclaration extends CompoundDeclaration {
      *
      * TODO: investigate performance
      */
-    private final ArrayListMultimap<String, String> fChildrenNames = ArrayListMultimap.create();
+    private final transient ArrayListMultimap<String, String> fChildrenNames = ArrayListMultimap.create();
 
     // ------------------------------------------------------------------------
     // Constructors
@@ -118,8 +118,7 @@ public final class ArrayDeclaration extends CompoundDeclaration {
         return "[declaration] array[" + Integer.toHexString(hashCode()) + ']'; //$NON-NLS-1$
     }
 
-    @NonNull
-    private List<Definition> read(@NonNull BitBuffer input, @Nullable IDefinitionScope definitionScope, String fieldName) throws CTFReaderException {
+    private @NonNull List<Definition> read(@NonNull BitBuffer input, @Nullable IDefinitionScope definitionScope, String fieldName) throws CTFReaderException {
         Builder<Definition> definitions = new ImmutableList.Builder<>();
         if (!fChildrenNames.containsKey(fieldName)) {
             for (int i = 0; i < fLength; i++) {
@@ -146,4 +145,34 @@ public final class ArrayDeclaration extends CompoundDeclaration {
         return (int) Math.min(Integer.MAX_VALUE, val);
     }
 
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + fElemType.hashCode();
+        result = prime * result + fLength;
+        return result;
+    }
+
+    @Override
+    public boolean equals(@Nullable Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        ArrayDeclaration other = (ArrayDeclaration) obj;
+        if (!fElemType.equals(other.fElemType)) {
+            return false;
+        }
+        if (fLength != other.fLength) {
+            return false;
+        }
+        return true;
+    }
+
 }
\ No newline at end of file
index 5c958cca38c56fa90fe98e25c225de6a598ed632..953d6e2e25b08b5e22884a8611b2c87b9d89e093 100644 (file)
@@ -136,8 +136,7 @@ public class SequenceDeclaration extends CompoundDeclaration {
             definitions.add(fElemType.createDefinition(definitionScope, elemName, input));
         }
         @SuppressWarnings("null")
-        @NonNull
-        ImmutableList<Definition> build = definitions.build();
+        @NonNull ImmutableList<Definition> build = definitions.build();
         return new ArrayDefinition(this, definitionScope, fieldName, build);
     }
 
@@ -152,4 +151,34 @@ public class SequenceDeclaration extends CompoundDeclaration {
         return Integer.MAX_VALUE;
     }
 
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + fElemType.hashCode();
+        result = prime * result + fLengthName.hashCode();
+        return result;
+    }
+
+    @Override
+    public boolean equals(@Nullable Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        SequenceDeclaration other = (SequenceDeclaration) obj;
+        if (!fElemType.equals(other.fElemType)) {
+            return false;
+        }
+        if (!fLengthName.equals(other.fLengthName)) {
+            return false;
+        }
+        return true;
+    }
+
 }
\ No newline at end of file
index b4b860aea23c341eb6b10c7cbca95628d0242e33..883cc5ce8a915a07dad694350c6c4a0a844c0b5c 100644 (file)
@@ -243,4 +243,31 @@ public class EventHeaderCompactDeclaration extends Declaration implements IEvent
         }
         return bo;
     }
+
+@Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + (fByteOrder.equals(ByteOrder.BIG_ENDIAN) ? 4321 : 1234);
+        return result;
+    }
+
+    @Override
+    public boolean equals(@Nullable Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        EventHeaderCompactDeclaration other = (EventHeaderCompactDeclaration) obj;
+        if (!fByteOrder.equals(other.fByteOrder)) {
+            return false;
+        }
+        return true;
+    }
+
 }
index 177da8dc8f9f6c5b6fce2fa0f4ec2f36c8bf5c82..0278099d8766c82239b529238116d40178e9a811 100644 (file)
@@ -241,4 +241,30 @@ public class EventHeaderLargeDeclaration extends Declaration implements IEventHe
         return bo;
     }
 
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + (fByteOrder.equals(ByteOrder.BIG_ENDIAN) ? 4321 : 1234);
+        return result;
+    }
+
+    @Override
+    public boolean equals(@Nullable Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        EventHeaderLargeDeclaration other = (EventHeaderLargeDeclaration) obj;
+        if (!fByteOrder.equals(other.fByteOrder)) {
+            return false;
+        }
+        return true;
+    }
+
 }
This page took 0.041368 seconds and 5 git commands to generate.