99 lines
3.4 KiB
Java
99 lines
3.4 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;
|
||
|
|
||
|
/* loaded from: classes2.dex */
|
||
|
public final class Parameter implements AnnotatedElement {
|
||
|
private final ImmutableList<Annotation> annotations;
|
||
|
private final Invokable<?, ?> declaration;
|
||
|
private final int position;
|
||
|
private final TypeToken<?> type;
|
||
|
|
||
|
/* 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 final boolean isAnnotationPresent(Class<? extends Annotation> cls) {
|
||
|
return getAnnotation(cls) != null;
|
||
|
}
|
||
|
|
||
|
@Override // java.lang.reflect.AnnotatedElement
|
||
|
public final <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 final Annotation[] getAnnotations() {
|
||
|
return getDeclaredAnnotations();
|
||
|
}
|
||
|
|
||
|
@Override // java.lang.reflect.AnnotatedElement
|
||
|
public final <A extends Annotation> A[] getAnnotationsByType(Class<A> cls) {
|
||
|
return (A[]) getDeclaredAnnotationsByType(cls);
|
||
|
}
|
||
|
|
||
|
@Override // java.lang.reflect.AnnotatedElement
|
||
|
public final Annotation[] getDeclaredAnnotations() {
|
||
|
return (Annotation[]) this.annotations.toArray(new Annotation[0]);
|
||
|
}
|
||
|
|
||
|
@Override // java.lang.reflect.AnnotatedElement
|
||
|
public final <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 final <A extends Annotation> A[] getDeclaredAnnotationsByType(Class<A> cls) {
|
||
|
return (A[]) ((Annotation[]) FluentIterable.from(this.annotations).filter(cls).toArray(cls));
|
||
|
}
|
||
|
|
||
|
public final boolean equals(Object obj) {
|
||
|
if (!(obj instanceof Parameter)) {
|
||
|
return false;
|
||
|
}
|
||
|
Parameter parameter = (Parameter) obj;
|
||
|
return this.position == parameter.position && this.declaration.equals(parameter.declaration);
|
||
|
}
|
||
|
|
||
|
public final String toString() {
|
||
|
String valueOf = String.valueOf(this.type);
|
||
|
int i = this.position;
|
||
|
StringBuilder sb = new StringBuilder(String.valueOf(valueOf).length() + 15);
|
||
|
sb.append(valueOf);
|
||
|
sb.append(" arg");
|
||
|
sb.append(i);
|
||
|
return sb.toString();
|
||
|
}
|
||
|
|
||
|
public final int hashCode() {
|
||
|
return this.position;
|
||
|
}
|
||
|
|
||
|
public final TypeToken<?> getType() {
|
||
|
return this.type;
|
||
|
}
|
||
|
|
||
|
public final Invokable<?, ?> getDeclaringInvokable() {
|
||
|
return this.declaration;
|
||
|
}
|
||
|
}
|