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

io.github.mmm.base.impl.ComposableIterator Maven / Gradle / Ivy

/* Copyright (c) The m-m-m Team, Licensed under the Apache License, Version 2.0
 * http://www.apache.org/licenses/LICENSE-2.0 */
package io.github.mmm.base.impl;

import java.util.Iterator;

import io.github.mmm.base.lang.Composable;

/**
 * {@link Iterator} for {@link Composable}.
 *
 * @param  type of iterated children.
 *
 * @since 1.0.0
 */
public class ComposableIterator implements Iterator {

  private final Composable composable;

  private int index;

  /**
   * The constructor.
   * 
   * @param composable the {@link Composable} to iterate.
   */
  public ComposableIterator(Composable composable) {

    super();
    this.composable = composable;
    this.index = 0;
  }

  @Override
  public boolean hasNext() {

    return (this.index < this.composable.getChildCount());
  }

  @Override
  public C next() {

    C result = this.composable.getChild(this.index);
    this.index++;
    return result;
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy