001/*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied.  See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 */
019package org.apache.shiro.functor;
020
021/**
022 * Generic <a href="http://en.wikipedia.org/wiki/Functor">functor</a> interface representing a data translation (or
023 * conversion) operation.  For a given input, a Translator can translate an input argument into a potentially different
024 * output value.
025 * <p/>
026 * One example of where this is particularly convenient is API translation: translating a 3rd-party framework Exception
027 * to a Shiro Exception or vice-versa.
028 *
029 * @param <I> The input type
030 * @param <O> The output type
031 *
032 * @since 1.2
033 */
034public interface Translator<I,O> {
035
036    /**
037     * Translates the input argument into the required output instance.
038     *
039     * @param input the input data to translate
040     * @return the translated output data
041     * @since 1.2
042     */
043    O translate(I input);
044
045}