public class MetricLoaderHelper extends Object
Helper for loading metrics from the classpath.
| Constructor and Description |
|---|
MetricLoaderHelper(ClassLoader cl,
String baseName)
Create a new loader helper.
|
| Modifier and Type | Method and Description |
|---|---|
<T> T |
createMetric(Class<T> type,
com.fasterxml.jackson.databind.JsonNode node) |
<T> T |
createMetric(Class<T> type,
String json) |
Class<?> |
findClass(String name)
Look up the class implementing a metric by name.
|
String |
getMetricTypeName(com.fasterxml.jackson.databind.JsonNode node)
Get the metric type name from a node.
|
Object |
tryInstantiate(String name)
Try to instantiate a metric.
|
public MetricLoaderHelper(ClassLoader cl, String baseName) throws IOException
Create a new loader helper.
cl - The class loader.baseName - The base name for files to look for; will load from META-INF/lenskit/baseName.properteis.IOException - If there is an error loading the properties.@Nullable public Class<?> findClass(String name)
Look up the class implementing a metric by name.
name - The metric name.public Object tryInstantiate(String name)
Try to instantiate a metric.
name - The metric name (case-insensitive; will be looked up in lowercase).null if no such metric can be found.public String getMetricTypeName(com.fasterxml.jackson.databind.JsonNode node)
Get the metric type name from a node. If the node is a string, the string is returned; otherwise, the object’s type property is returned.
node - The node.@Nullable public <T> T createMetric(Class<T> type, com.fasterxml.jackson.databind.JsonNode node)