本文整理匯總了Java中org.eclipse.jdt.core.dom.ITypeBinding.getDeclaredFields方法的典型用法代碼示例。如果您正苦於以下問題:Java ITypeBinding.getDeclaredFields方法的具體用法?Java ITypeBinding.getDeclaredFields怎麽用?Java ITypeBinding.getDeclaredFields使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jdt.core.dom.ITypeBinding
的用法示例。
在下文中一共展示了ITypeBinding.getDeclaredFields方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: findFieldInType
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
/**
* Finds the field specified by <code>fieldName</code> in
* the given <code>type</code>. Returns <code>null</code> if no such field exists.
* @param type the type to search the field in
* @param fieldName the field name
* @return the binding representing the field or <code>null</code>
*/
public static IVariableBinding findFieldInType(ITypeBinding type, String fieldName) {
if (type.isPrimitive()) {
return null;
}
IVariableBinding[] fields= type.getDeclaredFields();
for (int i= 0; i < fields.length; i++) {
IVariableBinding field= fields[i];
if (field.getName().equals(fieldName)) {
return field;
}
}
return null;
}
示例2: hasMethodWithName
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
private static boolean hasMethodWithName(ITypeBinding typeBinding, String name) {
IVariableBinding[] fields= typeBinding.getDeclaredFields();
for (int i= 0; i < fields.length; i++) {
if (fields[i].getName().equals(name)) {
return true;
}
}
ITypeBinding superclass= typeBinding.getSuperclass();
if (superclass != null) {
return hasMethodWithName(superclass, name);
}
return false;
}
示例3: getDeclaredFields
import org.eclipse.jdt.core.dom.ITypeBinding; //導入方法依賴的package包/類
public static List<ast.FieldDeclaration> getDeclaredFields(ITypeBinding typeBinding) {
List<ast.FieldDeclaration> fieldList = new ArrayList<ast.FieldDeclaration>();
for(IVariableBinding fieldDecl: typeBinding.getDeclaredFields()){
fieldList.add(getFieldDeclaration(fieldDecl));
}
return fieldList;
}