// Path: myeslib-core/src/main/java/org/myeslib/core/AggregateRoot.java
// public interface AggregateRoot extends Serializable {
// 
// }
// 
// Path: myeslib-core/src/main/java/org/myeslib/core/Command.java
// public interface Command extends Serializable {
// 	
//     UUID getCommandId();
// 	Long getTargetVersion();
// 	
// }
// 
// Path: myeslib-core/src/main/java/org/myeslib/core/CommandHandler.java
// public interface CommandHandler<C extends Command> {
//     
//     List<? extends Event> handle(C command);
// 
// }
// 
// Path: myeslib-core/src/main/java/org/myeslib/core/Event.java
// public interface Event extends Serializable {
// 	
// }


import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Delegate;
import lombok.NonNull;
import lombok.Value;
import org.myeslib.core.AggregateRoot;
import org.myeslib.core.Command;
import org.myeslib.core.CommandHandler;
import org.myeslib.core.Event;
import com.google.common.base.Function;

        @Delegate @NonNull
        final InventoryItemAggregateRoot aggregateRoot;

        public List<? extends Event> handle(IncreaseInventory command) {
            checkArgument(getId() != null, "before increasing you must create an item");
            checkArgument(getId().equals(command.getId()), "item id does not match");
            InventoryIncreased event = new InventoryIncreased(command.getId(), command.getHowMany());
            return Arrays.asList(event);
        }
    }
    
    @AllArgsConstructor
    public static class DecreaseCommandHandler implements CommandHandler<DecreaseInventory> {

        @Delegate @NonNull
        final InventoryItemAggregateRoot aggregateRoot;

        public List<? extends Event> handle(DecreaseInventory command) {
            checkArgument(getId() != null, "before decreasing you must create an item");
            checkArgument(getId().equals(command.getId()), "item id does not match");
            checkArgument(isAvailable(command.howMany), "there are not enough items available");
            InventoryDecreased event = new InventoryDecreased(command.getId(), command.getHowMany());
            return Arrays.asList(event);
        }
    }
    
    // commands

    @Value
// Path: myeslib-core/src/main/java/org/myeslib/core/AggregateRoot.java
// public interface AggregateRoot extends Serializable {
// 
// }
// 
// Path: myeslib-core/src/main/java/org/myeslib/core/Command.java
// public interface Command extends Serializable {
// 	
//     UUID getCommandId();
// 	Long getTargetVersion();
// 	
// }
// 
// Path: myeslib-core/src/main/java/org/myeslib/core/CommandHandler.java
// public interface CommandHandler<C extends Command> {
//     
//     List<? extends Event> handle(C command);
// 
// }
// 
// Path: myeslib-core/src/main/java/org/myeslib/core/Event.java
// public interface Event extends Serializable {
// 	
// }


// Path: inventory-aggregate-root/src/main/java/org/myeslib/example/SampleDomain.java
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Delegate;
import lombok.NonNull;
import lombok.Value;
import org.myeslib.core.AggregateRoot;
import org.myeslib.core.Command;
import org.myeslib.core.CommandHandler;
import org.myeslib.core.Event;
import com.google.common.base.Function;


        @Delegate @NonNull
        final InventoryItemAggregateRoot aggregateRoot;

        public List<? extends Event> handle(IncreaseInventory command) {
            checkArgument(getId() != null, "before increasing you must create an item");
            checkArgument(getId().equals(command.getId()), "item id does not match");
            InventoryIncreased event = new InventoryIncreased(command.getId(), command.getHowMany());
            return Arrays.asList(event);
        }
    }
    
    @AllArgsConstructor
    public static class DecreaseCommandHandler implements CommandHandler<DecreaseInventory> {

        @Delegate @NonNull
        final InventoryItemAggregateRoot aggregateRoot;

        public List<? extends Event> handle(DecreaseInventory command) {
            checkArgument(getId() != null, "before decreasing you must create an item");
            checkArgument(getId().equals(command.getId()), "item id does not match");
            checkArgument(isAvailable(command.howMany), "there are not enough items available");
            InventoryDecreased event = new InventoryDecreased(command.getId(), command.getHowMany());
            return Arrays.asList(event);
        }
    }
    
    // commands

    @Value
    public static class CreateInventoryItem implements Command {