All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.etlunit.feature.ResourceFeatureOperation Maven / Gradle / Ivy

There is a newer version: 1.6.9
Show newest version
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 ResourceFeatureOperation implements FeatureOperation
{
	private final String name;
	private final String description;
	private final ResourceFeatureMetaInfo resourceFeatureMetaInfo;

	public ResourceFeatureOperation(ResourceFeatureMetaInfo resourceFeatureMetaInfo, String key, String description)
	{
		name = key;
		this.description = description;
		this.resourceFeatureMetaInfo = resourceFeatureMetaInfo;
	}

	@Override
	public String getName()
	{
		return name;
	}

	@Override
	public String getDescription()
	{
		return description;
	}

	@Override
	public String getUsage()
	{
		String val = resourceFeatureMetaInfo.getResource(name + ".usage");

		return val;
	}

	@Override
	public String getPrototype()
	{
		String val = resourceFeatureMetaInfo.getResource(name + ".prototype");

		return val;
	}

	@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 operation signature [" + resourceFeatureMetaInfo.describing
						.getFeatureName() + "].[" + name + "]: " + e.toString());
			}
		}

		return null;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy