001    /*
002     * Licensed to the Apache Software Foundation (ASF) under one or more
003     * contributor license agreements.  See the NOTICE file distributed with
004     * this work for additional information regarding copyright ownership.
005     * The ASF licenses this file to You under the Apache License, Version 2.0
006     * (the "License"); you may not use this file except in compliance with
007     * the License.  You may obtain a copy of the License at
008     *
009     *      http://www.apache.org/licenses/LICENSE-2.0
010     *
011     * Unless required by applicable law or agreed to in writing, software
012     * distributed under the License is distributed on an "AS IS" BASIS,
013     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     * See the License for the specific language governing permissions and
015     * limitations under the License.
016     */
017    package org.apache.commons.functor;
018    
019    /**
020     * Functor marker interface.  All provided functor interfaces extend this interface.
021     * <p>
022     * Implementors are encouraged but not required to make their functors
023     * {@link java.io.Serializable Serializable}.
024     * </p>
025     *
026     * @since 1.0
027     * @version $Revision: 647297 $ $Date: 2008-04-11 22:14:50 +0200 (Fri, 11 Apr 2008) $
028     */
029    public interface Functor {
030    
031        /**
032         * Returns a human readable description of this functor.
033         * Implementators are strongly encouraged but not
034         * strictly required to override the default {@link Object}
035         * implementation of this method.
036         *
037         * @return a human readable description of this functor
038         */
039        String toString();
040    
041        /**
042         * Returns a hash code for this functor adhering to the
043         * general {@link Object#hashCode Object.hashCode} contract.
044         * Implementators are strongly encouraged but not
045         * strictly required to override the default {@link Object}
046         * implementation of this method.
047         *
048         * @see #equals
049         * @return a hash code for this functor
050         */
051        int hashCode();
052    
053        /**
054         * Indicates whether some other object is &quot;equal to&quot;
055         * this functor.  This method must adhere to
056         * general {@link Object#equals Object.equals} contract.
057         * Additionally, this method can return
058         * <tt>true</tt> <i>only</i> if the specified Object implements
059         * the same functor interface and is known to produce the same
060         * results and/or side-effects for the same arguments (if any).
061         * <p>
062         * While implementators are strongly encouraged to override
063         * the default Object implementation of this method,
064         * note that the default Object implementation
065         * does in fact adhere to the functor <code>equals</code> contract.
066         * </p>
067         * @param that the object to compare this functor to
068         * @see #hashCode
069         * @return <code>true</code> iff the given object implements
070         *         this functor interface, and is known to produce the same
071         *         results and/or side-effects for the same arguments
072         *         (if any).
073         */
074        boolean equals(Object that);
075    }