// 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;
package org.myeslib.example;






@SuppressWarnings("serial")
public class SampleDomain {

    @Data
    public static class InventoryItemAggregateRoot implements AggregateRoot {

        UUID id;
        String description;
        Integer available = 0;

        public void on(InventoryItemCreated event) {
            this.id = event.id;
            this.description = event.description;
            this.available = 0;
        }

        public void on(InventoryIncreased event) {
            this.available = this.available + event.howMany;
        }

        public void on(InventoryDecreased event) {
            this.available = this.available - event.howMany;
        }
        
        public boolean isAvailable(int howMany) {
            return getAvailable() - howMany >= 0;
        }

    }
    
    // command handlers

    @AllArgsConstructor
// 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;

package org.myeslib.example;






@SuppressWarnings("serial")
public class SampleDomain {

    @Data
    public static class InventoryItemAggregateRoot implements AggregateRoot {

        UUID id;
        String description;
        Integer available = 0;

        public void on(InventoryItemCreated event) {
            this.id = event.id;
            this.description = event.description;
            this.available = 0;
        }

        public void on(InventoryIncreased event) {
            this.available = this.available + event.howMany;
        }

        public void on(InventoryDecreased event) {
            this.available = this.available - event.howMany;
        }
        
        public boolean isAvailable(int howMany) {
            return getAvailable() - howMany >= 0;
        }

    }
    
    // command handlers

    @AllArgsConstructor
    public static class CreateCommandHandler implements CommandHandler<CreateInventoryItem> {