private static String getBTypeListAsString(BType[] typeNames) { StringBuffer br = new StringBuffer(); int i = 0; for (BType type : typeNames) { br.append(type.getName()); if (++i < typeNames.length) { br.append(","); } } return br.toString(); }
@Override public String toString() { if (constraint == null) { return super.toString(); } else { return "json" + "<" + constraint.getName() + ">"; } }
@Override public String toString() { if (constraint == BTypes.typeAny) { return super.toString(); } else { return "stream" + "<" + constraint.getName() + ">"; } }
@Override public String toString() { if (constraint == BTypes.typeAny) { return super.toString(); } else { return "map" + "<" + constraint.getName() + ">"; } }
/** * Get full service name with the package path. * * @param serviceInfoType service info type * @return full qualified service name */ private static String getFullServiceName(BType serviceInfoType) { return serviceInfoType.getPackagePath().equals(PACKAGE_SEPARATOR) ? serviceInfoType.getName() : serviceInfoType.getPackagePath() + PACKAGE_SEPARATOR + serviceInfoType.getName(); }
public static boolean isRequestStruct(BMap<String, BValue> struct) { return struct.getType().getName().equals(REQUEST); }
private static boolean isResponseStruct(BMap<String, BValue> struct) { return struct.getType().getName().equals(HttpConstants.RESPONSE); }
/** * Get the full service name. * * @param serviceInfo service info * @return service name */ public static String getFullServiceName(ServiceInfo serviceInfo) { BType serviceInfoType = serviceInfo.getType(); return serviceInfoType.getPackagePath().equals(PACKAGE_SEPARATOR) ? serviceInfoType.getName() : serviceInfoType.getPackagePath() + PACKAGE_SEPARATOR + serviceInfoType.getName(); }
@Override public String getAnnotationEntryKey() { return service.getServiceInfo().serviceType.getType().getName() + "." + name; } }
@Override public String toString() { if (constraint == null) { return super.toString(); } else { return super.toString() + "<" + constraint.getName() + ">"; } }
/** * Convert a json array to the relevant record array. * * @param entityBodyType Represents entity body type * @param bjson Represents the json array that needs to be converted * @return the relevant ballerina record or object array */ private static BValue getRecordArray(BType entityBodyType, BValue bjson) { try { return JSONUtils.convertJSONToBArray(bjson, (BArrayType) entityBodyType); } catch (NullPointerException ex) { throw new BallerinaConnectorException("cannot convert payload to an array of type: " + entityBodyType.getName()); } }
public boolean equals(Object obj) { if (obj instanceof BType) { BType other = (BType) obj; boolean namesEqual = this.typeName.equals(other.getName()); // If both package paths are null or both package paths are not null, // then check their names. If not return false if (this.pkgPath == null && other.getPackagePath() == null) { return namesEqual; } else if (this.pkgPath != null && other.getPackagePath() != null) { return this.pkgPath.equals(other.getPackagePath()) && namesEqual; } } return false; }
/** * Convert a json to the relevant record type. * * @param entityBodyType Represents entity body type * @param bjson Represents the json value that needs to be converted * @return the relevant ballerina record or object */ private static BValue getRecord(BType entityBodyType, BValue bjson) { try { return JSONUtils.convertJSONToStruct(bjson, (BStructureType) entityBodyType); } catch (NullPointerException ex) { throw new BallerinaConnectorException("cannot convert payload to record type: " + entityBodyType.getName()); } }
public String createTable(BType constrainedType, BValueArray primaryKeys, BValueArray indexeColumns) { String tableName = TableConstants.TABLE_PREFIX + constrainedType.getName() .toUpperCase() + "_" + getTableID(); String sqlStmt = generateCreateTableStatment(tableName, constrainedType, primaryKeys); executeStatement(sqlStmt); //Add Index Data if (indexeColumns != null) { generateIndexesForTable(tableName, indexeColumns); } return tableName; }
public static <T> T getNativeObject(BMap<String, BValue> struct, String objectId, Class<T> objectClass, Context context) { Object messageNativeData = struct.getNativeData(objectId); return verifyNativeObject(context, struct.getType().getName(), objectClass, messageNativeData); }
public SerializableBRefArray(BValueArray bRefValueArray, SerializableState state) { BArrayType arrayType = (BArrayType) bRefValueArray.getType(); if (arrayType != null) { structName = arrayType.getElementType().getName(); pkgPath = arrayType.getElementType().getPackagePath(); } for (int i = 0; i < bRefValueArray.size(); i++) { values.add(state.serialize(bRefValueArray.getRefValue(i))); } }
public SerializableBMap(BMap<K, V> bMap, SerializableState state) { structName = bMap.getType().getName(); pkgPath = bMap.getType().getPackagePath(); bMap.getNativeData().forEach((k, o) -> nativeData.put(k, state.serialize(o))); bMap.getMap().forEach((k, v) -> map.put(k, state.serialize(v))); }
public void addData(BMap<String, BValue> data, Context context) { if (data.getType() != this.constraintType) { throw new BallerinaException("incompatible types: record of type:" + data.getType().getName() + " cannot be added to a table with type:" + this.constraintType.getName()); } tableProvider.insertData(tableName, data); reset(); }
private void validateEntityBodyParam(ParamDetail entityBodyParam) { String entityBodyAttributeValue = resource.getEntityBodyAttributeValue(); if (!entityBodyAttributeValue.equals(entityBodyParam.getVarName())) { throw new BallerinaConnectorException("expected '" + entityBodyAttributeValue + "' as param name, but found '" + entityBodyParam.getVarName() + "'"); } int type = entityBodyParam.getVarType().getTag(); if (type == TypeTags.RECORD_TYPE_TAG || type == TypeTags.JSON_TAG || type == TypeTags.XML_TAG || type == TypeTags.STRING_TAG || (type == TypeTags.ARRAY_TAG && validArrayType(entityBodyParam))) { this.entityBody = entityBodyParam; paramCount++; } else { throw new BallerinaConnectorException("incompatible entity-body type : " + entityBodyParam.getVarType().getName()); } }