/** * Returns a clone (as deep as possible) of this request object. */ @Override public EncryptedPutObjectRequest clone() { final EncryptedPutObjectRequest cloned = new EncryptedPutObjectRequest( getBucketName(), getKey(), getFile()); super.copyPutObjectBaseTo(cloned); final Map<String, String> materialsDescription = getMaterialsDescription(); cloned.withMaterialsDescription(materialsDescription == null ? null : new HashMap<String, String>(materialsDescription)); return cloned; }
@Test public void cloneEncryptedPutObjectRequest() { final File file = new File("somefile"); // null material description EncryptedPutObjectRequest clone = doTestClone( new EncryptedPutObjectRequest("bucket", "key", file), "bucket", "key", file); assertNull(clone.getMaterialsDescription()); // non-null material description Map<String,String> md = new HashMap<String, String>(); md.put("foo", "bar"); md = Collections.unmodifiableMap(md); clone = doTestClone( new EncryptedPutObjectRequest("bucket", "key", file).withMaterialsDescription(md), "bucket", "key", file); assertEquals(clone.getMaterialsDescription(), md); assertNotSame(clone.getMaterialsDescription(), md); }
/** * Returns a clone (as deep as possible) of this request object. */ @Override public EncryptedPutObjectRequest clone() { final EncryptedPutObjectRequest cloned = new EncryptedPutObjectRequest( getBucketName(), getKey(), getFile()); super.copyPutObjectBaseTo(cloned); final Map<String, String> materialsDescription = getMaterialsDescription(); cloned.withMaterialsDescription(materialsDescription == null ? null : new HashMap<String, String>(materialsDescription)); return cloned; }
/** * Returns a clone (as deep as possible) of this request object. */ @Override public EncryptedPutObjectRequest clone() { final EncryptedPutObjectRequest cloned = new EncryptedPutObjectRequest( getBucketName(), getKey(), getFile()); super.copyPutObjectBaseTo(cloned); final Map<String, String> materialsDescription = getMaterialsDescription(); cloned.withMaterialsDescription(materialsDescription == null ? null : new HashMap<String, String>(materialsDescription)) ; return cloned; } }