Make AnnotationEncodedValue implement BaseAnnotation
diff --git a/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/value/DexBackedEncodedValue.java b/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/value/DexBackedEncodedValue.java
index a4c0f0f..97bc807 100644
--- a/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/value/DexBackedEncodedValue.java
+++ b/dexlib2/src/main/java/org/jf/dexlib2/dexbacked/value/DexBackedEncodedValue.java
@@ -47,7 +47,7 @@
}
@Override
- public int getType() {
+ public int getValueType() {
return 0;
}
}
diff --git a/dexlib2/src/main/java/org/jf/dexlib2/iface/value/AnnotationEncodedValue.java b/dexlib2/src/main/java/org/jf/dexlib2/iface/value/AnnotationEncodedValue.java
index 4d5337b..20f4fc5 100644
--- a/dexlib2/src/main/java/org/jf/dexlib2/iface/value/AnnotationEncodedValue.java
+++ b/dexlib2/src/main/java/org/jf/dexlib2/iface/value/AnnotationEncodedValue.java
@@ -35,6 +35,5 @@
import javax.annotation.Nonnull;
-public interface AnnotationEncodedValue extends EncodedValue {
- @Nonnull BaseAnnotation getValue();
+public interface AnnotationEncodedValue extends EncodedValue, BaseAnnotation {
}
diff --git a/dexlib2/src/main/java/org/jf/dexlib2/iface/value/EncodedValue.java b/dexlib2/src/main/java/org/jf/dexlib2/iface/value/EncodedValue.java
index b4ea855..52ffa08 100644
--- a/dexlib2/src/main/java/org/jf/dexlib2/iface/value/EncodedValue.java
+++ b/dexlib2/src/main/java/org/jf/dexlib2/iface/value/EncodedValue.java
@@ -32,5 +32,5 @@
package org.jf.dexlib2.iface.value;
public interface EncodedValue {
- int getType();
+ int getValueType();
}
diff --git a/dexlib2/src/main/java/org/jf/dexlib2/immutable/ImmutableAnnotation.java b/dexlib2/src/main/java/org/jf/dexlib2/immutable/ImmutableAnnotation.java
index dd503bc..d24cf43 100644
--- a/dexlib2/src/main/java/org/jf/dexlib2/immutable/ImmutableAnnotation.java
+++ b/dexlib2/src/main/java/org/jf/dexlib2/immutable/ImmutableAnnotation.java
@@ -31,6 +31,7 @@
package org.jf.dexlib2.immutable;
+import com.google.common.base.Objects;
import com.google.common.collect.ImmutableList;
import org.jf.dexlib2.iface.Annotation;
import org.jf.dexlib2.iface.AnnotationElement;
@@ -40,21 +41,25 @@
import javax.annotation.Nullable;
import java.util.List;
-public class ImmutableAnnotation extends ImmutableBaseAnnotation implements Annotation {
+public class ImmutableAnnotation implements Annotation {
public final int visibility;
+ @Nonnull public final String type;
+ @Nonnull public final ImmutableList<? extends ImmutableAnnotationElement> elements;
public ImmutableAnnotation(int visibility,
@Nonnull String type,
@Nullable List<? extends AnnotationElement> elements) {
- super(type, elements);
this.visibility = visibility;
+ this.type = type;
+ this.elements = ImmutableAnnotationElement.immutableListOf(elements);
}
public ImmutableAnnotation(int visibility,
@Nonnull String type,
@Nullable ImmutableList<? extends ImmutableAnnotationElement> elements) {
- super(type, elements);
this.visibility = visibility;
+ this.type = type;
+ this.elements = Objects.firstNonNull(elements, ImmutableList.<ImmutableAnnotationElement>of());
}
public static ImmutableAnnotation of(Annotation annotation) {
@@ -67,10 +72,9 @@
annotation.getElements());
}
- @Override
- public int getVisibility() {
- return visibility;
- }
+ @Override public int getVisibility() { return visibility; }
+ @Nonnull @Override public String getType() { return type; }
+ @Nonnull @Override public ImmutableList<? extends ImmutableAnnotationElement> getElements() { return elements; }
@Nonnull
public static ImmutableList<ImmutableAnnotation> immutableListOf(List<? extends Annotation> list) {
diff --git a/dexlib2/src/main/java/org/jf/dexlib2/immutable/value/ImmutableAnnotationEncodedValue.java b/dexlib2/src/main/java/org/jf/dexlib2/immutable/value/ImmutableAnnotationEncodedValue.java
index 61ed7b3..f1ba0b8 100644
--- a/dexlib2/src/main/java/org/jf/dexlib2/immutable/value/ImmutableAnnotationEncodedValue.java
+++ b/dexlib2/src/main/java/org/jf/dexlib2/immutable/value/ImmutableAnnotationEncodedValue.java
@@ -31,37 +31,44 @@
package org.jf.dexlib2.immutable.value;
+import com.google.common.base.Objects;
+import com.google.common.collect.ImmutableList;
import org.jf.dexlib2.ValueType;
-import org.jf.dexlib2.iface.value.EncodedValue;
-import org.jf.dexlib2.immutable.ImmutableBaseAnnotation;
-import org.jf.dexlib2.iface.BaseAnnotation;
+import org.jf.dexlib2.iface.AnnotationElement;
+import org.jf.dexlib2.immutable.ImmutableAnnotationElement;
import org.jf.dexlib2.iface.value.AnnotationEncodedValue;
import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import java.util.List;
public class ImmutableAnnotationEncodedValue extends ImmutableEncodedValue implements AnnotationEncodedValue {
- @Nonnull
- public final ImmutableBaseAnnotation value;
+ @Nonnull public final String type;
+ @Nonnull public final ImmutableList<? extends ImmutableAnnotationElement> elements;
- public ImmutableAnnotationEncodedValue(@Nonnull BaseAnnotation value) {
+ public ImmutableAnnotationEncodedValue(@Nonnull String type,
+ @Nullable List<? extends AnnotationElement> elements) {
super(ValueType.ANNOTATION);
- this.value = ImmutableBaseAnnotation.of(value);
+ this.type = type;
+ this.elements = ImmutableAnnotationElement.immutableListOf(elements);
}
- public ImmutableAnnotationEncodedValue(@Nonnull ImmutableBaseAnnotation value) {
+ public ImmutableAnnotationEncodedValue(@Nonnull String type,
+ @Nullable ImmutableList<? extends ImmutableAnnotationElement> elements) {
super(ValueType.ANNOTATION);
- this.value = value;
+ this.type = type;
+ this.elements = Objects.firstNonNull(elements, ImmutableList.<ImmutableAnnotationElement>of());
}
- public static ImmutableAnnotationEncodedValue of(@Nonnull AnnotationEncodedValue annotationEncodedValue) {
+ public static ImmutableAnnotationEncodedValue of(AnnotationEncodedValue annotationEncodedValue) {
if (annotationEncodedValue instanceof ImmutableAnnotationEncodedValue) {
return (ImmutableAnnotationEncodedValue)annotationEncodedValue;
}
- return new ImmutableAnnotationEncodedValue(annotationEncodedValue.getValue());
+ return new ImmutableAnnotationEncodedValue(
+ annotationEncodedValue.getType(),
+ annotationEncodedValue.getElements());
}
- @Nonnull
- public ImmutableBaseAnnotation getValue() {
- return value;
- }
+ @Nonnull @Override public String getType() { return type; }
+ @Nonnull @Override public ImmutableList<? extends ImmutableAnnotationElement> getElements() { return elements; }
}
diff --git a/dexlib2/src/main/java/org/jf/dexlib2/immutable/value/ImmutableEncodedValue.java b/dexlib2/src/main/java/org/jf/dexlib2/immutable/value/ImmutableEncodedValue.java
index 2231032..32e0683 100644
--- a/dexlib2/src/main/java/org/jf/dexlib2/immutable/value/ImmutableEncodedValue.java
+++ b/dexlib2/src/main/java/org/jf/dexlib2/immutable/value/ImmutableEncodedValue.java
@@ -48,7 +48,7 @@
}
public static ImmutableEncodedValue of(EncodedValue encodedValue) {
- switch (encodedValue.getType()) {
+ switch (encodedValue.getValueType()) {
case ValueType.BYTE:
return ImmutableByteEncodedValue.of((ByteEncodedValue)encodedValue);
case ValueType.SHORT:
@@ -87,7 +87,7 @@
}
}
- public int getType() { return type; }
+ public int getValueType() { return type; }
@Nonnull
public static ImmutableList<ImmutableEncodedValue> immutableListOf(List<? extends EncodedValue> list) {