@Override public boolean equals(Object obj) { if (obj instanceof BArrayType) { BArrayType other = (BArrayType) obj; if (other.state == BArrayState.CLOSED_SEALED && this.size != other.size) { return false; } return this.elementType.equals(other.elementType); } return false; }
@Override public boolean equals(Object obj) { if (!super.equals(obj) || !(obj instanceof BJSONType)) { return false; } BJSONType other = (BJSONType) obj; if (constraint == other.constraint) { return true; } else if (constraint == null || other.constraint == null) { return false; } return constraint.equals(other.constraint); } }
@Override public boolean equals(Object obj) { if (!super.equals(obj) || !(obj instanceof BStreamType)) { return false; } BStreamType other = (BStreamType) obj; if (constraint == other.constraint) { return true; } if (constraint == null || other.constraint == null) { return false; } return constraint.equals(other.constraint); } }
@Override public boolean equals(Object obj) { if (!super.equals(obj) || !(obj instanceof BTableType)) { return false; } BTableType other = (BTableType) obj; if (constraint == other.constraint) { return true; } if (constraint == null || other.constraint == null) { return false; } return constraint.equals(other.constraint); } }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof BFunctionType)) { return false; } if (!super.equals(o)) { return false; } BFunctionType that = (BFunctionType) o; if (!Arrays.equals(paramTypes, that.paramTypes)) { return false; } return Arrays.equals(retParamTypes, that.retParamTypes); }
public ServiceInfo getServiceInfo(BType serviceType) { return serviceInfoMap.values().stream() .filter(serviceInfo -> serviceInfo.serviceType.getType().equals(serviceType)).findFirst().orElse(null); }
/** * This method is for use as the first check in checking for cast/assignability for two types. * Checks whether the source type is the same as the target type or if the target type is any type, and if true * the return value would be true. * * @param rhsType the source type - the type (of the value) being cast/assigned * @param lhsType the target type against which cast/assignability is checked * @return true if the lhsType is any or is the same as rhsType */ private static boolean isSameOrAnyType(BType rhsType, BType lhsType) { return (lhsType.getTag() == TypeTags.ANY_TAG && rhsType.getTag() != TypeTags.ERROR_TAG) || rhsType .equals(lhsType); }
private static boolean isValidMapInsertion(BType mapType, BValue value) { if (value == null) { return true; } BType constraintType = ((BMapType) mapType).getConstrainedType(); if (constraintType == BTypes.typeAny || constraintType.equals(value.getType())) { return true; } return checkCast(value, constraintType, new ArrayList<>()); }
private static boolean isSameType(BType rhsType, BType lhsType) { // First check whether both references points to the same object. if (rhsType == lhsType || rhsType.equals(lhsType)) { return true; } if (rhsType.getTag() == lhsType.getTag() && rhsType.getTag() == TypeTags.ARRAY_TAG) { return checkArrayEquivalent(rhsType, lhsType); } // TODO Support function types, json/map constrained types etc. if (rhsType.getTag() == TypeTags.MAP_TAG && lhsType.getTag() == TypeTags.MAP_TAG) { return lhsType.equals(rhsType); } return false; }
private static boolean checkArrayCast(BType sourceType, BType targetType, List<TypePair> unresolvedTypes) { if (targetType.getTag() == TypeTags.ARRAY_TAG && sourceType.getTag() == TypeTags.ARRAY_TAG) { BArrayType sourceArrayType = (BArrayType) sourceType; BArrayType targetArrayType = (BArrayType) targetType; if (targetArrayType.getDimensions() > sourceArrayType.getDimensions()) { return false; } return checkArrayCast(sourceArrayType.getElementType(), targetArrayType.getElementType(), unresolvedTypes); } else if (targetType.getTag() == TypeTags.UNION_TAG) { return checkUnionAssignable(sourceType, targetType, unresolvedTypes); } if (targetType.getTag() == TypeTags.ANY_TAG) { return true; } return sourceType.equals(targetType); }
private static boolean checkIsType(BType sourceType, BType targetType, List<TypePair> unresolvedTypes) { if (sourceType == targetType || sourceType.equals(targetType)) { return true;
} else if (isSimpleBasicType(expectedType)) { execExplicitlyTypedExpressionOpCode(ctx, sf, expectedType, bRefTypeValue, j); } else if (expectedType.equals(bRefTypeValue.getType())) { sf.refRegs[j] = bRefTypeValue; } else {