/** * Matches sources on origin:name:id. * - If a matching source already exist in the sourceMap, and has the same id as the input source, do removal * - If a matching source already exist in the sourceMap, but have a different id as the input source, no-op * - Otherwise, no-op */ public InstanceInfo remove(Source source) { String sourceKey = sourceKey(source); Source currIfExist = sourceMap.get(sourceKey); if (currIfExist != null) { if (currIfExist.getId().equals(source.getId())) { sourceMap.remove(sourceKey); return dataMap.remove(currIfExist); } else { // no-op return null; } } else { // no-op return null; } }