• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

box / box-java-sdk-gen / #359

14 Jul 2025 11:20AM UTC coverage: 38.075% (+2.5%) from 35.58%
#359

push

github

web-flow
feat: Support common union fields and implicit union conversion (box/box-codegen#758) (#361)

288 of 1203 new or added lines in 106 files covered. (23.94%)

165 existing lines in 43 files now uncovered.

18537 of 48685 relevant lines covered (38.08%)

0.38 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/java/com/box/sdkgen/schemas/fileorfolder/FileOrFolder.java
1
package com.box.sdkgen.schemas.fileorfolder;
2

3
import com.box.sdkgen.internal.OneOfTwo;
4
import com.box.sdkgen.schemas.file.File;
5
import com.box.sdkgen.schemas.folder.Folder;
6
import com.box.sdkgen.schemas.foldermini.FolderMini;
7
import com.box.sdkgen.schemas.usermini.UserMini;
8
import com.box.sdkgen.serialization.json.EnumWrapper;
9
import com.box.sdkgen.serialization.json.JsonManager;
10
import com.fasterxml.jackson.core.JsonParser;
11
import com.fasterxml.jackson.databind.DeserializationContext;
12
import com.fasterxml.jackson.databind.JsonDeserializer;
13
import com.fasterxml.jackson.databind.JsonMappingException;
14
import com.fasterxml.jackson.databind.JsonNode;
15
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
16
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
17
import java.io.IOException;
18
import java.util.Date;
19

20
@JsonDeserialize(using = FileOrFolder.FileOrFolderDeserializer.class)
21
@JsonSerialize(using = OneOfTwo.OneOfTwoSerializer.class)
22
public class FileOrFolder extends OneOfTwo<File, Folder> {
23

24
  protected final String description;
25

26
  protected final Long size;
27

28
  protected final Date createdAt;
29

30
  protected final Date modifiedAt;
31

32
  protected final Date trashedAt;
33

34
  protected final Date purgedAt;
35

36
  protected final Date contentCreatedAt;
37

38
  protected final Date contentModifiedAt;
39

40
  protected final UserMini createdBy;
41

42
  protected final UserMini modifiedBy;
43

44
  protected final UserMini ownedBy;
45

46
  protected final FolderMini parent;
47

48
  protected final String itemStatus;
49

50
  protected final String sequenceId;
51

52
  protected final String name;
53

54
  protected final String id;
55

56
  protected final String etag;
57

58
  protected final String type;
59

60
  public FileOrFolder(File file) {
61
    super(file, null);
×
NEW
62
    this.description = file.getDescription();
×
NEW
63
    this.size = file.getSize();
×
NEW
64
    this.createdAt = file.getCreatedAt();
×
NEW
65
    this.modifiedAt = file.getModifiedAt();
×
NEW
66
    this.trashedAt = file.getTrashedAt();
×
NEW
67
    this.purgedAt = file.getPurgedAt();
×
NEW
68
    this.contentCreatedAt = file.getContentCreatedAt();
×
NEW
69
    this.contentModifiedAt = file.getContentModifiedAt();
×
NEW
70
    this.createdBy = file.getCreatedBy();
×
NEW
71
    this.modifiedBy = file.getModifiedBy();
×
NEW
72
    this.ownedBy = file.getOwnedBy();
×
NEW
73
    this.parent = file.getParent();
×
NEW
74
    this.itemStatus = EnumWrapper.convertToString(file.getItemStatus());
×
NEW
75
    this.sequenceId = file.getSequenceId();
×
NEW
76
    this.name = file.getName();
×
NEW
77
    this.id = file.getId();
×
NEW
78
    this.etag = file.getEtag();
×
NEW
79
    this.type = EnumWrapper.convertToString(file.getType());
×
UNCOV
80
  }
×
81

82
  public FileOrFolder(Folder folder) {
83
    super(null, folder);
×
NEW
84
    this.description = folder.getDescription();
×
NEW
85
    this.size = folder.getSize();
×
NEW
86
    this.createdAt = folder.getCreatedAt();
×
NEW
87
    this.modifiedAt = folder.getModifiedAt();
×
NEW
88
    this.trashedAt = folder.getTrashedAt();
×
NEW
89
    this.purgedAt = folder.getPurgedAt();
×
NEW
90
    this.contentCreatedAt = folder.getContentCreatedAt();
×
NEW
91
    this.contentModifiedAt = folder.getContentModifiedAt();
×
NEW
92
    this.createdBy = folder.getCreatedBy();
×
NEW
93
    this.modifiedBy = folder.getModifiedBy();
×
NEW
94
    this.ownedBy = folder.getOwnedBy();
×
NEW
95
    this.parent = folder.getParent();
×
NEW
96
    this.itemStatus = EnumWrapper.convertToString(folder.getItemStatus());
×
NEW
97
    this.sequenceId = folder.getSequenceId();
×
NEW
98
    this.name = folder.getName();
×
NEW
99
    this.id = folder.getId();
×
NEW
100
    this.etag = folder.getEtag();
×
NEW
101
    this.type = EnumWrapper.convertToString(folder.getType());
×
NEW
102
  }
×
103

104
  public boolean isFile() {
NEW
105
    return value0 != null;
×
106
  }
107

108
  public File getFile() {
109
    return value0;
×
110
  }
111

112
  public boolean isFolder() {
NEW
113
    return value1 != null;
×
114
  }
115

116
  public Folder getFolder() {
117
    return value1;
×
118
  }
119

120
  public String getDescription() {
NEW
121
    return description;
×
122
  }
123

124
  public long getSize() {
NEW
125
    return size;
×
126
  }
127

128
  public Date getCreatedAt() {
NEW
129
    return createdAt;
×
130
  }
131

132
  public Date getModifiedAt() {
NEW
133
    return modifiedAt;
×
134
  }
135

136
  public Date getTrashedAt() {
NEW
137
    return trashedAt;
×
138
  }
139

140
  public Date getPurgedAt() {
NEW
141
    return purgedAt;
×
142
  }
143

144
  public Date getContentCreatedAt() {
NEW
145
    return contentCreatedAt;
×
146
  }
147

148
  public Date getContentModifiedAt() {
NEW
149
    return contentModifiedAt;
×
150
  }
151

152
  public UserMini getCreatedBy() {
NEW
153
    return createdBy;
×
154
  }
155

156
  public UserMini getModifiedBy() {
NEW
157
    return modifiedBy;
×
158
  }
159

160
  public UserMini getOwnedBy() {
NEW
161
    return ownedBy;
×
162
  }
163

164
  public FolderMini getParent() {
NEW
165
    return parent;
×
166
  }
167

168
  public String getItemStatus() {
NEW
169
    return itemStatus;
×
170
  }
171

172
  public String getSequenceId() {
NEW
173
    return sequenceId;
×
174
  }
175

176
  public String getName() {
NEW
177
    return name;
×
178
  }
179

180
  public String getId() {
NEW
181
    return id;
×
182
  }
183

184
  public String getEtag() {
NEW
185
    return etag;
×
186
  }
187

188
  public String getType() {
NEW
189
    return type;
×
190
  }
191

192
  static class FileOrFolderDeserializer extends JsonDeserializer<FileOrFolder> {
193

194
    public FileOrFolderDeserializer() {
195
      super();
×
196
    }
×
197

198
    @Override
199
    public FileOrFolder deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
200
      JsonNode node = JsonManager.jsonToSerializedData(jp);
×
201
      JsonNode discriminant0 = node.get("type");
×
202
      if (!(discriminant0 == null)) {
×
203
        switch (discriminant0.asText()) {
×
204
          case "file":
205
            return new FileOrFolder(JsonManager.deserialize(node, File.class));
×
206
          case "folder":
207
            return new FileOrFolder(JsonManager.deserialize(node, Folder.class));
×
208
        }
209
      }
210
      throw new JsonMappingException(jp, "Unable to deserialize FileOrFolder");
×
211
    }
212
  }
213
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc