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