List of usage examples for org.objectweb.asm.tree AnnotationNode visit
@Override
public void visit(final String name, final Object value)
From source file:com.android.build.gradle.internal.incremental.InstantRunVerifierTest.java
License:Apache License
@Test public void testDiffListOnAnnotationNodesEntriesDataSwap() throws Exception { AnnotationNode original = new AnnotationNode("Ltest/SomeAnnotation;"); original.visit("entry1", "data1"); original.visit("entry2", "data2"); AnnotationNode updated = new AnnotationNode("Ltest/SomeAnnotation;"); updated.visit("entry1", "data2"); updated.visit("entry2", "data1"); assertEquals(InstantRunVerifier.Diff.CHANGE, InstantRunVerifier.diffList(Lists.newArrayList(original), Lists.newArrayList(updated), InstantRunVerifier.ANNOTATION_COMPARATOR)); }
From source file:com.android.build.gradle.internal.incremental.InstantRunVerifierTest.java
License:Apache License
@Test public void testDiffListOnAnnotationNodesDiffEntriesOrder() throws Exception { AnnotationNode original = new AnnotationNode("Ltest/SomeAnnotation;"); original.visit("entry1", "data1"); original.visit("entry2", "data2"); AnnotationNode updated = new AnnotationNode("Ltest/SomeAnnotation;"); updated.visit("entry2", "data2"); updated.visit("entry1", "data1"); assertEquals(InstantRunVerifier.Diff.NONE, InstantRunVerifier.diffList(Lists.newArrayList(original), Lists.newArrayList(updated), InstantRunVerifier.ANNOTATION_COMPARATOR)); }
From source file:com.android.build.gradle.internal.incremental.InstantRunVerifierTest.java
License:Apache License
@Test public void testDiffListOnAnnotationNodesWithArrayValues() throws Exception { AnnotationNode original = new AnnotationNode("Ltest/SomeAnnotation;"); original.visit("byteArray", new byte[] { 1, 2, 3 }); original.visit("booleanArray", new boolean[] { false, true, false }); original.visit("shortArray", new short[] { 1, 2, 3 }); original.visit("charArray", new char[] { 'a', 'b', 'c' }); original.visit("intArray", new int[] { 1, 2, 3 }); original.visit("longArray", new long[] { 1, 2, 3 }); original.visit("floatArray", new float[] { 1, 2, 3 }); original.visit("doubleArray", new double[] { 1, 2, 3 }); original.visit("stringArray", new String[] { "1", "2", "3" }); AnnotationNode updated = new AnnotationNode("Ltest/SomeAnnotation;"); updated.visit("byteArray", new byte[] { 1, 2, 3 }); updated.visit("booleanArray", new boolean[] { false, true, false }); updated.visit("shortArray", new short[] { 1, 2, 3 }); updated.visit("charArray", new char[] { 'a', 'b', 'c' }); updated.visit("intArray", new int[] { 1, 2, 3 }); updated.visit("longArray", new long[] { 1, 2, 3 }); updated.visit("floatArray", new float[] { 1, 2, 3 }); updated.visit("doubleArray", new double[] { 1, 2, 3 }); updated.visit("stringArray", new String[] { "1", "2", "3" }); assertEquals(InstantRunVerifier.Diff.NONE, InstantRunVerifier.diffList(Lists.newArrayList(original), Lists.newArrayList(updated), InstantRunVerifier.ANNOTATION_COMPARATOR)); }
From source file:com.thomas15v.packetlib.codegenerator.asm.ASMHelper.java
License:MIT License
/** * Create a new annotation node with the supplied values * //from w w w . j a va2 s.c om * @param annotationType Name (internal name) of the annotation interface to * create * @param value Interleaved key/value pairs. Keys must be strings * @return new annotation node */ private static AnnotationNode makeAnnotationNode(String annotationType, Object... value) { AnnotationNode node = new AnnotationNode(annotationType); for (int pos = 0; pos < value.length - 1; pos += 2) { if (!(value[pos] instanceof String)) { throw new IllegalArgumentException( "Annotation keys must be strings, found " + value[pos].getClass().getSimpleName() + " with " + value[pos].toString() + " at index " + pos + " creating " + annotationType); } node.visit((String) value[pos], value[pos + 1]); } return node; }