Identity.java
/***************************************************************************
Copyright 2009 Emily Estes
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
***************************************************************************/
package net.metanotion.functor;
/** An implementation of Block that implements the identity function.
Given an object x: (new Identity()).eval(x) == x.
@param <I> The type of objects this block instance operates on.
*/
public final class Identity<I> implements Block<I,I> {
/** Since this class is stateles, this is a consant instance to use for convenience. */
public static final Identity I = new Identity();
/** Evaluting this "block", by simply returning the value that was passed in.
@param i The value.
@return The same value that this block was evaluated against.
*/
public I eval(final I i) { return i; }
}