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

xapi.collect.impl.EntryKeyAdapter Maven / Gradle / Ivy

package xapi.collect.impl;

import java.util.Iterator;
import java.util.Map.Entry;

public class EntryKeyAdapter  implements Iterable {

  private class KeyIterator implements Iterator{
    private Iterator> source;
    public KeyIterator(Iterator> source) {
      this.source = source;
    }
    @Override
    public boolean hasNext() {
      return source.hasNext();
    }
    @Override
    public K next() {
      return source.next().getKey();
    }
    @Override
    public void remove() {
      source.remove();
    }
  }

  private Iterable> source;

  public EntryKeyAdapter(Iterable> source) {
    this.source = source;
  }

  @Override
  public Iterator iterator() {
    return new KeyIterator(source.iterator());
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy