Skip to content

Commit

Permalink
Restore some type-safety to ResolverRegistry
Browse files Browse the repository at this point in the history
  • Loading branch information
marcphilipp committed Oct 30, 2015
1 parent fab3921 commit bb7aa92
Showing 1 changed file with 6 additions and 4 deletions.
Expand Up @@ -21,19 +21,21 @@
*/ */
class TestDescriptorResolverRegistry { class TestDescriptorResolverRegistry {


private final Map<Class<? extends TestPlanSpecificationElement>, TestDescriptorResolver> resolvers = new HashMap<>(); private final Map<Class<? extends TestPlanSpecificationElement>, TestDescriptorResolver<? extends TestPlanSpecificationElement, ?>> resolvers = new HashMap<>();


public TestDescriptorResolver forType(Class<? extends TestPlanSpecificationElement> type) { @SuppressWarnings("unchecked")
public <T extends TestPlanSpecificationElement> TestDescriptorResolver<T, ?> forType(Class<T> type) {
if (resolvers.containsKey(type)) { if (resolvers.containsKey(type)) {
return resolvers.get(type); return (TestDescriptorResolver<T, ?>) resolvers.get(type);
} }
else { else {
throw new UnsupportedOperationException( throw new UnsupportedOperationException(
"There is no specification resolver registered for type: " + type.getName()); "There is no specification resolver registered for type: " + type.getName());
} }
} }


public void addResolver(Class<? extends TestPlanSpecificationElement> element, TestDescriptorResolver resolver) { public <T extends TestPlanSpecificationElement> void addResolver(Class<T> element,
TestDescriptorResolver<T, ?> resolver) {
resolvers.put(element, resolver); resolvers.put(element, resolver);
} }
} }

0 comments on commit bb7aa92

Please sign in to comment.