001package com.box.sdk; 002 003import com.eclipsesource.json.JsonObject; 004import com.eclipsesource.json.JsonValue; 005 006/** Represents the download status of a zip file. */ 007public class BoxZipDownloadStatus extends BoxJSONObject { 008 private int totalFileCount; 009 private int downloadFileCount; 010 private int skippedFileCount; 011 private int skippedFolderCount; 012 private State state; 013 014 /** Constructs a BoxZipDownloadStatus with default settings. */ 015 public BoxZipDownloadStatus() {} 016 017 /** 018 * Constructs a BoxZipDownloadStatus from a JSON string. 019 * 020 * @param json the JSON encoded enterprise. 021 */ 022 public BoxZipDownloadStatus(String json) { 023 super(json); 024 } 025 026 BoxZipDownloadStatus(JsonObject jsonObject) { 027 super(jsonObject); 028 } 029 030 /** 031 * Gets the total number of files in the zip. 032 * 033 * @return the total number of files in the zip. 034 */ 035 public int getTotalFileCount() { 036 return this.totalFileCount; 037 } 038 039 /** 040 * Gets the number of files in the zip that were downloaded. 041 * 042 * @return the number of files in the zip that were downloaded. 043 */ 044 public int getDownloadFileCount() { 045 return this.downloadFileCount; 046 } 047 048 /** 049 * Gets the number of files in the zip that were skipped when downloading. 050 * 051 * @return the number of files in the zip that were skipped when downloading. 052 */ 053 public int getSkippedFileCount() { 054 return this.skippedFileCount; 055 } 056 057 /** 058 * Gets the number of folders in the zip that were skipped when downloading. 059 * 060 * @return the number of folder in the zip that were skipped when downloading. 061 */ 062 public int getSkippedFolderCount() { 063 return this.skippedFolderCount; 064 } 065 066 /** 067 * Gets the state of the download for the zip file. 068 * 069 * @return the state of the download for the zip file 070 */ 071 public State getState() { 072 return this.state; 073 } 074 075 @Override 076 void parseJSONMember(JsonObject.Member member) { 077 JsonValue value = member.getValue(); 078 String memberName = member.getName(); 079 if (memberName.equals("total_file_count")) { 080 this.totalFileCount = value.asInt(); 081 } else if (memberName.equals("downloaded_file_count")) { 082 this.downloadFileCount = value.asInt(); 083 } else if (memberName.equals("skipped_file_count")) { 084 this.skippedFileCount = value.asInt(); 085 } else if (memberName.equals("skipped_folder_count")) { 086 this.skippedFolderCount = value.asInt(); 087 } else if (memberName.equals("state")) { 088 this.state = State.fromJSONValue(value.asString()); 089 } 090 } 091 092 /** Enumerates the possible download states of a zip. */ 093 public enum State { 094 /** Succeeded in downloading. */ 095 SUCCEEDED("succeeded"), 096 097 /** Downloading in progress. */ 098 IN_PROGRESS("in_progress"), 099 100 /** Failed when downloading. */ 101 FAILED("failed"); 102 103 private final String jsonValue; 104 105 State(String jsonValue) { 106 this.jsonValue = jsonValue; 107 } 108 109 static State fromJSONValue(String jsonValue) { 110 return State.valueOf(jsonValue.toUpperCase(java.util.Locale.ROOT)); 111 } 112 113 String toJSONValue() { 114 return this.jsonValue; 115 } 116 } 117}