com.github.aidensuen.mongo.reflection.ParamInfo Maven / Gradle / Ivy
package com.github.aidensuen.mongo.reflection;
import org.springframework.core.ResolvableType;
public class ParamInfo {
private final Class> paramType;
private final boolean isArray;
private final ResolvableType resolvableType;
public ParamInfo(ResolvableType resolvableType) {
this.resolvableType = resolvableType;
this.paramType = resolvableType.resolve();
this.isArray = resolvableType.isArray();
}
public Class> getParamType() {
return paramType;
}
public boolean isArray() {
return isArray;
}
public ResolvableType getResolvableType() {
return resolvableType;
}
public Class> getComponentType() {
return this.resolvableType.getComponentType().resolve();
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append(paramType.getName());
if (isArray) {
builder.append("<").append(getComponentType().getName()).append(">");
} else {
if (resolvableType.hasGenerics()) {
for (ResolvableType resolvableType : resolvableType.getGenerics()) {
Class> genericType = resolvableType.resolve();
builder.append("<").append(genericType != null ? genericType.getName() : "?").append(">");
}
}
}
return builder.toString();
}
}