use of org.wso2.ballerinalang.compiler.tree.expressions.BLangRecordLiteral in project ballerina by ballerina-lang.
the class ClientGeneratorPlugin method isClientGenerationEnabled.
private boolean isClientGenerationEnabled(AnnotationAttachmentNode ann) {
boolean isClientRequested;
if (ann == null) {
return false;
}
BLangRecordLiteral bLiteral = ((BLangRecordLiteral) ((BLangAnnotationAttachment) ann).getExpression());
List<BLangRecordLiteral.BLangRecordKeyValue> list = bLiteral.getKeyValuePairs();
Map<String, String[]> attrs = GeneratorUtils.getKeyValuePairAsMap(list);
String val = attrs.get("generate")[0];
isClientRequested = Boolean.parseBoolean(val);
return isClientRequested;
}
use of org.wso2.ballerinalang.compiler.tree.expressions.BLangRecordLiteral in project ballerina by ballerina-lang.
the class EndpointContextHolder method extractDetails.
private void extractDetails(EndpointNode ep, AnnotationAttachmentNode ann) {
this.name = ep.getName().getValue();
BLangRecordLiteral bLiteral = (BLangRecordLiteral) ep.getConfigurationExpression();
List<BLangRecordLiteral.BLangRecordKeyValue> list = bLiteral.getKeyValuePairs();
Map<String, String[]> configs = GeneratorUtils.getKeyValuePairAsMap(list);
String httpsPort = configs.get(GeneratorConstants.ATTR_HTTPS_PORT) != null ? configs.get(GeneratorConstants.ATTR_HTTPS_PORT)[0] : null;
this.host = configs.get(GeneratorConstants.ATTR_HOST) != null ? configs.get(GeneratorConstants.ATTR_HOST)[0] : null;
this.port = configs.get(GeneratorConstants.ATTR_HTTP_PORT) != null ? configs.get(GeneratorConstants.ATTR_HTTP_PORT)[0] : null;
bLiteral = ((BLangRecordLiteral) ((BLangAnnotationAttachment) ann).getExpression());
List<BLangRecordLiteral.BLangRecordKeyValue> attrList = bLiteral.getKeyValuePairs();
Map<String, String[]> attrs = GeneratorUtils.getKeyValuePairAsMap(attrList);
this.basePath = attrs.get(GeneratorConstants.ATTR_BASE_PATH) != null ? attrs.get(GeneratorConstants.ATTR_BASE_PATH)[0] : null;
StringBuffer sb = new StringBuffer();
// Select protocol according to given ports. HTTPS is given the priority
if (httpsPort != null) {
sb.append(GeneratorConstants.ATTR_HTTPS);
port = httpsPort;
} else {
sb.append(GeneratorConstants.ATTR_HTTP);
}
// Set default values to host and port if values are not defined
if (host == null) {
host = GeneratorConstants.ATTR_DEF_HOST;
}
if (port == null) {
port = GeneratorConstants.ATTR_DEF_PORT;
}
this.url = sb.append(host).append(':').append(port).append(basePath).toString();
}
Aggregations