Skip to content

Commit 15eaaf6

Browse files
added a comment
1 parent 7ca3113 commit 15eaaf6

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

‎src/main/java/com/microsoft/graph/Util.java‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,18 @@
44

55
import javax.annotation.Nullable;
66

7+
/**
8+
* Class with commonly used utility methods.<br/>
9+
* <b>Note</b>: This class is meant for internal SDK use only and SDK users should not take a
10+
* dependency on it.
11+
*/
712
public final class Util {
813
private Util() {}
914

15+
/**
16+
* Closes a {@code Closeable} quietly, i.e. ignores any exceptions thrown when {@code close()}.
17+
* @param closeable The {@code Closeable} instance to be quietly closed.
18+
*/
1019
public static void closeQuietly(@Nullable Closeable closeable) {
1120
if (closeable == null) {
1221
return;

‎src/main/java/com/microsoft/graph/serializer/ISerializer.java‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,11 @@
2525
import com.google.gson.JsonElement;
2626

2727
import java.io.InputStream;
28-
import java.util.Collections;
2928
import java.util.List;
3029
import java.util.Map;
3130

32-
import javax.annotation.Nullable;
3331
import javax.annotation.Nonnull;
32+
import javax.annotation.Nullable;
3433

3534
import static java.util.Collections.emptyMap;
3635

@@ -89,6 +88,20 @@ default <T> T deserializeObject(@Nonnull final InputStream inputStream, @Nonnull
8988
@Nullable
9089
<T> T deserializeObject(@Nonnull final InputStream inputStream, @Nonnull final Class<T> clazz, @Nonnull final Map<String, List<String>> responseHeaders);
9190

91+
/**
92+
* Deserialize an object from the input JsonElement
93+
*
94+
* @param jsonElement the {@code JsonElement} that stores the representation of the item
95+
* @param clazz the {@code Class} of the item to be deserialized
96+
* @param <T> the type of the item to be deserialized
97+
* @return the deserialized item from the input string
98+
*/
99+
@SuppressWarnings("unchecked")
100+
@Nullable
101+
default <T> T deserializeObject(@Nonnull JsonElement jsonElement, @Nonnull Class<T> clazz) {
102+
return deserializeObject(jsonElement, clazz, emptyMap());
103+
}
104+
92105
/**
93106
* Deserialize an object from the input JsonElement
94107
*

0 commit comments

Comments
 (0)