Skip to content

Commit

Permalink
http-client-java, bug fix, unbranded does not have CoreUtils (#5129)
Browse files Browse the repository at this point in the history
fix #5128

We may need some refactor over this `CoreUtils` related code.
  • Loading branch information
weidongxu-microsoft authored Nov 18, 2024
1 parent 9a923c2 commit ce9c388
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -309,13 +309,18 @@ private static ClassType.Builder getClassTypeBuilder(Class<?> classKey) {
.jsonToken("JsonToken.STRING")
.serializationValueGetterModifier(valueGetter -> valueGetter
+ " == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(" + valueGetter + ")")
.jsonDeserializationMethod("getNullable(nonNullReader -> " + CORE_UTILS.getName()
+ ".parseBestOffsetDateTime(nonNullReader.getString()))")
.jsonDeserializationMethod(JavaSettings.getInstance().isBranded()
? ("getNullable(nonNullReader -> " + CORE_UTILS.getName()
+ ".parseBestOffsetDateTime(nonNullReader.getString()))")
: ("getNullable(nonNullReader -> OffsetDateTime.parse(nonNullReader.getString()))"))
.serializationMethodBase("writeString")
.xmlElementDeserializationMethod(
"getNullableElement(dateString -> " + CORE_UTILS.getName() + ".parseBestOffsetDateTime(dateString))")
.xmlAttributeDeserializationTemplate("%s.getNullableAttribute(%s, %s, dateString -> " + CORE_UTILS.getName()
+ ".parseBestOffsetDateTime(dateString))")
.xmlElementDeserializationMethod(JavaSettings.getInstance().isBranded()
? ("getNullableElement(dateString -> " + CORE_UTILS.getName() + ".parseBestOffsetDateTime(dateString))")
: ("getNullableElement(dateString -> OffsetDateTime.parse(dateString))"))
.xmlAttributeDeserializationTemplate(JavaSettings.getInstance().isBranded()
? ("%s.getNullableAttribute(%s, %s, dateString -> " + CORE_UTILS.getName()
+ ".parseBestOffsetDateTime(dateString))")
: ("%s.getNullableAttribute(%s, %s, dateString -> OffsetDateTime.parse(dateString))"))
.build();

public static final ClassType DURATION = new Builder(false).knownClass(Duration.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
public class EmitterOptions implements JsonSerializable<EmitterOptions> {
private String namespace;
private String outputDir;
private String flavor = "Azure";
private String flavor = "generic";
private String serviceName;
private List<String> serviceVersions;
private Boolean generateTests = true;
Expand Down

0 comments on commit ce9c388

Please sign in to comment.