am = new AttrMethods<M>();
else {
if (am.getter != null) {
final String msg = "Attribute " + attrName +
" has more than one getter";
throw new NotCompliantMBeanException(msg);
}
}
am.getter = cm;
attrMap.put(attrName, am);
} else if (name.startsWith("set") && name.length() > 3
&& nParams == 1 &&
m.getReturnType() == void.class) {
// It's a setter
attrName = name.substring(3);
AttrMethods<M> am = attrMap.get(attrName);
if (am == null)
am = new AttrMethods<M>();
else if (am.setter != null) {
final String msg = "Attribute " + attrName +
" has more than one setter";
throw new NotCompliantMBeanException(msg);
}
am.setter = cm;
attrMap.put(attrName, am);
} else {
// It's an operation
List<M> cms = opMap.get(name);
if (cms == null)
cms = newList();
cms.add(cm);
opMap.put(name, cms);
}
}
/* Check that getters and setters are consistent. */
for (Map.Entry<String, AttrMethods<M>> entry : attrMap.entrySet()) {
AttrMethods<M> am = entry.getValue();
if (!introspector.consistent(am.getter, am.setter)) {
final String msg = "Getter and setter for " + entry.getKey() +
" have inconsistent types";
throw new NotCompliantMBeanException(msg);
}
}
}