@Override public int hashCode() { if (attributeModifiers == null) getModifiers(); return Objects.hashCode(getAttributeKey(), getBaseValue(), attributeModifiers); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj instanceof WrappedAttribute) { WrappedAttribute other = (WrappedAttribute) obj; if (getBaseValue() == other.getBaseValue() && Objects.equal(getAttributeKey(), other.getAttributeKey())) { return getModifiers().stream() .filter((elem) -> !other.getModifiers().contains(elem)) .count() == 0; } } return false; }
/** * Determine if the attribute has a given attribute modifier, identified by UUID. * @param id - the id to check for. * @return TRUE if it does, FALSE otherwise. */ public boolean hasModifier(UUID id) { return getModifiers().contains(WrappedAttributeModifier.newBuilder(id).build()); }
/** * Retrieve an attribute modifier by UUID. * @param id - the id to look for. * @return The single attribute modifier with the given ID. */ public WrappedAttributeModifier getModifierByUUID(UUID id) { if (hasModifier(id)) { for (WrappedAttributeModifier modifier : getModifiers()) { if (Objects.equal(modifier.getUUID(), id)) { return modifier; } } } return null; }
private Builder(WrappedAttribute template) { if (template != null) { baseValue = template.getBaseValue(); attributeKey = template.getAttributeKey(); packet = template.getParentPacket(); modifiers = template.getModifiers(); } }
@Override public String toString() { return "WrappedAttribute[key=" + getAttributeKey() + ", base=" + getBaseValue() + ", final=" + getFinalValue() + ", modifiers=" + getModifiers() + "]"; }
Collection<WrappedAttributeModifier> modifiers = getModifiers(); double x = getBaseValue(); double y = 0;