public class MetricLoaderHelper
extends java.lang.Object
Helper for loading metrics from the classpath.
Constructor and Description |
---|
MetricLoaderHelper(java.lang.ClassLoader cl,
java.lang.String baseName)
Create a new loader helper.
|
Modifier and Type | Method and Description |
---|---|
<T> T |
createMetric(java.lang.Class<T> type,
com.fasterxml.jackson.databind.JsonNode node) |
<T> T |
createMetric(java.lang.Class<T> type,
java.lang.String json) |
java.lang.Class<?> |
findClass(java.lang.String name)
Look up the class implementing a metric by name.
|
java.lang.String |
getMetricTypeName(com.fasterxml.jackson.databind.JsonNode node)
Get the metric type name from a node.
|
public MetricLoaderHelper(java.lang.ClassLoader cl, java.lang.String baseName) throws java.io.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.java.io.IOException
- If there is an error loading the properties.@Nullable public java.lang.Class<?> findClass(java.lang.String name)
Look up the class implementing a metric by name.
name
- The metric name.public java.lang.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(java.lang.Class<T> type, com.fasterxml.jackson.databind.JsonNode node)
@Nullable public <T> T createMetric(java.lang.Class<T> type, java.lang.String json)