use of io.jenkins.plugins.casc.impl.attributes.PersistedListAttribute in project configuration-as-code-plugin by jenkinsci.
the class BaseConfigurator method createAttribute.
protected Attribute createAttribute(String name, final TypePair type) {
boolean multiple = type.rawType.isArray() || Collection.class.isAssignableFrom(type.rawType);
// If attribute is a Collection|Array of T, we need to introspect further to determine T
Class c = multiple ? getComponentType(type) : type.rawType;
if (c == null) {
throw new IllegalStateException("Unable to detect type of attribute " + getTarget() + '#' + name);
}
// special collection types with dedicated handlers to manage data replacement / possible values
if (DescribableList.class.isAssignableFrom(type.rawType)) {
return new DescribableListAttribute(name, c);
} else if (PersistedList.class.isAssignableFrom(type.rawType)) {
return new PersistedListAttribute(name, c);
}
Attribute attribute;
if (!c.isPrimitive() && !c.isEnum() && Modifier.isAbstract(c.getModifiers())) {
if (!Describable.class.isAssignableFrom(c)) {
// Not a Describable, so we don't know how to detect concrete implementation type
LOGGER.warning("Can't handle " + getTarget() + "#" + name + ": type is abstract but not Describable.");
return null;
}
attribute = new DescribableAttribute(name, c);
} else {
attribute = new Attribute(name, c);
}
attribute.multiple(multiple);
return attribute;
}
Aggregations