// Path: services-core/src/main/java/io/plumery/core/CommandHandler.java
// public interface CommandHandler <T extends Command> extends ActionHandler<T> {
//     public void handle(T command);
// }
// 
// Path: services-core/src/main/java/io/plumery/core/infrastructure/Repository.java
// public interface Repository<T extends AggregateRoot> {
//     public void save(T message, int version);
//     public T getById(ID id);
// }
// 
// Path: services-inventoryitem-domain/src/main/java/io/plumery/inventoryitem/core/command/CheckInItemsToInventory.java
// public class CheckInItemsToInventory extends Command {
//     public final ID inventoryItemId;
//     public final Integer count;
// 
//     public CheckInItemsToInventory(ID inventoryItemId, Integer count, Integer originalVersion) {
//         this.inventoryItemId = inventoryItemId;
//         this.count = count;
//         this.originalVersion = originalVersion;
//     }
// }
// 
// Path: services-inventoryitem-domain/src/main/java/io/plumery/inventoryitem/core/domain/InventoryItem.java
// public class InventoryItem extends AggregateRoot {
//     private Boolean activated;
//     private String name;
// 
//     @SuppressWarnings("unused")
//     private InventoryItem() {}
// 
//     public InventoryItem(ID id, String name) {
//         InventoryItemCreated e = new InventoryItemCreated()
//             .withName(name);
//         e.id = id;
//         applyChange(e);
//     }
// 
// 
//     public void changeName(String newName) {
//         if (isNullOrEmpty(newName)) throw new InvalidArgumentException("'newName' should be provided", this.id, version);
// 
//         InventoryItemRenamed e = new InventoryItemRenamed()
//                 .withNewName(newName);
//         e.id = id;
//         applyChange(e);
//     }
// 
//     public void remove(Integer count) {
//         if (count <= 0) throw new InvalidStateException("cant remove negative count from inventory", this.id, version);
//         applyChange(new ItemsRemovedFromInventory(id, count));
//     }
// 
// 
//     public void checkIn(Integer count) {
//         if (count <= 0) throw new InvalidStateException("must have a count greater than 0 to add to inventory", this.id, version);
//         applyChange(new ItemsCheckedInToInventory(id, count));
//     }
// 
//     public void deactivate() {
//         if(!activated) throw new InvalidStateException("already deactivated", this.id, version);
// 
//         InventoryItemDeactivated e = new InventoryItemDeactivated();
//         e.id = id;
//         applyChange(e);
//     }
// 
// 
//     private void apply(InventoryItemRenamed e) {
//         name = e.getNewName();
//     }
// 
//     private void apply(InventoryItemCreated e) {
//         id = e.id;
//         activated = true;
//     }
// 
//     private void apply(InventoryItemDeactivated e) {
//         activated = false;
//     }
// }


import io.plumery.core.CommandHandler;
import io.plumery.core.infrastructure.Repository;
import io.plumery.inventoryitem.core.command.CheckInItemsToInventory;
import io.plumery.inventoryitem.core.domain.InventoryItem;
package io.plumery.inventoryitem.core.command.handler;


public class CheckInItemsToIventoryHandler implements CommandHandler<CheckInItemsToInventory> {
    private Repository<InventoryItem> repository;

    public CheckInItemsToIventoryHandler(Repository<InventoryItem> repository) {
        this.repository = repository;
    }

    @Override
    public void handle(CheckInItemsToInventory command) {
// Path: services-core/src/main/java/io/plumery/core/CommandHandler.java
// public interface CommandHandler <T extends Command> extends ActionHandler<T> {
//     public void handle(T command);
// }
// 
// Path: services-core/src/main/java/io/plumery/core/infrastructure/Repository.java
// public interface Repository<T extends AggregateRoot> {
//     public void save(T message, int version);
//     public T getById(ID id);
// }
// 
// Path: services-inventoryitem-domain/src/main/java/io/plumery/inventoryitem/core/command/CheckInItemsToInventory.java
// public class CheckInItemsToInventory extends Command {
//     public final ID inventoryItemId;
//     public final Integer count;
// 
//     public CheckInItemsToInventory(ID inventoryItemId, Integer count, Integer originalVersion) {
//         this.inventoryItemId = inventoryItemId;
//         this.count = count;
//         this.originalVersion = originalVersion;
//     }
// }
// 
// Path: services-inventoryitem-domain/src/main/java/io/plumery/inventoryitem/core/domain/InventoryItem.java
// public class InventoryItem extends AggregateRoot {
//     private Boolean activated;
//     private String name;
// 
//     @SuppressWarnings("unused")
//     private InventoryItem() {}
// 
//     public InventoryItem(ID id, String name) {
//         InventoryItemCreated e = new InventoryItemCreated()
//             .withName(name);
//         e.id = id;
//         applyChange(e);
//     }
// 
// 
//     public void changeName(String newName) {
//         if (isNullOrEmpty(newName)) throw new InvalidArgumentException("'newName' should be provided", this.id, version);
// 
//         InventoryItemRenamed e = new InventoryItemRenamed()
//                 .withNewName(newName);
//         e.id = id;
//         applyChange(e);
//     }
// 
//     public void remove(Integer count) {
//         if (count <= 0) throw new InvalidStateException("cant remove negative count from inventory", this.id, version);
//         applyChange(new ItemsRemovedFromInventory(id, count));
//     }
// 
// 
//     public void checkIn(Integer count) {
//         if (count <= 0) throw new InvalidStateException("must have a count greater than 0 to add to inventory", this.id, version);
//         applyChange(new ItemsCheckedInToInventory(id, count));
//     }
// 
//     public void deactivate() {
//         if(!activated) throw new InvalidStateException("already deactivated", this.id, version);
// 
//         InventoryItemDeactivated e = new InventoryItemDeactivated();
//         e.id = id;
//         applyChange(e);
//     }
// 
// 
//     private void apply(InventoryItemRenamed e) {
//         name = e.getNewName();
//     }
// 
//     private void apply(InventoryItemCreated e) {
//         id = e.id;
//         activated = true;
//     }
// 
//     private void apply(InventoryItemDeactivated e) {
//         activated = false;
//     }
// }


// Path: services-inventoryitem-domain/src/main/java/io/plumery/inventoryitem/core/command/handler/CheckInItemsToIventoryHandler.java
import io.plumery.core.CommandHandler;
import io.plumery.core.infrastructure.Repository;
import io.plumery.inventoryitem.core.command.CheckInItemsToInventory;
import io.plumery.inventoryitem.core.domain.InventoryItem;

package io.plumery.inventoryitem.core.command.handler;


public class CheckInItemsToIventoryHandler implements CommandHandler<CheckInItemsToInventory> {
    private Repository<InventoryItem> repository;

    public CheckInItemsToIventoryHandler(Repository<InventoryItem> repository) {
        this.repository = repository;
    }

    @Override
    public void handle(CheckInItemsToInventory command) {
        InventoryItem item = repository.getById(command.inventoryItemId);