if (componentType != null) {
for (DisplayGroup displayGroup : getDisplayGroups()) {
String originalName = displayGroup.getOriginalName();
String newName = displayGroup.getName();
String newClassName = displayGroup.getClassName();
AddKeyInfo info = new AddKeyInfo(componentType);
info.setTypeName(displayGroup.getClassName());
info.setName(newName);
info.setCreateAccessorMethod(false);
info.setCreateMutatorMethod(false);
// Populate generic types if required
IType classType = findDisplayGroupClass(displayGroup.getClassName());
String newParameterType = "";
if (classType !=null && classType.getTypeParameters().length > 0) {
newParameterType = displayGroup.getEntityName();
info.setParameterTypeName(newParameterType);
}
IField field = componentType.getField(info.getFieldName());
if (originalName == null) {
if (!field.exists()) {
AddKeyOperation.addKey(info);
}
} else {
info.setName(originalName);
field = componentType.getField(info.getFieldName());
if (field.exists()) {
String originalClassName = Signature.getSignatureSimpleName(Signature.getTypeErasure(field.getTypeSignature()));
String types[] = Signature.getTypeArguments(field.getTypeSignature());
String originalParameterType = types.length > 0 ? Signature.getSignatureSimpleName(types[0]) : "";
if (!originalName.equals(newName) || !originalClassName.equals(displayGroup.getClassName())
|| !originalParameterType.equals(newParameterType)) {
info.setName(newName);
AddKeyOperation.replaceField(info, originalName);
}}
}
}
if (_removedDisplayGroups != null) {
for (DisplayGroup displayGroup : _removedDisplayGroups) {
String originalName = displayGroup.getOriginalName();
if (originalName != null) {
AddKeyInfo info = new AddKeyInfo(componentType);
info.setName(originalName);
IField field = componentType.getField(info.getFieldName());
if (field.exists()) {
field.delete(false, null);
}
}
}