Skip to content

Commit 6150b3f

Browse files
committed
DeepCopy methods, needs comments
1 parent 86eddd5 commit 6150b3f

File tree

4 files changed

+33
-9
lines changed

4 files changed

+33
-9
lines changed

src/main/java/com/microsoft/graph/http/GraphError.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,15 @@ protected String transformErrorCodeCase(@Nonnull final String original) {
8686
Objects.requireNonNull(original, "parameter original cannot be null");
8787
return CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, original);
8888
}
89+
90+
//TODO comments
91+
public static final GraphError graphErrorCopy(GraphError error) {
92+
GraphError errorCopy = new GraphError();
93+
errorCopy.message = error.message;
94+
errorCopy.code = error.code;
95+
if(error.innererror!=null) {
96+
errorCopy.innererror = GraphInnerError.graphInnerErrorCopy(error.innererror);
97+
}
98+
return errorCopy;
99+
}
89100
}

src/main/java/com/microsoft/graph/http/GraphErrorResponse.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,13 @@ public final AdditionalDataManager additionalDataManager() {
7272
return additionalDataManager;
7373
}
7474

75-
public GraphErrorResponse getCopy()
75+
//TODO: Comments
76+
public static GraphErrorResponse getErrorCopy(GraphErrorResponse response)
7677
{
77-
//makeCopy of error
78-
//make copy of additionalData manager
79-
//make copy of raw object
80-
return this;
81-
78+
GraphErrorResponse copy = new GraphErrorResponse();
79+
copy.additionalDataManager = response.additionalDataManager(); //We are okay with keeping the dataManager intact
80+
copy.rawObject = response.rawObject.deepCopy();
81+
copy.error = GraphError.graphErrorCopy(response.error);
82+
return copy;
8283
}
83-
84-
8584
}

src/main/java/com/microsoft/graph/http/GraphInnerError.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,18 @@ public class GraphInnerError {
6060
@SerializedName("innererror")
6161
@Nullable
6262
public GraphInnerError innererror;
63+
64+
//TODO: Comments
65+
public static final GraphInnerError graphInnerErrorCopy(GraphInnerError InnerError) {
66+
GraphInnerError innerErrorCopy = new GraphInnerError();
67+
innerErrorCopy.code = InnerError.code;
68+
innerErrorCopy.errorType = InnerError.errorType;
69+
innerErrorCopy.debugMessage = InnerError.debugMessage;
70+
innerErrorCopy.stackTrace = InnerError.stackTrace;
71+
innerErrorCopy.throwSite = InnerError.throwSite;
72+
if (InnerError.innererror != null) {
73+
innerErrorCopy.innererror = graphInnerErrorCopy(InnerError.innererror);
74+
}
75+
return innerErrorCopy;
76+
}
6377
}

src/main/java/com/microsoft/graph/http/GraphServiceException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ public List<String> getResponseHeaders() {
212212
*/
213213
@Nullable
214214
public GraphErrorResponse getError() {
215-
return error.getCopy(); //Copy the error, deserialize and copy contents TODO
215+
return GraphErrorResponse.getErrorCopy(error);
216216
}
217217

218218
/**

0 commit comments

Comments
 (0)