001    /*
002     *  Copyright 2001-2005 Stephen Colebourne
003     *
004     *  Licensed under the Apache License, Version 2.0 (the "License");
005     *  you may not use this file except in compliance with the License.
006     *  You may obtain a copy of the License at
007     *
008     *      http://www.apache.org/licenses/LICENSE-2.0
009     *
010     *  Unless required by applicable law or agreed to in writing, software
011     *  distributed under the License is distributed on an "AS IS" BASIS,
012     *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     *  See the License for the specific language governing permissions and
014     *  limitations under the License.
015     */
016    package org.joda.time.convert;
017    
018    import org.joda.time.Chronology;
019    import org.joda.time.ReadWritableInterval;
020    
021    /**
022     * IntervalConverter defines how an object is converted to an interval.
023     *
024     * @author Brian S O'Neill
025     * @author Stephen Colebourne
026     * @since 1.0
027     */
028    public interface IntervalConverter extends Converter {
029    
030        /**
031         * Checks if the input is a ReadableInterval.
032         * <p>
033         * If it is, then the calling code should cast and copy the fields directly.
034         *
035         * @param object  the object to convert, must not be null
036         * @param chrono  the chronology to use, may be null
037         * @return true if the input is a ReadableInterval
038         * @throws ClassCastException if the object is invalid
039         */
040        boolean isReadableInterval(Object object, Chronology chrono);
041    
042        /**
043         * Extracts interval endpoint values from an object of this converter's
044         * type, and sets them into the given ReadWritableInterval.
045         *
046         * @param writableInterval  interval to get modified, not null
047         * @param object  the object to convert, must not be null
048         * @param chrono  the chronology to use, may be null
049         * @throws ClassCastException if the object is invalid
050         */
051        void setInto(ReadWritableInterval writableInterval, Object object, Chronology chrono);
052    
053    }