-
Notifications
You must be signed in to change notification settings - Fork 166
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
Supports filling elements through templates for expression #1144
Conversation
Signed-off-by: yhmo <[email protected]>
Signed-off-by: cai.zhang <[email protected]>
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: xiaocai2333 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
DataType lastType = DataType.UNRECOGNIZED; | ||
boolean sameType = true; | ||
for (Object obj : array) { | ||
TemplateValue tv = deduceTemplateValue(obj); | ||
builder.addArray(tv); | ||
if (lastType == DataType.UNRECOGNIZED) { | ||
lastType = tv.getType(); | ||
} else if (lastType != tv.getType()) { | ||
sameType = false; | ||
} | ||
DataType arrayType = sameType ? lastType : DataType.JSON; | ||
builder.setElementType(arrayType); | ||
builder.setSameType(sameType); | ||
} |
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.
DataType lastType = DataType.UNRECOGNIZED; | |
boolean sameType = true; | |
for (Object obj : array) { | |
TemplateValue tv = deduceTemplateValue(obj); | |
builder.addArray(tv); | |
if (lastType == DataType.UNRECOGNIZED) { | |
lastType = tv.getType(); | |
} else if (lastType != tv.getType()) { | |
sameType = false; | |
} | |
DataType arrayType = sameType ? lastType : DataType.JSON; | |
builder.setElementType(arrayType); | |
builder.setSameType(sameType); | |
} | |
DataType lastType = DataType.UNRECOGNIZED; | |
boolean sameType = true; | |
for (Object obj : array) { | |
TemplateValue tv = deduceTemplateValue(obj); | |
builder.addArray(tv); | |
if (sameType && lastType != DataType.UNRECOGNIZED && lastType != tv.getType()) { | |
sameType = false; | |
} | |
lastType = tv.getType(); | |
} | |
DataType arrayType = sameType ? lastType : DataType.JSON; | |
builder.setElementType(arrayType); | |
builder.setSameType(sameType); |
return builder.build(); | ||
} | ||
|
||
public static TemplateValue deduceTemplateValue(Object value) { |
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.
nit: I prefer long method names that convey the exact action, maybe deduceAndCreateTemplateValue
DataType elementType = DataType.None; | ||
int i = 0; | ||
|
||
for (Object element : (List<?>) value) { |
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.
ditto
/close |
@xiaocai2333: Closed this PR. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
No description provided.