public static <T extends PersistableTransfer> T deserializeFrom(InputStream in) {
        String type;
        JsonNode tree;
        try {
            tree = MAPPER.readTree(in);
            JsonNode pauseType = tree.get("pauseType");
            if (pauseType == null)
                throw new IllegalArgumentException(
                        "Unrecognized serialized state");
            type = pauseType.asText();
        } catch (Exception e) {
            throw new IllegalArgumentException(e);
        }
        Class<?> clazz;
        if (PersistableDownload.TYPE.equals(type)) {
            clazz = PersistableDownload.class;
        } else if (PersistableUpload.TYPE.equals(type)) {
            clazz = PersistableUpload.class;
        } else {
            throw new UnsupportedOperationException(
                    "Unsupported paused transfer type: " + type);
        }
        try {
            @SuppressWarnings("unchecked")
            T t = (T) MAPPER.treeToValue(tree, clazz);
            return t;
        } catch (JsonProcessingException e) {
            throw new IllegalStateException(e);
        }
    }
Returns the deserialized transfer state of the given serialized
representation. Caller of this method should explicitly close the
<code>InputStream</code>.

@throws UnsupportedOperationException
            if the paused transfer type extracted from the serialized
            representation is not supported.
aws-java-sdk-s3/src/main/java/com/amazonaws/services/s3/transfer/PersistableTransfer.java