de.schlichtherle.truezip.entry.EntryContainer Maven / Gradle / Ivy
/*
* Copyright (C) 2005-2015 Schlichtherle IT Services.
* All rights reserved. Use is subject to license terms.
*/
package de.schlichtherle.truezip.entry;
import java.util.Iterator;
import javax.annotation.CheckForNull;
/**
* An iterable container for entries.
*
* @param the type of the entries in this container.
* @author Christian Schlichtherle
*/
public interface EntryContainer
extends Iterable {
/**
* Returns the number of entries in this container.
*
* @return The number of entries in this container.
*/
// TODO: Rename this to size().
int getSize();
/**
* Returns a new iterator for all entries in this container.
*
* First, the iteration must be consistent: Multiple iterators
* must iterate the same entries in the same order again unless the set
* of entries has changed.
*
* Next, the iteration should also reflect the natural order of
* the entries in this container.
* For example, if this container represents an archive file, the iteration
* should reflect the natural order of the entries in the archive file.
*
* @return A new iterator for all entries in this container.
*/
@Override
Iterator iterator();
/**
* Returns the entry for the given {@link Entry#getName() name} or
* {@code null} if no entry with this name exists in this container.
*
* @param name an entry name.
* @return The entry for the given {@link Entry#getName() name} or
* {@code null} if no entry with this name exists in this container.
*/
@CheckForNull E getEntry(String name);
}