-
Notifications
You must be signed in to change notification settings - Fork 277
ClientMethodTemplate: Remove method parameters that can be obtained from other parameters and Improve ClientType to WireType function #7483
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
base: main
Are you sure you want to change the base?
Conversation
No changes needing a change description found. |
You can try these changes here
|
if (!expressionsToCheckSet.contains(validateExpression.getKey())) { | ||
function.ifBlock(validateExpression.getKey() + " != null", | ||
ifBlock -> ifBlock.line(validateExpression.getValue() + ";")); | ||
} |
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.
not sure whether there could be impact from this condition.
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.
We now use a HashMap
(validateParamExpressions) from which already validated expressions are removed during the first iteration. So, the remaining expressions those have not yet been validated are handled here. Hence there will be no change in how the generated code looks like.
d8a2342
to
e73a408
Compare
List<ProxyMethodParameter> autoRestMethodRetrofitParameters) { | ||
for (ProxyMethodParameter parameter : autoRestMethodRetrofitParameters) { | ||
protected static void convertClientTypesToWireTypes(JavaBlock function, ClientMethod clientMethod) { | ||
final List<ProxyMethodParameter> proxyMethodParameters = clientMethod.getProxyMethod().getParameters(); |
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.
Conditional checks in this method are simplified, reduced variable scopes and making it extensible so derived templates can reuse or override parts of the conversion.
* @param wireType the wire type of the parameter, used to determine the method to call for encoding. | ||
* @return Java code that converts a byte[] parameter to a Base64 URL encoded string. | ||
*/ | ||
private static String byteArrayToBase64UrlEncodedString(String parameterName, IType wireType) { |
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.
For example, plan is to change this new method to protected
instance method so client-core template can override to use Base64 type from new core.
// Refer iterableToWireStringValuesList(..)' | ||
parameterWireType = new ListType(ClassType.STRING); | ||
} | ||
} |
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 block is an expanded version of the original code, but with structure now consistent with structure of conversion code, which improves the readability. It also simplifies, for instance, the explode
is applicable only to IterableType
, as seen in the subsequent code generating the conversion.
…rom other parameters
…ar to the rest of the code in convertClientTypesToWireTypes
7912cb5
to
cff5f07
Compare
The changes look good to me.
|
ClientMethodTemplate
(and its extended types) methods, there is no need to passProxyMethod
as an explicit argument, since it can be obtained fromClientMethod
argument.List<ProxyMethodParameter>
explicitly when it can be obtained fromClientMethod ::ProxyMethod::parameters
convertClientTypesToWireTypes
has been simplified and updated to be extensible for future prs that aim to simplify inherited templates such as client core.AutoRest validation pr.