001package com.box.sdk;
002
003import com.eclipsesource.json.JsonObject;
004import com.eclipsesource.json.JsonValue;
005
006/**
007 * Represents a part of the file that is uploaded.
008 */
009public class BoxFileUploadSessionPart extends BoxJSONObject {
010
011    private String partId;
012    private long offset;
013    private long size;
014    private String sha1;
015
016    /**
017     * Constructs an BoxFileUploadSessionPart object using an already parsed JSON object.
018     * @param  jsonObject the parsed JSON object.
019     */
020    BoxFileUploadSessionPart(JsonObject jsonObject) {
021        super(jsonObject);
022    }
023
024    /**
025     * Constructs an empty BoxFileUploadSessionPart object.
026     */
027    BoxFileUploadSessionPart() {
028        super();
029    }
030
031    /**
032     * Gets the sha1 digest of the part.
033     * @return the sh1 digest
034     */
035    public String getSha1() {
036        return this.sha1;
037    }
038
039    /**
040     * Sets the sh1 digest of the part.
041     * @param sha1 the sh1 digest of the part
042     */
043    public void setSha1(String sha1) {
044        this.sha1 = sha1;
045    }
046
047    /**
048     * Gets the part id.
049     * @return the id of the part.
050     */
051    public String getPartId() {
052        return this.partId;
053    }
054
055    /**
056     * Gets the offset byte.
057     * @return the offset of the part.
058     */
059    public long getOffset() {
060        return this.offset;
061    }
062
063    /**
064     * Gets the size of the part.
065     * @return the size of the part.
066     */
067    public long getSize() {
068        return this.size;
069    }
070
071    /**
072     * Sets the part id.
073     * @param partId the id of the part.
074     */
075    public void setPartId(String partId) {
076        this.partId = partId;
077    }
078
079    /**
080     * Sets the offset.
081     * @param offset the offset byte of the part.
082     */
083    public void setOffset(long offset) {
084        this.offset = offset;
085    }
086
087    /**
088     * Sets the size of the part.
089     * @param size the size of the part.
090     */
091    public void setSize(long size) {
092        this.size = size;
093    }
094
095    @Override
096    protected void parseJSONMember(JsonObject.Member member) {
097        String memberName = member.getName();
098        JsonValue value = member.getValue();
099        if (memberName.equals("part_id")) {
100            this.partId = value.asString();
101        } else if (memberName.equals("offset")) {
102            this.offset = Double.valueOf(value.toString()).longValue();
103        } else if (memberName.equals("size")) {
104            this.size = Double.valueOf(value.toString()).longValue();
105        } else if (memberName.equals("sha1")) {
106            this.sha1 = value.asString();
107        }
108    }
109}