final PositionOrTrade position = target.getPositionOrTrade();
Security security = position.getSecurity();
if (security != null) {
return security.getName();
}
final SecurityLink link = position.getSecurityLink();
if (link != null) {
security = link.getTarget();
if (security != null) {
return security.getName();
}
final ExternalIdBundle identifiers = link.getExternalId();
if (identifiers != null) {
if (identifiers.size() > 0) {
return position.getQuantity() + " x " + identifiers.iterator().next();
} else {
return position.getQuantity() + " x " + identifiers;
}
} else if (link.getObjectId() != null) {
return position.getQuantity() + " x " + link.getObjectId();
}
}
return null;
}
});