Rabbit-R1/android (non root)/java/sources/com/google/common/reflect/Parameter.java
2024-05-21 17:08:36 -04:00

97 lines
3.3 KiB
Java

package com.google.common.reflect;
import com.google.common.base.Preconditions;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.UnmodifiableIterator;
import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedElement;
import javax.annotation.CheckForNull;
@ElementTypesAreNonnullByDefault
/* loaded from: classes3.dex */
public final class Parameter implements AnnotatedElement {
private final ImmutableList<Annotation> annotations;
private final Invokable<?, ?> declaration;
private final int position;
private final TypeToken<?> type;
public Invokable<?, ?> getDeclaringInvokable() {
return this.declaration;
}
public TypeToken<?> getType() {
return this.type;
}
public int hashCode() {
return this.position;
}
/* JADX INFO: Access modifiers changed from: package-private */
public Parameter(Invokable<?, ?> invokable, int i, TypeToken<?> typeToken, Annotation[] annotationArr) {
this.declaration = invokable;
this.position = i;
this.type = typeToken;
this.annotations = ImmutableList.copyOf(annotationArr);
}
@Override // java.lang.reflect.AnnotatedElement
public boolean isAnnotationPresent(Class<? extends Annotation> cls) {
return getAnnotation(cls) != null;
}
@Override // java.lang.reflect.AnnotatedElement
@CheckForNull
public <A extends Annotation> A getAnnotation(Class<A> cls) {
Preconditions.checkNotNull(cls);
UnmodifiableIterator<Annotation> it = this.annotations.iterator();
while (it.hasNext()) {
Annotation next = it.next();
if (cls.isInstance(next)) {
return cls.cast(next);
}
}
return null;
}
@Override // java.lang.reflect.AnnotatedElement
public Annotation[] getAnnotations() {
return getDeclaredAnnotations();
}
@Override // java.lang.reflect.AnnotatedElement
public <A extends Annotation> A[] getAnnotationsByType(Class<A> cls) {
return (A[]) getDeclaredAnnotationsByType(cls);
}
@Override // java.lang.reflect.AnnotatedElement
public Annotation[] getDeclaredAnnotations() {
return (Annotation[]) this.annotations.toArray(new Annotation[0]);
}
@Override // java.lang.reflect.AnnotatedElement
@CheckForNull
public <A extends Annotation> A getDeclaredAnnotation(Class<A> cls) {
Preconditions.checkNotNull(cls);
return (A) FluentIterable.from(this.annotations).filter(cls).first().orNull();
}
@Override // java.lang.reflect.AnnotatedElement
public <A extends Annotation> A[] getDeclaredAnnotationsByType(Class<A> cls) {
return (A[]) ((Annotation[]) FluentIterable.from(this.annotations).filter(cls).toArray(cls));
}
public boolean equals(@CheckForNull Object obj) {
if (!(obj instanceof Parameter)) {
return false;
}
Parameter parameter = (Parameter) obj;
return this.position == parameter.position && this.declaration.equals(parameter.declaration);
}
public String toString() {
String valueOf = String.valueOf(this.type);
return new StringBuilder(String.valueOf(valueOf).length() + 15).append(valueOf).append(" arg").append(this.position).toString();
}
}