*
* @param name the name
* @return the attribute definition
*/
private static AttributeDefinition createNestedComplexType(final String name) {
return new AttributeDefinition(name, name, null, ModelType.OBJECT, true, false, MeasurementUnit.NONE, createNestedParamValidator(), ALTERNATIVES_ANY, null, AttributeAccess.Flag.RESTART_ALL_SERVICES) {
@Override
public void marshallAsElement(ModelNode resourceModel, XMLStreamWriter writer) throws XMLStreamException {
throw new UnsupportedOperationException();
}
@Override
public ModelNode addResourceAttributeDescription(final ResourceBundle bundle, final String prefix, final ModelNode resourceDescription) {
final ModelNode result = super.addResourceAttributeDescription(bundle, prefix, resourceDescription);
addNestedDescriptions(result, prefix, bundle);
return result;
}
@Override
public ModelNode addOperationParameterDescription(ResourceBundle bundle, String prefix, ModelNode operationDescription) {
final ModelNode result = super.addOperationParameterDescription(bundle, prefix, operationDescription); //To change body of overridden methods use File | Settings | File Templates.
addNestedDescriptions(result, prefix, bundle);
return result;
}
void addNestedDescriptions(final ModelNode result, final String prefix, final ResourceBundle bundle) {
for(final AttributeDefinition def : NESTED_ATTRIBUTES) {
final String bundleKey = prefix == null ? def.getName() : (prefix + "." + def.getName());
result.get(VALUE_TYPE, def.getName(), DESCRIPTION).set(bundle.getString(bundleKey));
}
}
@Override
public ModelNode getNoTextDescription(boolean forOperation) {
final ModelNode model = super.getNoTextDescription(forOperation);
final ModelNode valueType = model.get(VALUE_TYPE);
for(final AttributeDefinition def : NESTED_ATTRIBUTES) {
final AttributeDefinition current;
if(NESTED_LIST_ATTRIBUTES.contains(def)) {
current = wrapAsList(def);
} else {
current = def;
}
final ModelNode m = current.getNoTextDescription(forOperation);
m.remove(ALTERNATIVES);
valueType.get(current.getName()).set(m);
}
return model;
}
};