Skip to content

Commit 3cc898b

Browse files
committed
change some nullity Decorators
1 parent 27e341a commit 3cc898b

File tree

3 files changed

+28
-9
lines changed

3 files changed

+28
-9
lines changed

src/main/java/com/bhyoo/onedrive/container/facet/FolderFacet.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@
1717
*/
1818
public class FolderFacet {
1919
@Getter protected final long childCount;
20-
@Getter protected final @NotNull FolderViewFacet view;
20+
// Nullable on onedrive for business
21+
@Getter protected final @Nullable FolderViewFacet view;
2122

22-
protected FolderFacet(@NotNull Long childCount, @NotNull FolderViewFacet view) {
23+
protected FolderFacet(@NotNull Long childCount, @Nullable FolderViewFacet view) {
2324
this.childCount = childCount;
2425
this.view = view;
2526
}
@@ -45,7 +46,6 @@ public static FolderFacet deserialize(@NotNull JsonParser parser) throws IOExcep
4546
}
4647

4748
assert childCount != null : "childCount is null";
48-
assert view != null : "view is null";
4949

5050
return new FolderFacet(childCount, view);
5151
}

src/main/java/com/bhyoo/onedrive/container/items/AbstractDriveItem.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,8 @@ else if (folder.pathPointer != null)
508508
}
509509

510510
@Override
511-
public @NotNull AsyncJobMonitor copyTo(@NotNull BasePointer dest, @NotNull String newName) throws ErrorResponseException {
511+
public @NotNull AsyncJobMonitor copyTo(@NotNull BasePointer dest, @NotNull String newName)
512+
throws ErrorResponseException {
512513
return client.copyItem(idPointer, dest, newName);
513514
}
514515

@@ -518,7 +519,8 @@ else if (folder.pathPointer != null)
518519
}
519520

520521
@Override
521-
public @NotNull AsyncJobMonitor copyTo(@NotNull String destId, @NotNull String newName) throws ErrorResponseException {
522+
public @NotNull AsyncJobMonitor copyTo(@NotNull String destId, @NotNull String newName)
523+
throws ErrorResponseException {
522524
return client.copyItem(this.id, destId, newName);
523525
}
524526

@@ -560,7 +562,9 @@ public void moveTo(@NotNull BasePointer pointer) throws ErrorResponseException {
560562

561563

562564
@Override
563-
public final @NotNull ItemReference newReference() {return new ItemReference(getDriveId(), id, pathPointer);}
565+
public final @NotNull ItemReference newReference() {
566+
return new ItemReference(getDriveId(), parentReference.driveType, id, pathPointer);
567+
}
564568

565569

566570

src/main/java/com/bhyoo/onedrive/container/items/ItemReference.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,27 @@
2525
@EqualsAndHashCode(of = {"id", "driveId"})
2626
public class ItemReference {
2727
@Getter protected @NotNull String driveId;
28-
@Getter protected @Nullable DriveType driveType;
28+
@Getter protected @NotNull DriveType driveType;
29+
/**
30+
* only null when root directory
31+
*/
2932
@Getter protected @Nullable String id;
33+
/**
34+
* only null on Business version
35+
*/
3036
@Getter protected @Nullable String name;
37+
/**
38+
* only null when root directory
39+
*/
3140
@Getter protected @Nullable PathPointer pathPointer;
41+
/**
42+
* only null when root directory
43+
*/
3244
@Getter protected @Nullable String rawPath;
3345
@Getter protected @Nullable String shareId;
3446
@Getter protected @Nullable SharePointIdsFacet sharepointIds;
3547

36-
protected ItemReference(@NotNull String driveId, @Nullable DriveType driveType, @Nullable String id,
48+
protected ItemReference(@NotNull String driveId, @NotNull DriveType driveType, @Nullable String id,
3749
@Nullable String name, @Nullable String rawPath, @Nullable String shareId,
3850
@Nullable SharePointIdsFacet sharepointIds) {
3951
this.driveId = driveId;
@@ -49,8 +61,10 @@ protected ItemReference(@NotNull String driveId, @Nullable DriveType driveType,
4961
}
5062
}
5163

52-
ItemReference(@NotNull String driveId, @Nullable String id, @Nullable PathPointer pathPointer) {
64+
ItemReference(@NotNull String driveId, @NotNull DriveType driveType,
65+
@Nullable String id, @Nullable PathPointer pathPointer) {
5366
this.driveId = driveId;
67+
this.driveType = driveType;
5468
this.id = id;
5569
this.pathPointer = pathPointer;
5670

@@ -101,6 +115,7 @@ public static ItemReference deserialize(@NotNull JsonParser parser) throws IOExc
101115
}
102116

103117
assert driveId != null : "driveId is null";
118+
assert driveType != null : "driveType is null";
104119

105120
return new ItemReference(driveId, driveType, id, name, rawPath, shareId, sharepointIds);
106121
}

0 commit comments

Comments
 (0)