InMemoryInterpolatedYieldCurveDefinitionMaster implements InterpolatedYieldCurveDefinitionMaster, InterpolatedYieldCurveDefinitionSource, ChangeProvider { @Override public synchronized void remove(ObjectIdentifiable objectIdentifiable) { ArgumentChecker.notNull(objectIdentifiable, "objectIdentifiable"); if (!getUniqueIdScheme().equals(objectIdentifiable.getObjectId().getScheme())) { throw new DataNotFoundException("Scheme '" + objectIdentifiable.getObjectId().getScheme() + "' not valid for '" + getUniqueIdScheme() + "'"); } final int i = objectIdentifiable.getObjectId().getValue().indexOf('_'); if (i <= 0) { throw new DataNotFoundException("Identifier '" + objectIdentifiable.getObjectId().getValue() + "' not valid for '" + getUniqueIdScheme() + "'"); } final String name = objectIdentifiable.getObjectId().getValue().substring(0, i); final String iso = objectIdentifiable.getObjectId().getValue().substring(i + 1); final Currency currency; try { currency = Currency.of(iso); } catch (IllegalArgumentException e) { throw new DataNotFoundException("Identifier '" + objectIdentifiable.getObjectId().getValue() + "' not valid for '" + getUniqueIdScheme() + "'", e); } final Pair<Currency, String> key = Pairs.of(currency, name); final TreeMap<Instant, YieldCurveDefinition> value = _definitions.get(key); if (value == null) { throw new DataNotFoundException("Curve definition not found"); } final Instant now = Instant.now(); value.put(now, null); changeManager().entityChanged(ChangeType.REMOVED, objectIdentifiable.getObjectId(), null, null, now); } InMemoryInterpolatedYieldCurveDefinitionMaster(); String getUniqueIdScheme(); void setUniqueIdScheme(final String scheme); @Override synchronized YieldCurveDefinition getDefinition(Currency currency, String name); @Override YieldCurveDefinition getDefinition(final Currency currency, final String name, final VersionCorrection versionCorrection); @Override synchronized YieldCurveDefinitionDocument add(YieldCurveDefinitionDocument document); @Override synchronized YieldCurveDefinitionDocument addOrUpdate(YieldCurveDefinitionDocument document); @Override YieldCurveDefinitionDocument correct(YieldCurveDefinitionDocument document); @Override synchronized YieldCurveDefinitionDocument get(UniqueId uid); @Override synchronized YieldCurveDefinitionDocument get(ObjectIdentifiable objectIdable, VersionCorrection versionCorrection); @Override synchronized void remove(ObjectIdentifiable objectIdentifiable); @Override synchronized YieldCurveDefinitionDocument update(YieldCurveDefinitionDocument document); @Override ChangeManager changeManager(); @Override List<UniqueId> replaceVersions(ObjectIdentifiable objectIdentifiable, List<YieldCurveDefinitionDocument> replacementDocuments); @Override List<UniqueId> replaceAllVersions(ObjectIdentifiable objectIdentifiable, List<YieldCurveDefinitionDocument> replacementDocuments); @Override List<UniqueId> replaceVersion(UniqueId uniqueId, List<YieldCurveDefinitionDocument> replacementDocuments); @Override void removeVersion(final UniqueId uniqueId); @Override UniqueId replaceVersion(YieldCurveDefinitionDocument replacementDocument); @Override UniqueId addVersion(ObjectIdentifiable objectId, YieldCurveDefinitionDocument documentToAdd); @Override Map<UniqueId, YieldCurveDefinitionDocument> get(Collection<UniqueId> uniqueIds); static final String DEFAULT_SCHEME; }
@Test public void testRemove() { assertNotNull(_master.getDefinition(Currency.USD, "1")); _master.remove(UniqueId.of(_master.getUniqueIdScheme(), "1_USD")); assertNull(_master.getDefinition(Currency.USD, "1")); }