Skip to content
Snippets Groups Projects
Commit c8c5480b authored by Simon Barner's avatar Simon Barner
Browse files

Introduce EMFTypeToTypeSetMap::addTypeSetEntry()

parent 73983729
No related branches found
No related tags found
1 merge request!593735: MemoryAreas
EMFTypeMap.java b6c39465568f0edbfbd5c90400a4f519c042d423 GREEN EMFTypeMap.java b6c39465568f0edbfbd5c90400a4f519c042d423 GREEN
EMFTypeToTypeMap.java 294abe02e7af4ad751d8760b6c6286a3c1f6d73f GREEN EMFTypeToTypeMap.java 294abe02e7af4ad751d8760b6c6286a3c1f6d73f GREEN
EMFTypeToTypeSetMap.java 47ab03966258e7512fa990eb5d420f5787dff3eb GREEN EMFTypeToTypeSetMap.java 162905b474905063b91f90638f898f03da46c294 YELLOW
TypeSet.java e18e66236b223eaf4c22037459779b421a0c2703 GREEN TypeSet.java e18e66236b223eaf4c22037459779b421a0c2703 GREEN
...@@ -15,9 +15,32 @@ ...@@ -15,9 +15,32 @@
+--------------------------------------------------------------------------*/ +--------------------------------------------------------------------------*/
package org.fortiss.tooling.kernel.service.types; package org.fortiss.tooling.kernel.service.types;
import static java.util.Collections.emptyList;
import static java.util.Collections.unmodifiableCollection;
import java.util.Collection;
import java.util.Set; import java.util.Set;
/** Maps a given EMF type to a {@link Set} of types. */ /** Maps a given EMF type to a {@link Set} of types. */
public class EMFTypeToTypeSetMap<S, T> extends EMFTypeMap<S, TypeSet<T>> { public class EMFTypeToTypeSetMap<S, T> extends EMFTypeMap<S, TypeSet<T>> {
// Nothing to do
/** Adds the given {@code targetType} to the mapped types of the given {@code sourceType}. */
public void addTypeSetEntry(Class<? extends S> sourceType, Class<? extends T> targetType) {
TypeSet<T> typeSet = get(sourceType);
if(typeSet == null) {
typeSet = new TypeSet<T>();
put(sourceType, typeSet);
}
typeSet.add(targetType);
}
/**
* Returns the (possibly empty) unmodifiable {@link Collection} of target types that are mapped
* to the given given {@code sourceType}.
*/
public Collection<Class<? extends T>> getTargetTypes(Class<? extends S> sourceType) {
final TypeSet<T> rval = get(sourceType);
return rval != null ? unmodifiableCollection(rval) : emptyList();
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment