Search in sources :

Example 1 with FeatureParameterType

use of org.jboss.galleon.type.FeatureParameterType in project galleon by wildfly.

the class ResolvedFeature method setParam.

void setParam(String name, Object value, boolean overwrite) throws ProvisioningException {
    if (id != null) {
        final Object idValue = id.params.get(name);
        if (idValue != null) {
            if (!idValue.equals(value)) {
                throw new ProvisioningDescriptionException("ID parameter " + name + "=" + idValue + " can't be reset to " + value);
            }
            return;
        }
    }
    if (!spec.xmlSpec.hasParam(name)) {
        throw new ProvisioningDescriptionException(Errors.unknownFeatureParameter(spec.id, name));
    }
    if (unsetParams.contains(name)) {
        if (!overwrite) {
            return;
        }
        unsetParams = CollectionUtils.remove(unsetParams, name);
        params.put(name, value);
        return;
    }
    if (resetParams.contains(name)) {
        if (!overwrite) {
            return;
        }
        resetParams = CollectionUtils.remove(resetParams, name);
        params.put(name, value);
        return;
    }
    final Object prevValue = params.get(name);
    if (prevValue == null) {
        params.put(name, value);
        return;
    }
    final FeatureParameterType valueType = spec.getTypeForParameter(name);
    if (valueType.isMergeable()) {
        params.put(name, overwrite ? valueType.merge(prevValue, value) : valueType.merge(value, prevValue));
        return;
    }
    if (overwrite) {
        params.put(name, value);
    }
}
Also used : FeatureParameterType(org.jboss.galleon.type.FeatureParameterType) ProvisioningDescriptionException(org.jboss.galleon.ProvisioningDescriptionException)

Aggregations

ProvisioningDescriptionException (org.jboss.galleon.ProvisioningDescriptionException)1 FeatureParameterType (org.jboss.galleon.type.FeatureParameterType)1