/** * 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("S3Object").add("Key", key()).add("LastModified", lastModified()).add("ETag", eTag()) .add("Size", size()).add("StorageClass", storageClassAsString()).add("Owner", owner()).build(); }
@Override public int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + Objects.hashCode(key()); hashCode = 31 * hashCode + Objects.hashCode(lastModified()); hashCode = 31 * hashCode + Objects.hashCode(eTag()); hashCode = 31 * hashCode + Objects.hashCode(size()); hashCode = 31 * hashCode + Objects.hashCode(storageClassAsString()); hashCode = 31 * hashCode + Objects.hashCode(owner()); return hashCode; }
public <T> Optional<T> getValueForField(String fieldName, Class<T> clazz) { switch (fieldName) { case "Key": return Optional.ofNullable(clazz.cast(key())); case "LastModified": return Optional.ofNullable(clazz.cast(lastModified())); case "ETag": return Optional.ofNullable(clazz.cast(eTag())); case "Size": return Optional.ofNullable(clazz.cast(size())); case "StorageClass": return Optional.ofNullable(clazz.cast(storageClassAsString())); case "Owner": return Optional.ofNullable(clazz.cast(owner())); default: return Optional.empty(); } }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof S3Object)) { return false; } S3Object other = (S3Object) obj; return Objects.equals(key(), other.key()) && Objects.equals(lastModified(), other.lastModified()) && Objects.equals(eTag(), other.eTag()) && Objects.equals(size(), other.size()) && Objects.equals(storageClassAsString(), other.storageClassAsString()) && Objects.equals(owner(), other.owner()); }