System.out.println(response.count()); } catch (DynamoDbException e) { System.err.println(e.getMessage());
/** * 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("QueryResponse").add("Items", items()).add("Count", count()).add("ScannedCount", scannedCount()) .add("LastEvaluatedKey", lastEvaluatedKey()).add("ConsumedCapacity", consumedCapacity()).build(); }
@Override public int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + Objects.hashCode(items()); hashCode = 31 * hashCode + Objects.hashCode(count()); hashCode = 31 * hashCode + Objects.hashCode(scannedCount()); hashCode = 31 * hashCode + Objects.hashCode(lastEvaluatedKey()); hashCode = 31 * hashCode + Objects.hashCode(consumedCapacity()); return hashCode; }
public <T> Optional<T> getValueForField(String fieldName, Class<T> clazz) { switch (fieldName) { case "Items": return Optional.ofNullable(clazz.cast(items())); case "Count": return Optional.ofNullable(clazz.cast(count())); case "ScannedCount": return Optional.ofNullable(clazz.cast(scannedCount())); case "LastEvaluatedKey": return Optional.ofNullable(clazz.cast(lastEvaluatedKey())); case "ConsumedCapacity": return Optional.ofNullable(clazz.cast(consumedCapacity())); default: return Optional.empty(); } }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof QueryResponse)) { return false; } QueryResponse other = (QueryResponse) obj; return Objects.equals(items(), other.items()) && Objects.equals(count(), other.count()) && Objects.equals(scannedCount(), other.scannedCount()) && Objects.equals(lastEvaluatedKey(), other.lastEvaluatedKey()) && Objects.equals(consumedCapacity(), other.consumedCapacity()); }