package io.plumery.inventoryitem.core.domain;

import io.plumery.core.AggregateRoot;
import io.plumery.core.ID;
import io.plumery.inventoryitem.core.domain.event.InventoryItemDeactivated;
import io.plumery.inventoryitem.core.domain.event.InventoryItemRenamed;
import io.plumery.inventoryitem.core.domain.event.ItemsCheckedInToInventory;
import io.plumery.inventoryitem.core.domain.event.ItemsRemovedFromInventory;
import io.plumery.inventoryitem.core.events.InventoryItemCreated;

import static com.google.common.base.Strings.isNullOrEmpty;

public class InventoryItem extends AggregateRoot {
    private Boolean activated;

    @SuppressWarnings("unused")
    private InventoryItem() {}

    public InventoryItem(ID id, String name) {
        InventoryItemCreated event = new InventoryItemCreated()
            .withName(name)
            .withInventoryItemId(id.toString());

        applyChange(event);
    }


    public void changeName(String newName) {
        if (isNullOrEmpty(newName)) throw new IllegalArgumentException("newName");
        applyChange(new InventoryItemRenamed(id, newName));
    }

    public void remove(Integer count) {
        if (count <= 0) throw new IllegalStateException("cant remove negative count from inventory");
        applyChange(new ItemsRemovedFromInventory(id, count));
    }


    public void checkIn(Integer count) {
        if (count <= 0) throw new IllegalStateException("must have a count greater than 0 to add to inventory");
        applyChange(new ItemsCheckedInToInventory(id, count));
    }

    public void deactivate() {
        if(!activated) throw new IllegalStateException("already deactivated");
        applyChange(new InventoryItemDeactivated(id));
    }

    private void apply(InventoryItemCreated e) {
        id = e.id;
        activated = true;
    }

    private void apply(InventoryItemDeactivated e) {
        activated = false;
    }
}

@@ -616,16 +616,41 @@
 tivated;
+%0A    private String name;
 %0A%0A    @S
@@ -845,16 +845,17 @@
 me(name)
+;
 %0A       
@@ -859,47 +859,21 @@
     
-    .withInventoryItemId(id.toString())
+event.id = id
 ;%0A%0A 
@@ -1703,32 +1703,115 @@
 ed(id));%0A    %7D%0A%0A
+%0A    private void apply(InventoryItemRenamed e) %7B%0A        name = e.newName;%0A    %7D%0A%0A
     private void

Add missing apply method