-
Notifications
You must be signed in to change notification settings - Fork 2.2k
[POC] A draft version for the search serializer to collect feedback #13218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
37eacbc
ee0335a
c83105e
026b17e
8e4e728
7cf5f12
0eec309
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| package com.azure.core.experimental.serializer; | ||
|
|
||
| /** | ||
| * The enum to indicate how to include | ||
| */ | ||
| public enum JsonInclusion { | ||
| ALWAYS, | ||
| DEFAULT | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| package com.azure.core.experimental.serializer; | ||
|
|
||
| /** | ||
| * The json serializer options. | ||
| */ | ||
| public class JsonOptions { | ||
| private JsonInclusion jsonInclusion; | ||
|
|
||
| /** | ||
| * Gets the json inclusion value. | ||
| * @return The enum field json inclusion. | ||
| */ | ||
| public JsonInclusion getJsonInclusion() { | ||
| return jsonInclusion; | ||
| } | ||
|
|
||
| /** | ||
| * Sets the json inclusion value. | ||
| * @param jsonInclusion The enum field json inclusion. | ||
| * @return The {@link JsonOptions} object itself. | ||
| */ | ||
| public JsonOptions setJsonInclusion(JsonInclusion jsonInclusion) { | ||
| this.jsonInclusion = jsonInclusion; | ||
| return this; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
| package com.azure.core.experimental.serializer; | ||
|
|
||
| import java.lang.reflect.ParameterizedType; | ||
|
|
||
| public abstract class Type<T> { | ||
|
|
||
| private final java.lang.reflect.Type javaType; | ||
|
|
||
| /** | ||
| * Constructor | ||
| * @throws IllegalArgumentException if the reference is constructed without actual type information | ||
| */ | ||
| public Type() { | ||
| java.lang.reflect.Type superClass = this.getClass().getGenericSuperclass(); | ||
| if (superClass instanceof Class) { | ||
| throw new IllegalArgumentException( | ||
| "Internal error: TypeReference constructed without actual type information"); | ||
| } else { | ||
| this.javaType = ((ParameterizedType) superClass).getActualTypeArguments()[0]; | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Return class T type | ||
| * @return type | ||
| */ | ||
| public java.lang.reflect.Type getJavaType() { | ||
| return javaType; | ||
| } | ||
|
|
||
| /** | ||
| * Returns is the type a ParameterizedType (collection, string etc.) | ||
| * @return boolean value | ||
| */ | ||
| public boolean isParameterizedType() { | ||
| if (!(javaType instanceof ParameterizedType)) { | ||
| return false; | ||
| } | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
| /** | ||
| * Get the type of the actual type of the Type object | ||
| * @return ava.lang.reflect.Type | ||
| */ | ||
| public java.lang.reflect.Type getListType() { | ||
| assert isParameterizedType(); | ||
| ParameterizedType parameterizedType = (ParameterizedType) javaType; | ||
| return parameterizedType.getActualTypeArguments()[0]; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ | |
| exports com.azure.core.experimental.serializer; | ||
| exports com.azure.core.experimental.spatial; | ||
|
|
||
| opens com.azure.core.experimental.spatial to com.fasterxml.jackson.databind; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't believe this needs to open to databind as no databinding will happen with the types in spatial. They all should be using streaming deserialization.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It indeed complaint about the PointGeometry did not open module to databind. Why spatial doesn't need to do reflection when serialize? |
||
| uses com.azure.core.experimental.serializer.AvroSerializerProvider; | ||
| uses com.azure.core.experimental.serializer.JsonSerializerProvider; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fine for testing this, in the future when this work is merged into Azure Core it'll become package private again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I think it doesn't hurt to public the serializer before we move back Azure Core.