content += "</i><br />";
}
}
// handle fields of type User
else if (User.class.isInstance(newField) || User.class.isInstance(oldField)) {
User oldValue = (User)oldField;
User newValue = (User)newField;
if (oldValue == null) {
content += " <b>NEW</b><i> " + newValue.getUsername() + "</i><br />";
}
else if (newValue == null) {
content += " <b>REMOVED</b><i> " + oldValue.getUsername() + "</i><br />";
}
else {
content += " <b>FROM</b><i> " + oldValue.getUsername() + " </i><b>TO</b><i> " + newValue.getUsername() + "</i><br />";
}
}
// handle fields of type Set<Tag>
else if (tagSetClass.isInstance(oldField) && tagSetClass.isInstance(newField)) {
Set<Tag> oldTags = (Set<Tag>)oldField;
Set<Tag> newTags = (Set<Tag>)newField;
if (oldTags.size() > 0) {
content += " <b>OLD</b><i> ";
for (Tag tag : oldTags) {
content += tag.getName() + ", ";
}
content += " </i>";
}
content += " <b>NEW</b><i> ";
for (Tag tag : newTags) {
content += tag.getName() + ", ";
}
content += "</i><br />";
}
else if (DefectStatus.class.isInstance(newField)) {
DefectStatus oldValue = (DefectStatus)oldField;
DefectStatus newValue = (DefectStatus)newField;
if (oldValue != null && newValue != null) {
content += " <b>FROM</b><i> " + oldValue.toString() + " </i><b>TO</b><i> " + newValue.toString() + "</i><br />";
}
}
// the field type is not recognized
else {
throw new RuntimeException("Cannot handle a FieldChange of generic type " + oldField + " for field name " + fieldName);