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

gov.sandia.cognition.evaluator.IdentityEvaluator Maven / Gradle / Ivy

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

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy