本文整理匯總了Java中org.eclipse.jdt.core.dom.ITypeBinding.isSubTypeCompatible方法的典型用法代碼示例。如果您正苦於以下問題:Java ITypeBinding.isSubTypeCompatible方法的具體用法?Java ITypeBinding.isSubTypeCompatible怎麽用?Java ITypeBinding.isSubTypeCompatible使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jdt.core.dom.ITypeBinding
的用法示例。
在下文中一共展示了ITypeBinding.isSubTypeCompatible方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: filterSubtypeExceptions
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
public static List<ITypeBinding> filterSubtypeExceptions(ITypeBinding[] exceptions) {
List<ITypeBinding> filteredExceptions = new ArrayList<>();
filteredExceptions.addAll(Arrays.asList(exceptions));
for (Iterator<ITypeBinding> subtypeIterator = filteredExceptions.iterator(); subtypeIterator.hasNext();) {
ITypeBinding iTypeBinding = subtypeIterator.next();
for (Iterator<ITypeBinding> supertypeIterator = filteredExceptions.iterator(); supertypeIterator.hasNext();) {
ITypeBinding superTypeBinding = supertypeIterator.next();
if (!iTypeBinding.equals(superTypeBinding) && iTypeBinding.isSubTypeCompatible(superTypeBinding)) {
subtypeIterator.remove();
break;
}
}
}
return filteredExceptions;
}
示例2: isSubtypeCompatible
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
/**
* Return B <: C ?
*
* @param typeB
* @param typeC
* @return
*/
public static boolean isSubtypeCompatible(Type typeB, Type typeC) {
// return typeC.isSubtypeCompatible(typeB);
String typeBName = typeB.getFullyQualifiedName();
Crystal crystal = Crystal.getInstance();
ITypeBinding typeBindingB = crystal.getTypeBindingFromName(typeBName);
String typeCName = typeC.getFullyQualifiedName();
ITypeBinding typeBindingC = crystal.getTypeBindingFromName(typeCName);
if (typeBindingB != null && typeBindingC != null) {
return typeBindingB.isSubTypeCompatible(typeBindingC);
}
return false;
}
示例3: isSubtypeCompatible
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
/**
* Return B <: C ?
* @param typeB
* @param typeC
* @return
*/
public static boolean isSubtypeCompatible(Type typeB, Type typeC) {
// return typeC.isSubtypeCompatible(typeB);
String typeBName = typeB.getFullyQualifiedName();
Crystal crystal = Crystal.getInstance();
ITypeBinding typeBindingB = crystal.getTypeBindingFromName(typeBName);
String typeCName = typeB.getFullyQualifiedName();
ITypeBinding typeBindingC = crystal.getTypeBindingFromName(typeCName);
if (typeBindingB != null && typeBindingC != null ) {
return typeBindingB.isSubTypeCompatible(typeBindingC);
}
return false;
}
示例4: areSubTypeCompatible
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
private static boolean areSubTypeCompatible(IMethodBinding overridden, IMethodBinding overridable) {
if (overridden.getParameterTypes().length != overridable.getParameterTypes().length) {
return false;
}
ITypeBinding overriddenReturn= overridden.getReturnType();
ITypeBinding overridableReturn= overridable.getReturnType();
if (overriddenReturn == null || overridableReturn == null) {
return false;
}
if (!overriddenReturn.getErasure().isSubTypeCompatible(overridableReturn.getErasure())) {
return false;
}
ITypeBinding[] overriddenTypes= overridden.getParameterTypes();
ITypeBinding[] overridableTypes= overridable.getParameterTypes();
Assert.isTrue(overriddenTypes.length == overridableTypes.length);
for (int index= 0; index < overriddenTypes.length; index++) {
final ITypeBinding overridableErasure= overridableTypes[index].getErasure();
final ITypeBinding overriddenErasure= overriddenTypes[index].getErasure();
if (!overridableErasure.isSubTypeCompatible(overriddenErasure) || !overridableErasure.getKey().equals(overriddenErasure.getKey())) {
return false;
}
}
ITypeBinding[] overriddenExceptions= overridden.getExceptionTypes();
ITypeBinding[] overridableExceptions= overridable.getExceptionTypes();
boolean checked= false;
for (int index= 0; index < overriddenExceptions.length; index++) {
checked= false;
for (int offset= 0; offset < overridableExceptions.length; offset++) {
if (overriddenExceptions[index].isSubTypeCompatible(overridableExceptions[offset])) {
checked= true;
}
}
if (!checked) {
return false;
}
}
return true;
}