Search in sources :

Example 1 with ParameterType

use of org.jenkinsci.plugins.structs.describable.ParameterType in project blueocean-plugin by jenkinsci.

the class ExportedDescribableParameter method getCollectionTypes.

/**
 * Java types allowed if this is a collection
 * See {@link DescribableParameter#getType()} and {@link ParameterType#getActualType()}
 */
@Exported
public List<String> getCollectionTypes() {
    List<String> collectionTypes = new ArrayList<>();
    Type typ = param.getType().getActualType();
    if (typ instanceof ParameterizedType) {
        Type[] typeArgs = ((ParameterizedType) typ).getActualTypeArguments();
        for (Type ptyp : typeArgs) {
            if (ptyp instanceof Class<?>) {
                collectionTypes.add(((Class<?>) ptyp).getName());
            }
        }
    }
    return collectionTypes;
}
Also used : ParameterizedType(java.lang.reflect.ParameterizedType) ParameterizedType(java.lang.reflect.ParameterizedType) Type(java.lang.reflect.Type) ParameterType(org.jenkinsci.plugins.structs.describable.ParameterType) ArrayList(java.util.ArrayList) Exported(org.kohsuke.stapler.export.Exported)

Aggregations

ParameterizedType (java.lang.reflect.ParameterizedType)1 Type (java.lang.reflect.Type)1 ArrayList (java.util.ArrayList)1 ParameterType (org.jenkinsci.plugins.structs.describable.ParameterType)1 Exported (org.kohsuke.stapler.export.Exported)1