org.etlunit.feature.ResourceFeatureAnnotation Maven / Gradle / Ivy
package org.etlunit.feature;
import org.etlunit.json.validator.JsonSchema;
import org.etlunit.json.validator.JsonSchemaValidationException;
import java.util.Arrays;
import java.util.List;
public class ResourceFeatureAnnotation implements FeatureAnnotation
{
private final String name;
private final String description;
private final ResourceFeatureMetaInfo resourceFeatureMetaInfo;
private final propertyType pType;
public ResourceFeatureAnnotation(ResourceFeatureMetaInfo resourceFeatureMetaInfo, String key, String description, propertyType prop)
{
name = key;
this.description = description;
this.resourceFeatureMetaInfo = resourceFeatureMetaInfo;
pType = prop;
}
@Override
public String getName()
{
return name;
}
@Override
public String getDescription()
{
return description;
}
@Override
public List getValidator()
{
String schema = resourceFeatureMetaInfo.getResource(name + ".validator.jsonSchema");
if (schema != null)
{
try
{
return Arrays.asList(new JsonSchema(schema));
}
catch (JsonSchemaValidationException e)
{
throw new RuntimeException("Invalid schema for annotation signature [" + resourceFeatureMetaInfo.describing
.getFeatureName() + "].[" + name + "]: " + e.toString());
}
}
return null;
}
@Override
public propertyType getPropertyType()
{
return pType;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy