@Test public void testSerialize() { PathAttributes attributes = new PathAttributes(); PathAttributes clone = new PathAttributesDictionary().deserialize(attributes.serialize(SerializerFactory.get())); assertEquals(clone.getPermission(), attributes.getPermission()); assertEquals(clone.getModificationDate(), attributes.getModificationDate()); }
public <T> PathAttributes deserialize(T serialized) { final Deserializer dict = factory.create(serialized); final PathAttributes attributes = new PathAttributes(); final String sizeObj = dict.stringForKey("Size"); if(sizeObj != null) { attributes.setSize(Long.parseLong(sizeObj)); } final String quotaObj = dict.stringForKey("Quota"); if(quotaObj != null) { attributes.setQuota(Long.parseLong(quotaObj)); } final String modifiedObj = dict.stringForKey("Modified"); if(modifiedObj != null) { attributes.setModificationDate(Long.parseLong(modifiedObj)); } final String revisionObj = dict.stringForKey("Revision"); if(revisionObj != null) { attributes.setRevision(Long.parseLong(revisionObj)); } final List<T> versionsObj = dict.listForKey("Versions"); if(versionsObj != null) { final AttributedList<Path> versions = new AttributedList<>(); for(T versionDict : versionsObj) { versions.add(new PathDictionary(factory).deserialize(versionDict)); } attributes.setVersions(versions); } final String etagObj = dict.stringForKey("ETag"); if(etagObj != null) { attributes.setETag(dict.stringForKey("ETag")); } final Object permissionObj = dict.objectForKey("Permission"); if(permissionObj != null) { attributes.setPermission(new PermissionDictionary().deserialize(permissionObj)); } final Object aclObj = dict.objectForKey("Acl"); if(aclObj != null) { attributes.setAcl(new AclDictionary().deserialize(aclObj)); } final Object linkObj = dict.stringForKey("Link"); if(linkObj != null) { attributes.setLink(new DescriptiveUrl(URI.create(dict.stringForKey("Link")), DescriptiveUrl.Type.http)); } if(dict.mapForKey("Checksum") != null) { final Map<String, String> checksum = dict.mapForKey("Checksum"); attributes.setChecksum(new Checksum(HashAlgorithm.valueOf(checksum.get("Algorithm")), checksum.get("Hash"))); } else { attributes.setChecksum(Checksum.parse(dict.stringForKey("Checksum"))); } attributes.setVersionId(dict.stringForKey("Version")); attributes.setLockId(dict.stringForKey("Lock Id")); final String duplicateObj = dict.stringForKey("Duplicate"); if(duplicateObj != null) { attributes.setDuplicate(Boolean.valueOf(duplicateObj)); } final String hiddenObj = dict.stringForKey("Hidden"); if(hiddenObj != null) { attributes.setHidden(Boolean.valueOf(hiddenObj)); } attributes.setMetadata(Collections.emptyMap()); attributes.setRegion(dict.stringForKey("Region")); attributes.setStorageClass(dict.stringForKey("Storage Class")); final Object vaultObj = dict.objectForKey("Vault"); if(vaultObj != null) { attributes.setVault(new PathDictionary(factory).deserialize(vaultObj)); } return attributes; }
PathAttributesDictionary { public <T> PathAttributes deserialize(T serialized) { final Deserializer dict = factory.create(serialized); final PathAttributes attributes = new PathAttributes(); final String sizeObj = dict.stringForKey("Size"); if(sizeObj != null) { attributes.setSize(Long.parseLong(sizeObj)); } final String quotaObj = dict.stringForKey("Quota"); if(quotaObj != null) { attributes.setQuota(Long.parseLong(quotaObj)); } final String modifiedObj = dict.stringForKey("Modified"); if(modifiedObj != null) { attributes.setModificationDate(Long.parseLong(modifiedObj)); } final String revisionObj = dict.stringForKey("Revision"); if(revisionObj != null) { attributes.setRevision(Long.parseLong(revisionObj)); } final List<T> versionsObj = dict.listForKey("Versions"); if(versionsObj != null) { final AttributedList<Path> versions = new AttributedList<>(); for(T versionDict : versionsObj) { versions.add(new PathDictionary(factory).deserialize(versionDict)); } attributes.setVersions(versions); } final String etagObj = dict.stringForKey("ETag"); if(etagObj != null) { attributes.setETag(dict.stringForKey("ETag")); } final Object permissionObj = dict.objectForKey("Permission"); if(permissionObj != null) { attributes.setPermission(new PermissionDictionary().deserialize(permissionObj)); } final Object aclObj = dict.objectForKey("Acl"); if(aclObj != null) { attributes.setAcl(new AclDictionary().deserialize(aclObj)); } final Object linkObj = dict.stringForKey("Link"); if(linkObj != null) { attributes.setLink(new DescriptiveUrl(URI.create(dict.stringForKey("Link")), DescriptiveUrl.Type.http)); } if(dict.mapForKey("Checksum") != null) { final Map<String, String> checksum = dict.mapForKey("Checksum"); attributes.setChecksum(new Checksum(HashAlgorithm.valueOf(checksum.get("Algorithm")), checksum.get("Hash"))); } else { attributes.setChecksum(Checksum.parse(dict.stringForKey("Checksum"))); } attributes.setVersionId(dict.stringForKey("Version")); attributes.setLockId(dict.stringForKey("Lock Id")); final String duplicateObj = dict.stringForKey("Duplicate"); if(duplicateObj != null) { attributes.setDuplicate(Boolean.valueOf(duplicateObj)); } final String hiddenObj = dict.stringForKey("Hidden"); if(hiddenObj != null) { attributes.setHidden(Boolean.valueOf(hiddenObj)); } attributes.setMetadata(Collections.emptyMap()); attributes.setRegion(dict.stringForKey("Region")); attributes.setStorageClass(dict.stringForKey("Storage Class")); final Object vaultObj = dict.objectForKey("Vault"); if(vaultObj != null) { attributes.setVault(new PathDictionary(factory).deserialize(vaultObj)); } return attributes; } }
PathAttributesDictionary { public <T> PathAttributes deserialize(T serialized) { final Deserializer dict = factory.create(serialized); final PathAttributes attributes = new PathAttributes(); final String sizeObj = dict.stringForKey("Size"); if(sizeObj != null) { attributes.setSize(Long.parseLong(sizeObj)); } final String quotaObj = dict.stringForKey("Quota"); if(quotaObj != null) { attributes.setQuota(Long.parseLong(quotaObj)); } final String modifiedObj = dict.stringForKey("Modified"); if(modifiedObj != null) { attributes.setModificationDate(Long.parseLong(modifiedObj)); } final String revisionObj = dict.stringForKey("Revision"); if(revisionObj != null) { attributes.setRevision(Long.parseLong(revisionObj)); } final List<T> versionsObj = dict.listForKey("Versions"); if(versionsObj != null) { final AttributedList<Path> versions = new AttributedList<>(); for(T versionDict : versionsObj) { versions.add(new PathDictionary(factory).deserialize(versionDict)); } attributes.setVersions(versions); } final String etagObj = dict.stringForKey("ETag"); if(etagObj != null) { attributes.setETag(dict.stringForKey("ETag")); } final Object permissionObj = dict.objectForKey("Permission"); if(permissionObj != null) { attributes.setPermission(new PermissionDictionary().deserialize(permissionObj)); } final Object aclObj = dict.objectForKey("Acl"); if(aclObj != null) { attributes.setAcl(new AclDictionary().deserialize(aclObj)); } final Object linkObj = dict.stringForKey("Link"); if(linkObj != null) { attributes.setLink(new DescriptiveUrl(URI.create(dict.stringForKey("Link")), DescriptiveUrl.Type.http)); } if(dict.mapForKey("Checksum") != null) { final Map<String, String> checksum = dict.mapForKey("Checksum"); attributes.setChecksum(new Checksum(HashAlgorithm.valueOf(checksum.get("Algorithm")), checksum.get("Hash"))); } else { attributes.setChecksum(Checksum.parse(dict.stringForKey("Checksum"))); } attributes.setVersionId(dict.stringForKey("Version")); attributes.setLockId(dict.stringForKey("Lock Id")); final String duplicateObj = dict.stringForKey("Duplicate"); if(duplicateObj != null) { attributes.setDuplicate(Boolean.valueOf(duplicateObj)); } final String hiddenObj = dict.stringForKey("Hidden"); if(hiddenObj != null) { attributes.setHidden(Boolean.valueOf(hiddenObj)); } attributes.setMetadata(Collections.emptyMap()); attributes.setRegion(dict.stringForKey("Region")); attributes.setStorageClass(dict.stringForKey("Storage Class")); final Object vaultObj = dict.objectForKey("Vault"); if(vaultObj != null) { attributes.setVault(new PathDictionary(factory).deserialize(vaultObj)); } return attributes; } PathAttributesDictionary();  PathAttributesDictionary(final DeserializerFactory factory); }
PathAttributesDictionary { public <T> PathAttributes deserialize(T serialized) { final Deserializer dict = factory.create(serialized); final PathAttributes attributes = new PathAttributes(); final String sizeObj = dict.stringForKey("Size"); if(sizeObj != null) { attributes.setSize(Long.parseLong(sizeObj)); } final String quotaObj = dict.stringForKey("Quota"); if(quotaObj != null) { attributes.setQuota(Long.parseLong(quotaObj)); } final String modifiedObj = dict.stringForKey("Modified"); if(modifiedObj != null) { attributes.setModificationDate(Long.parseLong(modifiedObj)); } final String revisionObj = dict.stringForKey("Revision"); if(revisionObj != null) { attributes.setRevision(Long.parseLong(revisionObj)); } final List<T> versionsObj = dict.listForKey("Versions"); if(versionsObj != null) { final AttributedList<Path> versions = new AttributedList<>(); for(T versionDict : versionsObj) { versions.add(new PathDictionary(factory).deserialize(versionDict)); } attributes.setVersions(versions); } final String etagObj = dict.stringForKey("ETag"); if(etagObj != null) { attributes.setETag(dict.stringForKey("ETag")); } final Object permissionObj = dict.objectForKey("Permission"); if(permissionObj != null) { attributes.setPermission(new PermissionDictionary().deserialize(permissionObj)); } final Object aclObj = dict.objectForKey("Acl"); if(aclObj != null) { attributes.setAcl(new AclDictionary().deserialize(aclObj)); } final Object linkObj = dict.stringForKey("Link"); if(linkObj != null) { attributes.setLink(new DescriptiveUrl(URI.create(dict.stringForKey("Link")), DescriptiveUrl.Type.http)); } if(dict.mapForKey("Checksum") != null) { final Map<String, String> checksum = dict.mapForKey("Checksum"); attributes.setChecksum(new Checksum(HashAlgorithm.valueOf(checksum.get("Algorithm")), checksum.get("Hash"))); } else { attributes.setChecksum(Checksum.parse(dict.stringForKey("Checksum"))); } attributes.setVersionId(dict.stringForKey("Version")); attributes.setLockId(dict.stringForKey("Lock Id")); final String duplicateObj = dict.stringForKey("Duplicate"); if(duplicateObj != null) { attributes.setDuplicate(Boolean.valueOf(duplicateObj)); } final String hiddenObj = dict.stringForKey("Hidden"); if(hiddenObj != null) { attributes.setHidden(Boolean.valueOf(hiddenObj)); } attributes.setMetadata(Collections.emptyMap()); attributes.setRegion(dict.stringForKey("Region")); attributes.setStorageClass(dict.stringForKey("Storage Class")); final Object vaultObj = dict.objectForKey("Vault"); if(vaultObj != null) { attributes.setVault(new PathDictionary(factory).deserialize(vaultObj)); } return attributes; } PathAttributesDictionary();  PathAttributesDictionary(final DeserializerFactory factory); PathAttributes deserialize(T serialized); }
PathAttributesDictionary { public <T> PathAttributes deserialize(T serialized) { final Deserializer dict = factory.create(serialized); final PathAttributes attributes = new PathAttributes(); final String sizeObj = dict.stringForKey("Size"); if(sizeObj != null) { attributes.setSize(Long.parseLong(sizeObj)); } final String quotaObj = dict.stringForKey("Quota"); if(quotaObj != null) { attributes.setQuota(Long.parseLong(quotaObj)); } final String modifiedObj = dict.stringForKey("Modified"); if(modifiedObj != null) { attributes.setModificationDate(Long.parseLong(modifiedObj)); } final String revisionObj = dict.stringForKey("Revision"); if(revisionObj != null) { attributes.setRevision(Long.parseLong(revisionObj)); } final List<T> versionsObj = dict.listForKey("Versions"); if(versionsObj != null) { final AttributedList<Path> versions = new AttributedList<>(); for(T versionDict : versionsObj) { versions.add(new PathDictionary(factory).deserialize(versionDict)); } attributes.setVersions(versions); } final String etagObj = dict.stringForKey("ETag"); if(etagObj != null) { attributes.setETag(dict.stringForKey("ETag")); } final Object permissionObj = dict.objectForKey("Permission"); if(permissionObj != null) { attributes.setPermission(new PermissionDictionary().deserialize(permissionObj)); } final Object aclObj = dict.objectForKey("Acl"); if(aclObj != null) { attributes.setAcl(new AclDictionary().deserialize(aclObj)); } final Object linkObj = dict.stringForKey("Link"); if(linkObj != null) { attributes.setLink(new DescriptiveUrl(URI.create(dict.stringForKey("Link")), DescriptiveUrl.Type.http)); } if(dict.mapForKey("Checksum") != null) { final Map<String, String> checksum = dict.mapForKey("Checksum"); attributes.setChecksum(new Checksum(HashAlgorithm.valueOf(checksum.get("Algorithm")), checksum.get("Hash"))); } else { attributes.setChecksum(Checksum.parse(dict.stringForKey("Checksum"))); } attributes.setVersionId(dict.stringForKey("Version")); attributes.setLockId(dict.stringForKey("Lock Id")); final String duplicateObj = dict.stringForKey("Duplicate"); if(duplicateObj != null) { attributes.setDuplicate(Boolean.valueOf(duplicateObj)); } final String hiddenObj = dict.stringForKey("Hidden"); if(hiddenObj != null) { attributes.setHidden(Boolean.valueOf(hiddenObj)); } attributes.setMetadata(Collections.emptyMap()); attributes.setRegion(dict.stringForKey("Region")); attributes.setStorageClass(dict.stringForKey("Storage Class")); final Object vaultObj = dict.objectForKey("Vault"); if(vaultObj != null) { attributes.setVault(new PathDictionary(factory).deserialize(vaultObj)); } return attributes; } PathAttributesDictionary();  PathAttributesDictionary(final DeserializerFactory factory); PathAttributes deserialize(T serialized);  }