gov.sandia.cognition.evaluator.IdentityEvaluator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cognitive-foundry Show documentation
Show all versions of cognitive-foundry Show documentation
A single jar with all the Cognitive Foundry components.
/*
* File: IdentityEvaluator.java
* Authors: Justin Basilico
* Project: Cognitive Foundry Common Core
*
* Copyright 2011 Cognitive Foundry. All rights reserved.
*/
package gov.sandia.cognition.evaluator;
import gov.sandia.cognition.util.AbstractCloneableSerializable;
/**
* An identity function that returns its input as its output. It is a basic
* function of f(x) = x, which is defined for any generic type.
*
* @param
* The data type of the input and output of the evaluator.
* @author Justin Basilico
* @since 3.3.3
*/
public class IdentityEvaluator
extends AbstractCloneableSerializable
implements ReversibleEvaluator>
{
/**
* Creates a new {@code IdentityEvaluator}, which has no parameters.
*/
public IdentityEvaluator()
{
super();
}
@Override
public IdentityEvaluator clone()
{
@SuppressWarnings("unchecked")
final IdentityEvaluator clone = (IdentityEvaluator)
super.clone();
return clone;
}
/**
* Returns the given input.
*
* @param input
* The input value.
* @return
* The input value.
*/
@Override
public DataType evaluate(
final DataType input)
{
return input;
}
@Override
public IdentityEvaluator reverse()
{
return this;
}
/**
* Convenience method for creating an identity evaluator.
*
* @param
* The type of the input and output of the evaluator.
* @return
* A new evaluator.
*/
public static IdentityEvaluator create()
{
return new IdentityEvaluator();
}
}