private synchronized <T extends SchemaSourceRepresentation> void removeSource( final PotentialSchemaSource<?> source, final SchemaSourceRegistration<?> reg) { final Multimap<Class<? extends SchemaSourceRepresentation>, AbstractSchemaSourceRegistration<?>> m = sources.get(source.getSourceIdentifier()); if (m != null) { m.remove(source.getRepresentation(), reg); for (SchemaListenerRegistration l : listeners) { l.getInstance().schemaSourceUnregistered(source); } if (m.isEmpty()) { sources.remove(source.getSourceIdentifier()); } } }
private synchronized <T extends SchemaSourceRepresentation> void addSource( final PotentialSchemaSource<T> source, final AbstractSchemaSourceRegistration<T> reg) { ListMultimap<Class<? extends SchemaSourceRepresentation>, AbstractSchemaSourceRegistration<?>> m = sources.get(source.getSourceIdentifier()); if (m == null) { m = ArrayListMultimap.create(); sources.put(source.getSourceIdentifier(), m); } m.put(source.getRepresentation(), reg); final Collection<PotentialSchemaSource<?>> reps = Collections.<PotentialSchemaSource<?>>singleton(source); for (SchemaListenerRegistration l : listeners) { l.getInstance().schemaSourceRegistered(reps); } }