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

gov.sandia.cognition.data.convert.IdentityDataConverter Maven / Gradle / Ivy

There is a newer version: 4.0.1
Show newest version
/*
 * 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();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy