|
| 1 | +package com.cloudinary; |
| 2 | + |
| 3 | +import java.util.Arrays; |
| 4 | +import java.util.HashMap; |
| 5 | +import java.util.Map; |
| 6 | + |
| 7 | +public class ArchiveParams { |
| 8 | + public static final String FORMAT_ZIP = "zip"; |
| 9 | + |
| 10 | + public static final String MODE_DOWNLOAD = "download"; |
| 11 | + public static final String MODE_CREATE = "create"; |
| 12 | + |
| 13 | + private String resourceType = "image"; |
| 14 | + private String type = null; |
| 15 | + private String mode = MODE_CREATE; |
| 16 | + private String targetFormat = null; |
| 17 | + private String targetPublicId = null; |
| 18 | + private boolean flattenFolders = false; |
| 19 | + private boolean flattenTransformations = false; |
| 20 | + private boolean useOriginalFilename = false; |
| 21 | + private boolean async = false; |
| 22 | + private boolean keepDerived = false; |
| 23 | + private String notificationUrl = null; |
| 24 | + private String[] targetTags = null; |
| 25 | + private String[] tags = null; |
| 26 | + private String[] publicIds = null; |
| 27 | + private String[] prefixes = null; |
| 28 | + private Transformation[] transformations = null; |
| 29 | + |
| 30 | + public String resourceType() { |
| 31 | + return resourceType; |
| 32 | + } |
| 33 | + |
| 34 | + public ArchiveParams resourceType(String resourceType) { |
| 35 | + if (resourceType == null) |
| 36 | + throw new IllegalArgumentException("resource type must be non-null"); |
| 37 | + this.resourceType = resourceType; |
| 38 | + return this; |
| 39 | + } |
| 40 | + |
| 41 | + public String type() { |
| 42 | + return type; |
| 43 | + } |
| 44 | + |
| 45 | + public ArchiveParams type(String type) { |
| 46 | + this.type = type; |
| 47 | + return this; |
| 48 | + } |
| 49 | + |
| 50 | + public String mode() { |
| 51 | + return mode; |
| 52 | + } |
| 53 | + |
| 54 | + public ArchiveParams mode(String mode) { |
| 55 | + this.mode = mode; |
| 56 | + return this; |
| 57 | + } |
| 58 | + |
| 59 | + public String targetFormat() { |
| 60 | + return targetFormat; |
| 61 | + } |
| 62 | + |
| 63 | + public ArchiveParams targetFormat(String targetFormat) { |
| 64 | + this.targetFormat = targetFormat; |
| 65 | + return this; |
| 66 | + } |
| 67 | + |
| 68 | + public String targetPublicId() { |
| 69 | + return targetPublicId; |
| 70 | + } |
| 71 | + |
| 72 | + public ArchiveParams targetPublicId(String targetPublicId) { |
| 73 | + this.targetPublicId = targetPublicId; |
| 74 | + return this; |
| 75 | + } |
| 76 | + |
| 77 | + public boolean isFlattenFolders() { |
| 78 | + return flattenFolders; |
| 79 | + } |
| 80 | + |
| 81 | + public ArchiveParams flattenFolders(boolean flattenFolders) { |
| 82 | + this.flattenFolders = flattenFolders; |
| 83 | + return this; |
| 84 | + } |
| 85 | + |
| 86 | + public boolean isFlattenTransformations() { |
| 87 | + return flattenTransformations; |
| 88 | + } |
| 89 | + |
| 90 | + public ArchiveParams flattenTransformations(boolean flattenTransformations) { |
| 91 | + this.flattenTransformations = flattenTransformations; |
| 92 | + return this; |
| 93 | + } |
| 94 | + |
| 95 | + public boolean isUseOriginalFilename() { |
| 96 | + return useOriginalFilename; |
| 97 | + } |
| 98 | + |
| 99 | + public ArchiveParams useOriginalFilename(boolean useOriginalFilename) { |
| 100 | + this.useOriginalFilename = useOriginalFilename; |
| 101 | + return this; |
| 102 | + } |
| 103 | + |
| 104 | + public boolean isAsync() { |
| 105 | + return async; |
| 106 | + } |
| 107 | + |
| 108 | + public ArchiveParams async(boolean async) { |
| 109 | + this.async = async; |
| 110 | + return this; |
| 111 | + } |
| 112 | + |
| 113 | + public boolean isKeepDerived() { |
| 114 | + return keepDerived; |
| 115 | + } |
| 116 | + |
| 117 | + public ArchiveParams keepDerived(boolean keepDerived) { |
| 118 | + this.keepDerived = keepDerived; |
| 119 | + return this; |
| 120 | + } |
| 121 | + |
| 122 | + public String notificationUrl() { |
| 123 | + return notificationUrl; |
| 124 | + } |
| 125 | + |
| 126 | + public ArchiveParams notificationUrl(String notificationUrl) { |
| 127 | + this.notificationUrl = notificationUrl; |
| 128 | + return this; |
| 129 | + } |
| 130 | + |
| 131 | + public String[] targetTags() { |
| 132 | + return targetTags; |
| 133 | + } |
| 134 | + |
| 135 | + public ArchiveParams targetTags(String[] targetTags) { |
| 136 | + this.targetTags = targetTags; |
| 137 | + return this; |
| 138 | + } |
| 139 | + |
| 140 | + public String[] tags() { |
| 141 | + return tags; |
| 142 | + } |
| 143 | + |
| 144 | + public ArchiveParams tags(String[] tags) { |
| 145 | + this.tags = tags; |
| 146 | + return this; |
| 147 | + } |
| 148 | + |
| 149 | + public String[] publicIds() { |
| 150 | + return publicIds; |
| 151 | + } |
| 152 | + |
| 153 | + public ArchiveParams publicIds(String[] publicIds) { |
| 154 | + this.publicIds = publicIds; |
| 155 | + return this; |
| 156 | + } |
| 157 | + |
| 158 | + public String[] prefixes() { |
| 159 | + return prefixes; |
| 160 | + } |
| 161 | + |
| 162 | + public ArchiveParams prefixes(String[] prefixes) { |
| 163 | + this.prefixes = prefixes; |
| 164 | + return this; |
| 165 | + } |
| 166 | + |
| 167 | + public Transformation[] transformations() { |
| 168 | + return transformations; |
| 169 | + } |
| 170 | + |
| 171 | + public ArchiveParams transformations(Transformation[] transformations) { |
| 172 | + this.transformations = transformations; |
| 173 | + return this; |
| 174 | + } |
| 175 | + |
| 176 | + public Map<String, Object> toMap() { |
| 177 | + Map<String, Object> params = new HashMap<String, Object>(); |
| 178 | + params.put("resource_type", resourceType); |
| 179 | + params.put("type", type); |
| 180 | + params.put("mode", mode); |
| 181 | + if (targetPublicId != null) |
| 182 | + params.put("target_public_id", targetPublicId); |
| 183 | + params.put("flatten_folders", flattenFolders); |
| 184 | + params.put("flatten_transformations", flattenTransformations); |
| 185 | + params.put("use_original_filename", useOriginalFilename); |
| 186 | + params.put("async", async); |
| 187 | + params.put("keep_derived", keepDerived); |
| 188 | + if (notificationUrl != null) |
| 189 | + params.put("notification_url", notificationUrl); |
| 190 | + if (targetTags != null) |
| 191 | + params.put("target_tags", targetTags); |
| 192 | + if (tags != null) |
| 193 | + params.put("tags", tags); |
| 194 | + if (publicIds != null) |
| 195 | + params.put("public_ids", publicIds); |
| 196 | + if (prefixes != null) |
| 197 | + params.put("prefixes", prefixes); |
| 198 | + if (transformations != null) { |
| 199 | + params.put("transformations", Arrays.asList(transformations)); |
| 200 | + } |
| 201 | + return params; |
| 202 | + } |
| 203 | +} |
0 commit comments