Codota Logo
ClassNode.getInterfaces
Code IndexAdd Codota to your IDE (free)

How to use
getInterfaces
method
in
org.codehaus.groovy.ast.ClassNode

Best Java code snippets using org.codehaus.groovy.ast.ClassNode.getInterfaces (Showing top 20 results out of 315)

  • Common ways to obtain ClassNode
private void myMethod () {
ClassNode c =
  • Codota IconExpression expression;expression.getType()
  • Codota IconMethodNode methodNode;methodNode.getReturnType()
  • Codota IconString name;ClassHelper.make(name)
  • Smart code suggestions by Codota
}
origin: org.codehaus.groovy/groovy

@Override
public ClassNode[] getInterfaces() {
  Set<ClassNode> nodes = new LinkedHashSet<ClassNode>();
  for (ClassNode delegate : delegates) {
    ClassNode[] interfaces = delegate.getInterfaces();
    if (interfaces != null) Collections.addAll(nodes, interfaces);
  }
  return nodes.toArray(ClassNode.EMPTY_ARRAY);
}
origin: org.codehaus.groovy/groovy

private int getSuperInterfaceCount(ClassNode element) {
  int count = 1;
  ClassNode[] interfaces = element.getInterfaces();
  for (ClassNode anInterface : interfaces) {
    count = Math.max(count, getSuperInterfaceCount(anInterface) + 1);
  }
  return count;
}
origin: org.codehaus.groovy/groovy

@Override
public ClassNode[] getInterfaces() {
  lazyInitSupers();
  return super.getInterfaces();
}
origin: org.codehaus.groovy/groovy

/**
 * Get methods from all interfaces.
 * Methods from interfaces visited early will be overwritten by later ones.
 *
 * @param cNode The ClassNode
 * @return A map of methods
 */
public static Map<String, MethodNode> getDeclaredMethodsFromInterfaces(ClassNode cNode) {
  Map<String, MethodNode> result = new HashMap<String, MethodNode>();
  ClassNode[] interfaces = cNode.getInterfaces();
  for (ClassNode iface : interfaces) {
    result.putAll(iface.getDeclaredMethodsMap());
  }
  return result;
}
origin: org.codehaus.groovy/groovy

private static FieldNode getDeclaredOrInheritedField(ClassNode cn, String fieldName) {
  ClassNode node = cn;
  while (node != null) {
    FieldNode fn = node.getDeclaredField(fieldName);
    if (fn != null) return fn;
    List<ClassNode> interfacesToCheck = new ArrayList<ClassNode>(Arrays.asList(node.getInterfaces()));
    while (!interfacesToCheck.isEmpty()) {
      ClassNode nextInterface = interfacesToCheck.remove(0);
      fn = nextInterface.getDeclaredField(fieldName);
      if (fn != null) return fn;
      interfacesToCheck.addAll(Arrays.asList(nextInterface.getInterfaces()));
    }
    node = node.getSuperClass();
  }
  return null;
}
origin: org.codehaus.groovy/groovy

private void getAllInterfaces(Set<ClassNode> res) {
  if (isInterface())
   res.add(this);
  for (ClassNode anInterface : getInterfaces()) {
    res.add(anInterface);
    anInterface.getAllInterfaces(res);
  }
}
origin: org.codehaus.groovy/groovy

  public int compare(final ClassNode o1, final ClassNode o2) {
    int interfaceCountForO1 = o1.getInterfaces().length;
    int interfaceCountForO2 = o2.getInterfaces().length;
    if (interfaceCountForO1 > interfaceCountForO2) return -1;
    if (interfaceCountForO1 < interfaceCountForO2) return 1;
    int methodCountForO1 = o1.getMethods().size();
    int methodCountForO2 = o2.getMethods().size();
    if (methodCountForO1 > methodCountForO2) return -1;
    if (methodCountForO1 < methodCountForO2) return 1;
    return o1.getName().compareTo(o2.getName());
  }
};
origin: org.codehaus.groovy/groovy

private static void extractInterfaces(ClassNode node, Set<ClassNode> interfaces) {
  if (node==null) return;
  Collections.addAll(interfaces, node.getInterfaces());
  extractInterfaces(node.getSuperClass(), interfaces);
}

origin: org.codehaus.groovy/groovy

/**
 * @return the array of interfaces which this ClassNode implements
 */
public ClassNode[] getInterfaces() {
  if (redirect!=null) return redirect().getInterfaces();
  lazyClassInit();
  return interfaces;
}
origin: org.codehaus.groovy/groovy

private static void extractMostSpecificImplementedInterfaces(final ClassNode type, final ClassNode inode, final List<ClassNode> result) {
  if (type.implementsInterface(inode)) result.add(inode);
  else {
    ClassNode[] interfaces = inode.getInterfaces();
    for (ClassNode interfaceNode : interfaces) {
      if (type.implementsInterface(interfaceNode)) result.add(interfaceNode);
    }
    if (result.isEmpty() && interfaces.length>0) {
      // none if the direct interfaces match, but we must check "upper" in the hierarchy
      for (ClassNode interfaceNode : interfaces) {
        extractMostSpecificImplementedInterfaces(type, interfaceNode, result);
      }
    }
  }
}
origin: org.codehaus.groovy/groovy

/**
 * Adds methods from interfaces and parent interfaces. Existing entries in the methods map take precedence.
 * Methods from interfaces visited early take precedence over later ones.
 *
 * @param cNode The ClassNode
 * @param methodsMap A map of existing methods to alter
 */
public static void addDeclaredMethodsFromAllInterfaces(ClassNode cNode, Map<String, MethodNode> methodsMap) {
  List cnInterfaces = Arrays.asList(cNode.getInterfaces());
  ClassNode parent = cNode.getSuperClass();
  while (parent != null && !parent.equals(ClassHelper.OBJECT_TYPE)) {
    ClassNode[] interfaces = parent.getInterfaces();
    for (ClassNode iface : interfaces) {
      if (!cnInterfaces.contains(iface)) {
        methodsMap.putAll(iface.getDeclaredMethodsMap());
      }
    }
    parent = parent.getSuperClass();
  }
}
origin: org.codehaus.groovy/groovy

protected void collectAllInterfaceMethodsByName(final ClassNode receiver, final String name, final List<MethodNode> methods) {
  ClassNode cNode = receiver;
  while (cNode != null) {
    ClassNode[] interfaces = cNode.getInterfaces();
    if (interfaces != null && interfaces.length > 0) {
      for (ClassNode node : interfaces) {
        List<MethodNode> intfMethods = node.getMethods(name);
        methods.addAll(intfMethods);
        collectAllInterfaceMethodsByName(node, name, methods);
      }
    }
    cNode = cNode.getSuperClass();
  }
}
origin: org.codehaus.groovy/groovy

/**
 * Collects all interfaces of a class node, but reverses the order of the declaration of direct interfaces
 * of this class node. This is used to make sure a trait implementing A,B where both A and B have the same
 * method will take the method from B (latest), aligning the behavior with categories.
 * @param cNode a class node
 * @param interfaces ordered set of interfaces
 */
public static LinkedHashSet<ClassNode> collectAllInterfacesReverseOrder(ClassNode cNode, LinkedHashSet<ClassNode> interfaces) {
  if (cNode.isInterface())
    interfaces.add(cNode);
  ClassNode[] directInterfaces = cNode.getInterfaces();
  for (int i = directInterfaces.length-1; i >=0 ; i--) {
    final ClassNode anInterface = directInterfaces[i];
    interfaces.add(GenericsUtils.parameterizeType(cNode,anInterface));
    collectAllInterfacesReverseOrder(anInterface, interfaces);
  }
  return interfaces;
}
origin: org.codehaus.groovy/groovy

private void addToCache(ClassNode node){
  if (node == null) return;
  String name = node.getName();
  if (!precompiledDependencies.containsKey(name)  &&
    !node.isPrimaryClassNode())
  {
    return;
  }
  current.add(node.getName());
  addToCache(node.getSuperClass());
  addToCache(node.getInterfaces());
}

origin: org.codehaus.groovy/groovy

public static String getGenericsSignature(ClassNode node) {
  if (!usesGenericsInClassSignature(node)) return null;
  GenericsType[] genericsTypes = node.getGenericsTypes();
  StringBuilder ret = new StringBuilder(100);
  getGenericsTypeSpec(ret, genericsTypes);
  GenericsType extendsPart = new GenericsType(node.getUnresolvedSuperClass(false));
  writeGenericsBounds(ret, extendsPart, true);
  ClassNode[] interfaces = node.getInterfaces();
  for (int i = 0; i < interfaces.length; i++) {
    GenericsType interfacePart = new GenericsType(interfaces[i]);
    writeGenericsBounds(ret, interfacePart, false);
  }
  return ret.toString();
}
origin: org.codehaus.groovy/groovy

private static boolean usesGenericsInClassSignature(ClassNode node) {
  if (!node.isUsingGenerics()) return false;
  if (hasGenerics(node)) return true;
  ClassNode sclass = node.getUnresolvedSuperClass(false);
  if (sclass.isUsingGenerics()) return true;
  ClassNode[] interfaces = node.getInterfaces();
  if (interfaces != null) {
    for (int i = 0; i < interfaces.length; i++) {
      if (interfaces[i].isUsingGenerics()) return true;
    }
  }
  return false;
}
origin: org.codehaus.groovy/groovy

private boolean directlyImplementsTrait(ClassNode trait) {
  ClassNode[] interfaces = currentClass.getInterfaces();
  if (interfaces==null) {
    return currentClass.getSuperClass().equals(trait);
  }
  for (ClassNode node : interfaces) {
    if (node.equals(trait)) {
      return true;
    }
  }
  return currentClass.getSuperClass().equals(trait);
}
origin: org.codehaus.groovy/groovy

@Override
public void visitClass(ClassNode node) {
  boolean error = checkWildcard(node);
  if (error) return;
  boolean isAnon = node instanceof InnerClassNode && ((InnerClassNode) node).isAnonymous();
  checkGenericsUsage(node.getUnresolvedSuperClass(false), node.getSuperClass(), isAnon ? true : null);
  ClassNode[] interfaces = node.getInterfaces();
  for (ClassNode anInterface : interfaces) {
    checkGenericsUsage(anInterface, anInterface.redirect());
  }
  node.visitContents(this);
}
origin: org.codehaus.groovy/groovy

private void checkImplementsAndExtends(ClassNode node) {
  ClassNode cn = node.getSuperClass();
  if (cn.isInterface() && !node.isInterface()) {
    addError("You are not allowed to extend the " + getDescription(cn) + ", use implements instead.", node);
  }
  for (ClassNode anInterface : node.getInterfaces()) {
    cn = anInterface;
    if (!cn.isInterface()) {
      addError("You are not allowed to implement the " + getDescription(cn) + ", use extends instead.", node);
    }
  }
}
origin: groovy/groovy-core

public void visitClass(ClassNode node) {
  visitType(node);
  visitType(node.getUnresolvedSuperClass());
  visitTypes(node.getInterfaces());
  super.visitClass(node);
}
org.codehaus.groovy.astClassNodegetInterfaces

Javadoc

Returns an array of ClassNodes representing the interfaces the class implements

Popular methods of ClassNode

  • getName
  • getMethods
    This methods creates a list of all methods with this name of the current class and of all super clas
  • <init>
    Constructor used by makeArray() if no real class is available
  • getSuperClass
  • equals
  • addMethod
  • getAnnotations
  • addField
  • getFields
    Returns a list containing FieldNode objects for each field in the class represented by this ClassNod
  • getPlainNodeReference
  • getField
    Finds a field matching the given name in this class or a parent class.
  • getMethod
    Finds a method matching the given name and parameters in this class or any parent class.
  • getField,
  • getMethod,
  • isInterface,
  • getNameWithoutPackage,
  • isScript,
  • getDeclaredMethod,
  • getGenericsTypes,
  • getDeclaredConstructors,
  • getModifiers,
  • getTypeClass

Popular in Java

  • Running tasks concurrently on multiple threads
  • startActivity (Activity)
  • getSharedPreferences (Context)
  • runOnUiThread (Activity)
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • FileInputStream (java.io)
    A FileInputStream obtains input bytes from a file in a file system. What files are available depends
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • StringTokenizer (java.util)
    The string tokenizer class allows an application to break a string into tokens. The tokenization met
  • TreeMap (java.util)
    A Red-Black tree based NavigableMap implementation. The map is sorted according to the Comparable of
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now