本文整理汇总了Java中org.eclipse.jdt.internal.compiler.lookup.MethodBinding.getDefaultValue方法的典型用法代码示例。如果您正苦于以下问题:Java MethodBinding.getDefaultValue方法的具体用法?Java MethodBinding.getDefaultValue怎么用?Java MethodBinding.getDefaultValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.internal.compiler.lookup.MethodBinding
的用法示例。
在下文中一共展示了MethodBinding.getDefaultValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDefaultValue
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; //导入方法依赖的package包/类
@Override
public AnnotationValue getDefaultValue() {
MethodBinding binding = (MethodBinding)_binding;
Object defaultValue = binding.getDefaultValue();
if (defaultValue != null) return new AnnotationMemberValue(_env, defaultValue, binding);
return null;
}
示例2: invoke
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding; //导入方法依赖的package包/类
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
{
if (this._binding == null) return null;
final String methodName = method.getName();
if ( args == null || args.length == 0 ) {
if( methodName.equals("hashCode") ) { //$NON-NLS-1$
return new Integer( hashCode() );
}
else if( methodName.equals("toString") ) { //$NON-NLS-1$
return toString();
}
else if( methodName.equals("annotationType")) { //$NON-NLS-1$
return proxy.getClass().getInterfaces()[0];
}
}
else if ( args.length == 1 && methodName.equals("equals") ) { //$NON-NLS-1$
return new Boolean( equals( args[0] ) );
}
// If it's not one of the above methods, it must be an annotation member, so it cannot take any arguments
if ( args != null && args.length != 0 ) {
throw new NoSuchMethodException("method " + method.getName() + formatArgs(args) + " does not exist on annotation " + toString()); //$NON-NLS-1$ //$NON-NLS-2$
}
final MethodBinding methodBinding = getMethodBinding(methodName);
if ( methodBinding == null ) {
throw new NoSuchMethodException("method " + method.getName() + "() does not exist on annotation" + toString()); //$NON-NLS-1$ //$NON-NLS-2$
}
Object actualValue = null;
boolean foundMethod = false;
ElementValuePair[] pairs = _binding.getElementValuePairs();
for (ElementValuePair pair : pairs) {
if (methodName.equals(new String(pair.getName()))) {
actualValue = pair.getValue();
foundMethod = true;
break;
}
}
if (!foundMethod) {
// couldn't find explicit value; see if there's a default
actualValue = methodBinding.getDefaultValue();
}
Class<?> expectedType = method.getReturnType();
TypeBinding actualType = methodBinding.returnType;
return getReflectionValue(actualValue, actualType, expectedType);
}