Tabnine Logo
ReflectionUtils.isOverriddenMethod
Code IndexAdd Tabnine to your IDE (free)

How to use
isOverriddenMethod
method
in
io.swagger.v3.core.util.ReflectionUtils

Best Java code snippets using io.swagger.v3.core.util.ReflectionUtils.isOverriddenMethod (Showing top 6 results out of 315)

origin: swagger-api/swagger-core

/**
 * Checks if the method methodToFind is the overridden method from the superclass or superinterface.
 *
 * @param methodToFind is method to check
 * @param cls          is method class
 * @return true if the method is overridden method
 */
public static boolean isOverriddenMethod(Method methodToFind, Class<?> cls) {
  Set<Class<?>> superClasses = new HashSet<>();
  for (Class c : cls.getInterfaces()) {
    superClasses.add(c);
  }
  if (cls.getSuperclass() != null) {
    superClasses.add(cls.getSuperclass());
  }
  for (Class<?> superClass : superClasses) {
    if (superClass != null && !(superClass.equals(Object.class))) {
      for (Method method : superClass.getMethods()) {
        if (method.getName().equals(methodToFind.getName()) && method.getReturnType().isAssignableFrom(methodToFind.getReturnType())
            && Arrays.equals(method.getParameterTypes(), methodToFind.getParameterTypes()) && !Arrays.equals(method.getGenericParameterTypes(), methodToFind.getGenericParameterTypes())) {
          return true;
        }
      }
      if (isOverriddenMethod(methodToFind, superClass)) {
        return true;
      }
    }
  }
  return false;
}
origin: swagger-api/swagger-core

@Test
public void isOverriddenMethodTest() throws NoSuchMethodException {
  for (Method method : Child.class.getMethods()) {
    if ("parametrizedMethod1".equals(method.getName())) {
      final boolean result = ReflectionUtils.isOverriddenMethod(method, Child.class);
      final Class<?> first = method.getParameterTypes()[0];
      if (Number.class.equals(first)) {
        Assert.assertTrue(result);
      } else if (Integer.class.equals(first)) {
        Assert.assertFalse(result);
      }
    } else if ("parametrizedMethod3".equals(method.getName())) {
      Assert.assertFalse(ReflectionUtils.isOverriddenMethod(method, Child.class));
    }
  }
  for (Method method : Object.class.getMethods()) {
    if ("equals".equals(method.getName())) {
      Assert.assertFalse(ReflectionUtils.isOverriddenMethod(method, Object.class));
    }
  }
  for (Method method : IParent.class.getMethods()) {
    if ("parametrizedMethod5".equals(method.getName())) {
      Assert.assertTrue(ReflectionUtils.isOverriddenMethod(method, IParent.class));
    } else if ("parametrizedMethod2".equals(method.getName())) {
      Assert.assertFalse(ReflectionUtils.isOverriddenMethod(method, IParent.class));
    } else {
      Assert.fail("Method not expected");
    }
  }
}
origin: swagger-api/swagger-core

javax.ws.rs.Consumes methodConsumes = ReflectionUtils.getAnnotation(method, javax.ws.rs.Consumes.class);
if (ReflectionUtils.isOverriddenMethod(method, cls)) {
  continue;
origin: io.swagger.core.v3/swagger-core

/**
 * Checks if the method methodToFind is the overridden method from the superclass or superinterface.
 *
 * @param methodToFind is method to check
 * @param cls          is method class
 * @return true if the method is overridden method
 */
public static boolean isOverriddenMethod(Method methodToFind, Class<?> cls) {
  Set<Class<?>> superClasses = new HashSet<>();
  for (Class c : cls.getInterfaces()) {
    superClasses.add(c);
  }
  if (cls.getSuperclass() != null) {
    superClasses.add(cls.getSuperclass());
  }
  for (Class<?> superClass : superClasses) {
    if (superClass != null && !(superClass.equals(Object.class))) {
      for (Method method : superClass.getMethods()) {
        if (method.getName().equals(methodToFind.getName()) && method.getReturnType().isAssignableFrom(methodToFind.getReturnType())
            && Arrays.equals(method.getParameterTypes(), methodToFind.getParameterTypes()) && !Arrays.equals(method.getGenericParameterTypes(), methodToFind.getGenericParameterTypes())) {
          return true;
        }
      }
      if (isOverriddenMethod(methodToFind, superClass)) {
        return true;
      }
    }
  }
  return false;
}
origin: io.swagger.core.v3/swagger-jaxrs2

javax.ws.rs.Consumes methodConsumes = ReflectionUtils.getAnnotation(method, javax.ws.rs.Consumes.class);
if (ReflectionUtils.isOverriddenMethod(method, cls)) {
  continue;
origin: noboomu/proteus

javax.ws.rs.Consumes methodConsumes = ReflectionUtils.getAnnotation(method, javax.ws.rs.Consumes.class);
if (ReflectionUtils.isOverriddenMethod(method, cls))
io.swagger.v3.core.utilReflectionUtilsisOverriddenMethod

Javadoc

Checks if the method methodToFind is the overridden method from the superclass or superinterface.

Popular methods of ReflectionUtils

  • getAnnotation
    Returns an annotation by type from a method.
  • getOverriddenMethod
    Returns overridden method from superclass if it exists. If method was not found returns null.
  • getRepeatableAnnotationsArray
  • getDeclaredFields
    Returns the list of declared fields from the class cls and its superclasses excluding Object class.
  • getRepeatableAnnotations
    Returns a List of repeatable annotations by type from a method.
  • findMethod
    Searches the method methodToFind in given class cls. If the method is found returns it, else return
  • getParameterAnnotations
  • isConstructorCompatible
  • isInject
  • hasIdenticalParameters
  • isSystemType
  • isVoid
    Checks if the type is void.
  • isSystemType,
  • isVoid,
  • loadClassByName,
  • typeFromString

Popular in Java

  • Reactive rest calls using spring rest template
  • notifyDataSetChanged (ArrayAdapter)
  • getContentResolver (Context)
  • setRequestProperty (URLConnection)
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • RandomAccessFile (java.io)
    Allows reading from and writing to a file in a random-access manner. This is different from the uni-
  • BigDecimal (java.math)
    An immutable arbitrary-precision signed decimal.A value is represented by an arbitrary-precision "un
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • Stack (java.util)
    Stack is a Last-In/First-Out(LIFO) data structure which represents a stack of objects. It enables u
  • Runner (org.openjdk.jmh.runner)
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now