mirror of
https://github.com/revanced/smali.git
synced 2025-05-06 01:24:24 +02:00
Make AnnotationEncodedValue implement BaseAnnotation
This commit is contained in:
parent
22eede870f
commit
3019737ed3
@ -47,7 +47,7 @@ public class DexBackedEncodedValue implements EncodedValue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getType() {
|
public int getValueType() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,5 @@ import org.jf.dexlib2.iface.BaseAnnotation;
|
|||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public interface AnnotationEncodedValue extends EncodedValue {
|
public interface AnnotationEncodedValue extends EncodedValue, BaseAnnotation {
|
||||||
@Nonnull BaseAnnotation getValue();
|
|
||||||
}
|
}
|
||||||
|
@ -32,5 +32,5 @@
|
|||||||
package org.jf.dexlib2.iface.value;
|
package org.jf.dexlib2.iface.value;
|
||||||
|
|
||||||
public interface EncodedValue {
|
public interface EncodedValue {
|
||||||
int getType();
|
int getValueType();
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
package org.jf.dexlib2.immutable;
|
package org.jf.dexlib2.immutable;
|
||||||
|
|
||||||
|
import com.google.common.base.Objects;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import org.jf.dexlib2.iface.Annotation;
|
import org.jf.dexlib2.iface.Annotation;
|
||||||
import org.jf.dexlib2.iface.AnnotationElement;
|
import org.jf.dexlib2.iface.AnnotationElement;
|
||||||
@ -40,21 +41,25 @@ import javax.annotation.Nonnull;
|
|||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ImmutableAnnotation extends ImmutableBaseAnnotation implements Annotation {
|
public class ImmutableAnnotation implements Annotation {
|
||||||
public final int visibility;
|
public final int visibility;
|
||||||
|
@Nonnull public final String type;
|
||||||
|
@Nonnull public final ImmutableList<? extends ImmutableAnnotationElement> elements;
|
||||||
|
|
||||||
public ImmutableAnnotation(int visibility,
|
public ImmutableAnnotation(int visibility,
|
||||||
@Nonnull String type,
|
@Nonnull String type,
|
||||||
@Nullable List<? extends AnnotationElement> elements) {
|
@Nullable List<? extends AnnotationElement> elements) {
|
||||||
super(type, elements);
|
|
||||||
this.visibility = visibility;
|
this.visibility = visibility;
|
||||||
|
this.type = type;
|
||||||
|
this.elements = ImmutableAnnotationElement.immutableListOf(elements);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImmutableAnnotation(int visibility,
|
public ImmutableAnnotation(int visibility,
|
||||||
@Nonnull String type,
|
@Nonnull String type,
|
||||||
@Nullable ImmutableList<? extends ImmutableAnnotationElement> elements) {
|
@Nullable ImmutableList<? extends ImmutableAnnotationElement> elements) {
|
||||||
super(type, elements);
|
|
||||||
this.visibility = visibility;
|
this.visibility = visibility;
|
||||||
|
this.type = type;
|
||||||
|
this.elements = Objects.firstNonNull(elements, ImmutableList.<ImmutableAnnotationElement>of());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ImmutableAnnotation of(Annotation annotation) {
|
public static ImmutableAnnotation of(Annotation annotation) {
|
||||||
@ -67,10 +72,9 @@ public class ImmutableAnnotation extends ImmutableBaseAnnotation implements Anno
|
|||||||
annotation.getElements());
|
annotation.getElements());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override public int getVisibility() { return visibility; }
|
||||||
public int getVisibility() {
|
@Nonnull @Override public String getType() { return type; }
|
||||||
return visibility;
|
@Nonnull @Override public ImmutableList<? extends ImmutableAnnotationElement> getElements() { return elements; }
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public static ImmutableList<ImmutableAnnotation> immutableListOf(List<? extends Annotation> list) {
|
public static ImmutableList<ImmutableAnnotation> immutableListOf(List<? extends Annotation> list) {
|
||||||
|
@ -31,37 +31,44 @@
|
|||||||
|
|
||||||
package org.jf.dexlib2.immutable.value;
|
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.ValueType;
|
||||||
import org.jf.dexlib2.iface.value.EncodedValue;
|
import org.jf.dexlib2.iface.AnnotationElement;
|
||||||
import org.jf.dexlib2.immutable.ImmutableBaseAnnotation;
|
import org.jf.dexlib2.immutable.ImmutableAnnotationElement;
|
||||||
import org.jf.dexlib2.iface.BaseAnnotation;
|
|
||||||
import org.jf.dexlib2.iface.value.AnnotationEncodedValue;
|
import org.jf.dexlib2.iface.value.AnnotationEncodedValue;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class ImmutableAnnotationEncodedValue extends ImmutableEncodedValue implements AnnotationEncodedValue {
|
public class ImmutableAnnotationEncodedValue extends ImmutableEncodedValue implements AnnotationEncodedValue {
|
||||||
@Nonnull
|
@Nonnull public final String type;
|
||||||
public final ImmutableBaseAnnotation value;
|
@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);
|
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);
|
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) {
|
if (annotationEncodedValue instanceof ImmutableAnnotationEncodedValue) {
|
||||||
return (ImmutableAnnotationEncodedValue)annotationEncodedValue;
|
return (ImmutableAnnotationEncodedValue)annotationEncodedValue;
|
||||||
}
|
}
|
||||||
return new ImmutableAnnotationEncodedValue(annotationEncodedValue.getValue());
|
return new ImmutableAnnotationEncodedValue(
|
||||||
|
annotationEncodedValue.getType(),
|
||||||
|
annotationEncodedValue.getElements());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull @Override public String getType() { return type; }
|
||||||
public ImmutableBaseAnnotation getValue() {
|
@Nonnull @Override public ImmutableList<? extends ImmutableAnnotationElement> getElements() { return elements; }
|
||||||
return value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ public class ImmutableEncodedValue implements EncodedValue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ImmutableEncodedValue of(EncodedValue encodedValue) {
|
public static ImmutableEncodedValue of(EncodedValue encodedValue) {
|
||||||
switch (encodedValue.getType()) {
|
switch (encodedValue.getValueType()) {
|
||||||
case ValueType.BYTE:
|
case ValueType.BYTE:
|
||||||
return ImmutableByteEncodedValue.of((ByteEncodedValue)encodedValue);
|
return ImmutableByteEncodedValue.of((ByteEncodedValue)encodedValue);
|
||||||
case ValueType.SHORT:
|
case ValueType.SHORT:
|
||||||
@ -87,7 +87,7 @@ public class ImmutableEncodedValue implements EncodedValue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getType() { return type; }
|
public int getValueType() { return type; }
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public static ImmutableList<ImmutableEncodedValue> immutableListOf(List<? extends EncodedValue> list) {
|
public static ImmutableList<ImmutableEncodedValue> immutableListOf(List<? extends EncodedValue> list) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user