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

org.dbflute.lasta.di.util.tiger.IterableAdapter Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2014-2015 the original author or authors.
 *
 * 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 org.dbflute.lasta.di.util.tiger;

import java.util.Enumeration;
import java.util.Iterator;

/**
 * {@link Enumeration}を{@link Iterable}として扱うためのユーティリティ。
 * 
 * @param 
 *            {@link java.util.Enumeration}の要素型
 * @author modified by jflute (originated in Seasar)
 */
public class IterableAdapter implements Iterable, Iterator {

    Enumeration enumeration;

    /**
     * {@link Enumeration}を{@link Iterable}として扱うIterableAdapterを作成して返します。
     * 
     * @param 
     *            {@link Enumeration}の要素型
     * @param enumeration
     *            反復対象となる{@link java.util.Enumeration}
     * @return {@link Enumeration}を{@link Iterable}として扱うIterableAdapter
     */
    public static  IterableAdapter iterable(Enumeration enumeration) {
        return new IterableAdapter(enumeration);
    }

    /**
     * インスタンスを構築します。
     * 
     * @param enumeration
     *            反復対象となる{@link java.util.Enumeration}
     */
    public IterableAdapter(final Enumeration enumeration) {
        this.enumeration = enumeration;
    }

    /**
     * {@link java.util.Enumeration}の反復子を返します。
     * 
     * @return {@link java.util.Enumeration}の反復子
     */
    public Iterator iterator() {
        return this;
    }

    /**
     * @see java.util.Iterator#hasNext
     */
    public boolean hasNext() {
        return enumeration.hasMoreElements();
    }

    /**
     * @see java.util.Iterator#hasNext
     */
    public E next() {
        return enumeration.nextElement();
    }

    /**
     * このメソッドはサポートされません。
     * 
     * @see java.util.Iterator#remove
     */
    public void remove() {
        throw new UnsupportedOperationException("remove");
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy