package org.leumasjaffe.charsheet.model.inventory; import java.util.Collections; import java.util.HashMap; import java.util.Map; import org.leumasjaffe.charsheet.model.observable.IntValue; import org.leumasjaffe.charsheet.model.observable.StringValue; import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnySetter; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; import lombok.experimental.FieldDefaults; @AllArgsConstructor @Data @NoArgsConstructor @FieldDefaults(level=AccessLevel.PRIVATE) public class DDItem { String name = ""; IntValue count = new IntValue(1); int countEquipped = 0; IntValue weight = new IntValue(0); Money value = new Money(0, 0, 0, 0); StringValue page = new StringValue(); EquipmentSlot slot = EquipmentSlot.NONE; DDWeapon weapon = null; DDArmor armor = null; Map properties = new HashMap<>(); public boolean isWeapon() { return weapon != null; } public boolean isArmor() { return armor != null; } @SuppressWarnings("unchecked") public T getProperty(final String key) { return (T) properties.get(key); } @JsonAnySetter public void setProperty(final String key, final Object prop) { if ( properties == null ) { properties = new HashMap<>(); } properties.put(key, prop); } @JsonAnyGetter private Map getProperties() { return Collections.unmodifiableMap(properties); } public int getUnequippedCount() { return count.value() - countEquipped; } }