gov.sandia.cognition.data.convert.IdentityDataConverter 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: IdentityDataConverter.java
* Authors: Justin Basilico
* Company: Sandia National Laboratories
* Project: Cognitive Foundry
*
* Copyright June 16, 2008, Sandia Corporation.
* Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
* license for use of this work by or on behalf of the U.S. Government. Export
* of this program may require a license from the United States Government.
* See CopyrightHistory.txt for complete details.
*
*/
package gov.sandia.cognition.data.convert;
import gov.sandia.cognition.util.AbstractCloneableSerializable;
/**
* A pass-through converter that just returns the given value.
*
* @param
* The data type that is allowed.
* @author Justin Basilico
* @since 3.0
*/
public class IdentityDataConverter
extends AbstractCloneableSerializable
implements ReversibleDataConverter
{
/**
* Creates a new {@code IdentityDataConverter}.
*/
public IdentityDataConverter()
{
super();
}
@Override
public IdentityDataConverter clone()
{
@SuppressWarnings("unchecked")
final IdentityDataConverter clone = (IdentityDataConverter)
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;
}
/**
* The reverse converter is this converter, since it is an identity
* converter.
*
* @return The reverse converter is this converter.
*/
@Override
public IdentityDataConverter reverse()
{
return this;
}
/**
* Convenience method to create a new {@code IdentityDataConverter}.
*
* @param
* The data type that is allowed.
* @return
* A new identity data converter.
*/
public static IdentityDataConverter create()
{
return new IdentityDataConverter();
}
}