/** * Returns the IdentifierBundle without dates. * * @return the equivalent bundle, without the dates, not null */ public IdentifierBundle asIdentifierBundle() { Set<Identifier> ids = new HashSet<Identifier>(); for (IdentifierWithDates identifier : _identifiers) { ids.add(identifier.asIdentifier()); } return IdentifierBundle.of(ids); }
/** * Converts this bundle to a list of formatted strings. * * @return the list of identifiers as strings, not null */ public List<String> toStringList() { List<String> list = new ArrayList<String>(); for (IdentifierWithDates id : this) { list.add(id.toString()); } return list; }
// ------------------------------------------------------------------------- public MutableFudgeMsg toFudgeMsg(final FudgeMsgFactory factory, final MutableFudgeMsg message) { ArgumentChecker.notNull(factory, "factory"); ArgumentChecker.notNull(message, "message"); for (IdentifierWithDates identifier : getIdentifiers()) { message.add(ID_FUDGE_FIELD_NAME, identifier.toFudgeMsg(factory)); } return message; }
/** * Create a bundle from an bundle of identifiers. * * @param identifierBundle the identifier bundle, not null * @return the identifier bundle with dates set to null, not null */ public static IdentifierBundleWithDates of(IdentifierBundle identifierBundle) { ArgumentChecker.notNull(identifierBundle, "identifierBundle"); Set<IdentifierWithDates> identifiers = new HashSet<IdentifierWithDates>(); for (Identifier identifier : identifierBundle) { identifiers.add(IdentifierWithDates.of(identifier, null, null)); } return new IdentifierBundleWithDates(identifiers); }
/** * Deserializes this pair from a Fudge message. * * @param fudgeContext the Fudge context * @param msg the Fudge message, not null * @return the pair, not null */ public static IdentifierBundleWithDates fromFudgeMsg( FudgeDeserializationContext fudgeContext, FudgeMsg msg) { Set<IdentifierWithDates> identifiers = new HashSet<IdentifierWithDates>(); for (FudgeField field : msg.getAllByName(ID_FUDGE_FIELD_NAME)) { if (field.getValue() instanceof FudgeMsg == false) { throw new IllegalArgumentException( "Message provider has field named " + ID_FUDGE_FIELD_NAME + " which doesn't contain a sub-Message"); } identifiers.add(IdentifierWithDates.fromFudgeMsg(fudgeContext, (FudgeMsg) field.getValue())); } return new IdentifierBundleWithDates(identifiers); }