private static boolean checkIsLikeMapType(BValue sourceValue, BMapType targetType) { if (!(sourceValue instanceof BMap)) { return false; } for (Object mapEntry : ((BMap) sourceValue).values()) { if (!checkIsLikeType((BValue) mapEntry, targetType.getConstrainedType())) { return false; } } return true; }
public void execute(Context ctx) { BMap<String, BValue> map = (BMap<String, BValue>) ctx.getRefArgument(0); BValueArray bRefValueArray = new BValueArray((BRefType<?>[]) map.values(), BTypes.typeAny); ctx.setReturnValues(bRefValueArray); } }
@Override public void execute(Context context, CallableUnitCallback callback) { BMap<String, BValue> pushPromiseStruct = (BMap<String, BValue>) context.getRefArgument(1); Http2PushPromise http2PushPromise = HttpUtil.getPushPromise(pushPromiseStruct, null); if (http2PushPromise == null) { throw new BallerinaException("invalid push promise"); } BMap<String, BValue> bConnector = (BMap<String, BValue>) context.getRefArgument(0); HttpClientConnector clientConnector = (HttpClientConnector) ((BMap<String, BValue>) bConnector.values()[0]) .getNativeData(HttpConstants.HTTP_CLIENT); clientConnector.rejectPushResponse(http2PushPromise); callback.notifySuccess(); } }
for (Object value : this.values()) { if (value != null) { ((BValue) value).stamp(((BMapType) type).getConstrainedType());
@Override public void execute(Context context, CallableUnitCallback callback) { BMap<String, BValue> handleStruct = ((BMap<String, BValue>) context.getRefArgument(1)); ResponseHandle responseHandle = (ResponseHandle) handleStruct.getNativeData(HttpConstants.TRANSPORT_HANDLE); if (responseHandle == null) { throw new BallerinaException("invalid http handle"); } BMap<String, BValue> bConnector = (BMap<String, BValue>) context.getRefArgument(0); HttpClientConnector clientConnector = (HttpClientConnector) ((BMap<String, BValue>) bConnector.values()[0]) .getNativeData(HttpConstants.HTTP_CLIENT); clientConnector.hasPushPromise(responseHandle). setPromiseAvailabilityListener(new PromiseAvailabilityCheckListener(context, callback)); }
@Override public void execute(Context context, CallableUnitCallback callback) { DataContext dataContext = new DataContext(context, callback, null); BMap<String, BValue> handleStruct = ((BMap<String, BValue>) context.getRefArgument(1)); ResponseHandle responseHandle = (ResponseHandle) handleStruct.getNativeData(HttpConstants.TRANSPORT_HANDLE); if (responseHandle == null) { throw new BallerinaException("invalid http handle"); } BMap<String, BValue> bConnector = (BMap<String, BValue>) context.getRefArgument(0); HttpClientConnector clientConnector = (HttpClientConnector) ((BMap<String, BValue>) bConnector.values()[0]) .getNativeData(HttpConstants.HTTP_CLIENT); clientConnector.getResponse(responseHandle). setHttpConnectorListener(new ResponseListener(dataContext)); }
@Override public void execute(Context context, CallableUnitCallback callback) { DataContext dataContext = new DataContext(context, callback, null); BMap<String, BValue> handleStruct = ((BMap<String, BValue>) context.getRefArgument(1)); ResponseHandle responseHandle = (ResponseHandle) handleStruct.getNativeData(HttpConstants.TRANSPORT_HANDLE); if (responseHandle == null) { throw new BallerinaException("invalid http handle"); } BMap<String, BValue> bConnector = (BMap<String, BValue>) context.getRefArgument(0); HttpClientConnector clientConnector = (HttpClientConnector) ((BMap<String, BValue>) bConnector.values()[0]) .getNativeData(HttpConstants.HTTP_CLIENT); clientConnector.getNextPushPromise(responseHandle). setPushPromiseListener(new PromiseListener(dataContext)); }
@Override public void execute(Context context, CallableUnitCallback callback) { DataContext dataContext = new DataContext(context, callback, null); BMap<String, BValue> pushPromiseStruct = (BMap<String, BValue>) context.getRefArgument(1); Http2PushPromise http2PushPromise = HttpUtil.getPushPromise(pushPromiseStruct, null); if (http2PushPromise == null) { throw new BallerinaException("invalid push promise"); } BMap<String, BValue> bConnector = (BMap<String, BValue>) context.getRefArgument(0); HttpClientConnector clientConnector = (HttpClientConnector) ((BMap<String, BValue>) bConnector.values()[0]) .getNativeData(HttpConstants.HTTP_CLIENT); clientConnector.getPushResponse(http2PushPromise). setPushResponseListener(new PushResponseListener(dataContext), http2PushPromise.getPromisedStreamId()); }
private static boolean checkIsLikeJSONType(BValue sourceValue, BJSONType targetType) { if (targetType.getConstrainedType() != null) { return checkIsLikeType(sourceValue, targetType.getConstrainedType()); } else if (sourceValue.getType().getTag() == TypeTags.ARRAY_TAG) { BValueArray source = (BValueArray) sourceValue; if (BTypes.isValueType(source.elementType)) { return checkIsType(source.elementType, targetType, new ArrayList<>()); } BRefType<?>[] arrayValues = source.getValues(); for (int i = 0; i < ((BValueArray) sourceValue).size(); i++) { if (!checkIsLikeType(arrayValues[i], targetType)) { return false; } } } else if (sourceValue.getType().getTag() == TypeTags.MAP_TAG) { for (BValue value : ((BMap) sourceValue).values()) { if (!checkIsLikeType(value, targetType)) { return false; } } } else if (sourceValue.getType().getTag() == TypeTags.RECORD_TYPE_TAG) { for (Object object : ((BMap) sourceValue).getMap().values()) { if (!checkIsLikeType((BValue) object, targetType)) { return false; } } } return true; }