1 /* 2 * $Id: MessageSequence.java 22272 2011-06-27 16:17:16Z mike.schilling $ 3 * -------------------------------------------------------------------------------------- 4 * Copyright (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.com 5 * 6 * The software in this package is published under the terms of the CPAL v1.0 7 * license, a copy of which has been included with this distribution in the 8 * LICENSE.txt file. 9 */ 10 11 package org.mule.routing; 12 13 import java.util.Iterator; 14 15 /** 16 * A sequence of messages 17 * 18 * @author flbulgarelli 19 * @param <T> the message payload type 20 */ 21 public interface MessageSequence<T> extends Iterator<T> 22 { 23 int UNKNOWN_SIZE = -1; 24 25 /** 26 * If the sequence is empty 27 * 28 * @return !hasNext() 29 */ 30 boolean isEmpty(); 31 32 /** 33 * The number of members of the sequence. If this is unknown, return UNKNOWN_ELEMENTS_COUNT. 34 * 35 * @return The estimated size of the sequence, or {@link #UNKNOWN_SIZE}, 36 * if it is unknown 37 */ 38 int size(); 39 40 /** 41 * Whether this sequence has more elements. 42 * 43 * @see Iterator#hasNext() 44 */ 45 @Override 46 public boolean hasNext(); 47 48 /** 49 * The next element of the sequence. At any moment, if 50 * {@link #size()} is not equal to 51 * {@link #UNKNOWN_SIZE}, this means that this method may be invoked 52 * approximately up to {@link #size()} times. 53 */ 54 @Override 55 public T next(); 56 57 /** 58 * Unsupported operation. 59 * {@link MessageSequence} do not allow removal of elements. 60 */ 61 @Override 62 public void remove(); 63 }