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

net.sf.aguacate.function.spi.AbstractFunction Maven / Gradle / Ivy

There is a newer version: 0.10.9
Show newest version
package net.sf.aguacate.function.spi;

import java.util.Collection;
import java.util.List;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import net.sf.aguacate.function.Function;
import net.sf.aguacate.function.Parameter;

public abstract class AbstractFunction implements Function {

	private static final Logger MESSAGE_LOGGER = LogManager.getLogger("aguacate.function");

	private final Collection methods;

	private final String name;

	private final String message;

	private final Parameter[] parameters;

	private final String outputName;

	public AbstractFunction(Collection methods, String name, String message, List parameters,
			String outputName) {
		this.methods = methods;
		this.name = name;
		this.message = message;
		this.parameters = parameters.toArray(new Parameter[parameters.size()]);
		this.outputName = outputName;
	}

	@Override
	public boolean validFor(String method) {
		return methods.contains(method);
	}

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

	@Override
	public String getMessage() {
		return message;
	}

	@Override
	public Parameter[] getParameters() {
		return parameters;
	}

	@Override
	public String getOutputName() {
		return outputName;
	}

	protected void logFailure(String msg) {
		MESSAGE_LOGGER.warn("{}({}): failure", msg, getName());
	}

	protected void logSuccess(String msg) {
		MESSAGE_LOGGER.info("{}({}): success", msg, getName());
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy