com.mastfrog.webapi.Interpolators Maven / Gradle / Ivy
package com.mastfrog.webapi;
import java.util.LinkedList;
import java.util.List;
/**
* Registry of interpolators by type
*
* @author Tim Boudreau
*/
final class Interpolators {
private final List> all = new LinkedList<>();
@SuppressWarnings("unchecked")
> Class get(Class type) {
for (Entry e : all) {
if (type == e.parameterType) {
return (Class) e.interpolatorType;
}
}
return null;
}
public > void add(Class type, Class dec) {
all.add(new Entry(type, dec));
}
private static final class Entry> {
private final Class parameterType;
private final Class interpolatorType;
public Entry(Class parameterType, Class interpolatorType) {
this.parameterType = parameterType;
this.interpolatorType = interpolatorType;
}
}
}