* @param member the member to be removed
* @exception ModelException if impossible
*/
public void removeDeclaredMember(JDOMember member) throws ModelException {
if (member == null) {
throw new ModelException(
msg.msg("EXC_InvalidMember", "null")); //NOI18N
}
String name = member.getName();
if (member instanceof JDOField) {
JDOField field = (JDOField) member;
// nullify mappedByName which removes mappedBy info
field.setMappedByName(null);
// nullify relationship which updates its inverse
field.setRelationship(null);
if (associatedProperties.containsValue(member)) {
associatedProperties.remove(name);
}
else {
declaredFields.remove(name);
}
// There might be a property with the field to be removed as
// associated JDOField => remove the property too.
JDOProperty prop = getAssociatedProperty(field);
if (prop != null) {
removeDeclaredMember(prop);
}
}
else if (member instanceof JDOClass) {
// inner class
declaredClasses.remove(name);
}
else {
throw new ModelException(
msg.msg("EXC_InvalidMember", name)); //NOI18N
}
}