// Path: src/main/java/com/cqrs/appengine/core/exceptions/HydrationException.java
// public class HydrationException extends AggregateException {
// 
//     private static final String ERROR_TEXT = "Loading the data failed";
// 
//     private static final long serialVersionUID = 1L;
// 
//     /**
//      * Default constructor
//      * 
//      * @param aggregateId
//      */
//     public HydrationException(UUID aggregateId){
//         super(aggregateId, ERROR_TEXT);
//     }
// 
//     /**
//      * Constructor to provide specific error reason for the hydration exception
//      * 
//      * @param aggregateId
//      * @param error
//      */
//     public HydrationException(UUID aggregateId, String error){
//         super(aggregateId, error);
//     }
// }
// 
// Path: src/main/java/com/cqrs/appengine/core/messaging/Event.java
// public interface Event {
// 
// }


import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import com.cqrs.appengine.core.exceptions.HydrationException;
import com.cqrs.appengine.core.messaging.Event;
package com.cqrs.appengine.core.domain;



/**
 * Base class for aggregate root implementations
 */
public abstract class AggregateRootBase implements AggregateRoot {

    /**
     * Aggregate id
     */
    protected UUID id = null;

    /**
     * list of changes that have occurred since last loaded
     */
    private List<Event> changes = new ArrayList<Event>();

    /**
     * returns the expected version
     */
    private int expectedVersion = 0;

    @Override
    public int getExpectedVersion(){
        return expectedVersion;
    }

    @Override
    public void markChangesAsCommitted(){
        changes.clear();
    } 

    @Override
    public UUID getId(){
        return id;
    }

    @Override
    public Iterable<Event> getUncommittedChanges(){
        return changes == null || changes.isEmpty() ? null : changes;
    }

    @Override
// Path: src/main/java/com/cqrs/appengine/core/exceptions/HydrationException.java
// public class HydrationException extends AggregateException {
// 
//     private static final String ERROR_TEXT = "Loading the data failed";
// 
//     private static final long serialVersionUID = 1L;
// 
//     /**
//      * Default constructor
//      * 
//      * @param aggregateId
//      */
//     public HydrationException(UUID aggregateId){
//         super(aggregateId, ERROR_TEXT);
//     }
// 
//     /**
//      * Constructor to provide specific error reason for the hydration exception
//      * 
//      * @param aggregateId
//      * @param error
//      */
//     public HydrationException(UUID aggregateId, String error){
//         super(aggregateId, error);
//     }
// }
// 
// Path: src/main/java/com/cqrs/appengine/core/messaging/Event.java
// public interface Event {
// 
// }


// Path: src/main/java/com/cqrs/appengine/core/domain/AggregateRootBase.java
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import com.cqrs.appengine.core.exceptions.HydrationException;
import com.cqrs.appengine.core.messaging.Event;

package com.cqrs.appengine.core.domain;



/**
 * Base class for aggregate root implementations
 */
public abstract class AggregateRootBase implements AggregateRoot {

    /**
     * Aggregate id
     */
    protected UUID id = null;

    /**
     * list of changes that have occurred since last loaded
     */
    private List<Event> changes = new ArrayList<Event>();

    /**
     * returns the expected version
     */
    private int expectedVersion = 0;

    @Override
    public int getExpectedVersion(){
        return expectedVersion;
    }

    @Override
    public void markChangesAsCommitted(){
        changes.clear();
    } 

    @Override
    public UUID getId(){
        return id;
    }

    @Override
    public Iterable<Event> getUncommittedChanges(){
        return changes == null || changes.isEmpty() ? null : changes;
    }

    @Override
    public void loadFromHistory(Iterable<Event> history) throws HydrationException {