Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright (c) 2010-2011. Axon Framework
   *
   * 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.axonframework.domain;
 
Creates a DomainEventStream that streams the contents of a list.

Author(s):
Allard Buijze
Since:
0.1
 
 public class SimpleDomainEventStream implements DomainEventStream {
 
     private static final DomainEventStream EMPTY_STREAM = new SimpleDomainEventStream();
 
     private int nextIndex;
     private final DomainEvent[] events;

    
Initialize the event stream using the given List of DomainEvent and aggregate identifier.

Parameters:
events the list of domain events to stream
Throws:
java.lang.IllegalArgumentException if the given list is empty
 
     public SimpleDomainEventStream(Collection<? extends DomainEventevents) {
         this(events.toArray(new DomainEvent[events.size()]));
     }

    
Initialize the event stream using the given DomainEvents and aggregate identifier. The aggregate identifier is initialized by reading it from the first event available. Therefore, you must provide at least one event.

Parameters:
events the list of domain events to stream
Throws:
java.lang.IllegalArgumentException if no events are supplied
 
     public SimpleDomainEventStream(DomainEvent... events) {
         this. = Arrays.copyOfRange(events, 0, events.length);
     }

    
 
     @Override
     public boolean hasNext() {
         return . > ;
     }

    

Throws:
java.util.NoSuchElementException when no items exist after the current pointer in the stream
 
     @Override
     public DomainEvent next() {
         if (!hasNext()) {
             throw new NoSuchElementException("Trying to peek beyond the limits of this stream.");
         }
         return [++];
     }

    

Throws:
java.util.NoSuchElementException when no items exist after the current pointer in the stream
 
     @Override
     public DomainEvent peek() {
         if (!hasNext()) {
             throw new NoSuchElementException("Trying to peek beyond the limits of this stream.");
         }
         return [];
     }

    
Append the contents of this stream to the given collection. This includes all events that have already been read from the stream.

Parameters:
collection the collection to append the events to.
 
    public void appendTo(Collection<DomainEventcollection) {
        collection.addAll(Arrays.asList());
    }

    
Creates an empty stream. For performance reasons, this method always returns the same instance.

Returns:
en empty DomainEventStream
    public static DomainEventStream emptyStream() {
        return ;
    }
New to GrepCode? Check out our FAQ X