java.lang.reflect.Method.isDefault()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(437)

本文整理了Java中java.lang.reflect.Method.isDefault()方法的一些代码示例,展示了Method.isDefault()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Method.isDefault()方法的具体详情如下:
包路径:java.lang.reflect.Method
类名称:Method
方法名:isDefault

Method.isDefault介绍

暂无

代码示例

代码示例来源:origin: square/retrofit

@Override boolean isDefaultMethod(Method method) {
 return method.isDefault();
}

代码示例来源:origin: com.squareup.retrofit2/retrofit

@Override boolean isDefaultMethod(Method method) {
 return method.isDefault();
}

代码示例来源:origin: square/retrofit

@IgnoreJRERequirement // Guarded by API check.
@Override boolean isDefaultMethod(Method method) {
 if (Build.VERSION.SDK_INT < 24) {
  return false;
 }
 return method.isDefault();
}

代码示例来源:origin: org.freemarker/freemarker

public boolean isDefaultMethod(Method method) {
  return method.isDefault();
}

代码示例来源:origin: lettuce-io/lettuce-core

/**
 * Checks whether the given method is a query method candidate.
 *
 * @param method
 * @return
 */
private boolean isQueryMethodCandidate(Method method) {
  return !method.isBridge() && !method.isDefault();
}

代码示例来源:origin: com.squareup.retrofit2/retrofit

@IgnoreJRERequirement // Guarded by API check.
@Override boolean isDefaultMethod(Method method) {
 if (Build.VERSION.SDK_INT < 24) {
  return false;
 }
 return method.isDefault();
}

代码示例来源:origin: embulk/embulk

/**
 * Returns a Multimap from fieldName Strings to their getter Methods.
 *
 * It expects to be called only from TaskSerDe. Multimap is used inside org.embulk.config.
 */
static Multimap<String, Method> fieldGetters(Class<?> iface) {
  ImmutableMultimap.Builder<String, Method> builder = ImmutableMultimap.builder();
  for (Method method : iface.getMethods()) {
    String methodName = method.getName();
    String fieldName = getterFieldNameOrNull(methodName);
    if (fieldName != null && hasExpectedArgumentLength(method, 0)
        && (!method.isDefault() || method.getAnnotation(Config.class) != null)) {
      // If the method has default implementation, and @Config is not annotated there, the method is kept.
      builder.put(fieldName, method);
    }
  }
  return builder.build();
}

代码示例来源:origin: wildfly/wildfly

if(tmp != null) {
  for(Method mm: tmp)
    if(mm.isDefault())
      methods.add(mm);

代码示例来源:origin: jdbi/jdbi

if (method.isDefault() && !method.isSynthetic()) {
  throw new IllegalStateException(String.format(
      "Default method %s.%s has @%s annotation. "

代码示例来源:origin: apache/flink

/**
   * Test if this method should be skipped in our check for proper forwarding, e.g. because it is just a bridge.
   */
  private static boolean checkSkipMethodForwardCheck(Method delegateMethod, Set<Method> skipMethods) {

    if (delegateMethod.isBridge()
      || delegateMethod.isDefault()
      || skipMethods.contains(delegateMethod)) {
      return true;
    }

    // skip methods declared in Object (Mockito doesn't like them)
    try {
      Object.class.getMethod(delegateMethod.getName(), delegateMethod.getParameterTypes());
      return true;
    } catch (Exception ignore) {
    }
    return false;
  }
}

代码示例来源:origin: com.thoughtworks.xstream/xstream

@Override
  public String serializedClass(final Class type) {
    Class<?> replacement = null;
    if (Types.isLambdaType(type)) {
      if (Serializable.class.isAssignableFrom(type)) {
        final Class<?>[] interfaces = type.getInterfaces();
        if (interfaces.length > 1) {
          for (int i = 0; replacement == null && i < interfaces.length; i++) {
            final Class<?> iface = interfaces[i];
            for (final Method method : iface.getMethods()) {
              if (!method.isDefault() && !Modifier.isStatic(method.getModifiers())) {
                replacement = iface;
                break;
              }
            }
          }
        } else {
          replacement = interfaces[0];
        }
      } else {
        replacement = Null.class;
      }
    }
    return super.serializedClass(replacement == null ? type : replacement);
  }
}

代码示例来源:origin: jdbi/jdbi

@Override
public Optional<Handler> buildHandler(Class<?> sqlObjectType, Method method) {
  if (!method.isDefault()) {
    return Optional.empty();

代码示例来源:origin: lettuce-io/lettuce-core

/**
 * Lookup a {@link MethodHandle} for a default {@link Method}.
 *
 * @param method must be a {@link Method#isDefault() default} {@link Method}.
 * @return the {@link MethodHandle}.
 */
public static MethodHandle lookupMethodHandle(Method method) throws ReflectiveOperationException {
  LettuceAssert.notNull(method, "Method must not be null");
  LettuceAssert.isTrue(method.isDefault(), "Method is not a default method");
  return methodHandleLookup.lookup(method);
}

代码示例来源:origin: jOOQ/jOOR

if (method.isDefault()) {

代码示例来源:origin: robolectric/robolectric

void write() {
 int accessModifiers =
   iClass.getModifiers() & (Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE);
 visit(
   V1_5,
   accessModifiers | ACC_SUPER | ACC_FINAL,
   reflectorType.getInternalName(),
   null,
   OBJECT_TYPE.getInternalName(),
   new String[] {iType.getInternalName()});
 writeTargetField();
 writeConstructor();
 for (Method method : iClass.getMethods()) {
  if (method.isDefault()) continue;
  Accessor accessor = method.getAnnotation(Accessor.class);
  if (accessor != null) {
   new AccessorMethodWriter(method, accessor).write();
  } else {
   new ReflectorMethodWriter(method).write();
  }
 }
 visitEnd();
}

代码示例来源:origin: lettuce-io/lettuce-core

if (method.isDefault()) {
  return methodHandleCache.computeIfAbsent(method, ClusterFutureSyncInvocationHandler::lookupDefaultMethod)
      .bindTo(proxy).invokeWithArguments(args);

代码示例来源:origin: lettuce-io/lettuce-core

@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
  Method method = invocation.getMethod();
  if (!method.isDefault()) {
    return invocation.proceed();
  }
  LettuceAssert.isTrue(invocation instanceof InvocationTargetProvider,
      "Invocation must provide a target object via InvocationTargetProvider");
  InvocationTargetProvider targetProvider = (InvocationTargetProvider) invocation;
  return methodHandleCache.computeIfAbsent(method, DefaultMethodInvokingInterceptor::lookupMethodHandle)
      .bindTo(targetProvider.getInvocationTarget()).invokeWithArguments(invocation.getArguments());
}

代码示例来源:origin: MovingBlocks/Terasology

if (!method.isDefault() && !method.isBridge() && !method.isSynthetic()) {
  api.put(category, " -- " + Arrays.toString(method.getParameterTypes()) +  " (PARAMETERS)");
  api.put(category, " -- " + Arrays.toString(method.getExceptionTypes()) +  " (EXCEPTIONS)");
} else if (method.isDefault() && apiClass.isInterface()) {
  api.put(category, " - " + method.getName() +  " (DEFAULT METHOD)");
  api.put(category, " -- " + method.getReturnType() +  " (RETURN)");

代码示例来源:origin: runelite/runelite

if (method.isDefault())
  if (method.isDefault())
if (method.isDefault())

代码示例来源:origin: runelite/runelite

if (!method.isDefault())

相关文章

微信公众号

最新文章

更多