/** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. */ @Override public String toString() { return ToString.builder("AttributeValue").add("S", s()).add("N", n()).add("B", b()).add("SS", ss()).add("NS", ns()) .add("BS", bs()).add("M", m()).add("L", l()).add("BOOL", bool()).add("NUL", nul()).build(); }
@Override public int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + Objects.hashCode(s()); hashCode = 31 * hashCode + Objects.hashCode(n()); hashCode = 31 * hashCode + Objects.hashCode(b()); hashCode = 31 * hashCode + Objects.hashCode(ss()); hashCode = 31 * hashCode + Objects.hashCode(ns()); hashCode = 31 * hashCode + Objects.hashCode(bs()); hashCode = 31 * hashCode + Objects.hashCode(m()); hashCode = 31 * hashCode + Objects.hashCode(l()); hashCode = 31 * hashCode + Objects.hashCode(bool()); hashCode = 31 * hashCode + Objects.hashCode(nul()); return hashCode; }
public <T> Optional<T> getValueForField(String fieldName, Class<T> clazz) { switch (fieldName) { case "S": return Optional.ofNullable(clazz.cast(s())); case "N": return Optional.ofNullable(clazz.cast(n())); case "B": return Optional.ofNullable(clazz.cast(b())); case "SS": return Optional.ofNullable(clazz.cast(ss())); case "NS": return Optional.ofNullable(clazz.cast(ns())); case "BS": return Optional.ofNullable(clazz.cast(bs())); case "M": return Optional.ofNullable(clazz.cast(m())); case "L": return Optional.ofNullable(clazz.cast(l())); case "BOOL": return Optional.ofNullable(clazz.cast(bool())); case "NUL": return Optional.ofNullable(clazz.cast(nul())); default: return Optional.empty(); } }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof AttributeValue)) { return false; } AttributeValue other = (AttributeValue) obj; return Objects.equals(s(), other.s()) && Objects.equals(n(), other.n()) && Objects.equals(b(), other.b()) && Objects.equals(ss(), other.ss()) && Objects.equals(ns(), other.ns()) && Objects.equals(bs(), other.bs()) && Objects.equals(m(), other.m()) && Objects.equals(l(), other.l()) && Objects.equals(bool(), other.bool()) && Objects.equals(nul(), other.nul()); }