All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.aidensuen.mongo.reflection.ParamInfo Maven / Gradle / Ivy

There is a newer version: 1.1.2
Show newest version
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();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy