Tabnine Logo
ClassNode.implementsInterface
Code IndexAdd Tabnine to your IDE (free)

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

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

origin: org.codehaus.groovy/groovy

/**
 * @return true if this class is derived from a groovy object
 *         i.e. it implements GroovyObject
 */
public boolean isDerivedFromGroovyObject() {
  return implementsInterface(ClassHelper.GROOVY_OBJECT_TYPE);
}
origin: org.codehaus.groovy/groovy

@Override
public boolean implementsInterface(final ClassNode classNode) {
  for (ClassNode delegate : delegates) {
    if (delegate.implementsInterface(classNode)) return true;
  }
  return false;
}
origin: org.codehaus.groovy/groovy

private static boolean implementsExternalizable(ClassNode cNode) {
  return cNode.implementsInterface(EXTERNALIZABLE_TYPE);
}
origin: org.codehaus.groovy/groovy

private static boolean isValidAnnotationClass(ClassNode node) {
  return node.implementsInterface(ClassHelper.Annotation_TYPE);
}
origin: org.codehaus.groovy/groovy

private static boolean implementsSerializable(ClassNode cNode) {
  return cNode.implementsInterface(SERIALIZABLE_TYPE);
}
origin: org.codehaus.groovy/groovy

@Override
public void visitClass(ClassNode node) {
  this.optimizeMethodCall = !node.implementsInterface(GROOVY_INTERCEPTABLE_TYPE);
  this.node = node;
  this.scope = nonStaticScope;
  super.visitClass(node);
  this.scope=null;
  this.node=null;
}
origin: org.codehaus.groovy/groovy

private static void addMostSpecificInterface(ClassNode interfaceNode, List<ClassNode> nodes) {
  if (nodes.isEmpty()) nodes.add(interfaceNode);
  for (int i = 0, nodesSize = nodes.size(); i < nodesSize; i++) {
    final ClassNode node = nodes.get(i);
    if (node.equals(interfaceNode)||node.implementsInterface(interfaceNode)) {
      // a more specific interface exists in the list, keep it
      return;
    }
    if (interfaceNode.implementsInterface(node)) {
      // the interface beeing added is more specific than the one in the list, replace it
      nodes.set(i, interfaceNode);
      return;
    }
  }
  // if we reach this point, this means the interface is new
  nodes.add(interfaceNode);
}
origin: org.codehaus.groovy/groovy

public static boolean isOrImplements(ClassNode type, ClassNode interfaceType) {
  return type.equals(interfaceType) || type.implementsInterface(interfaceType);
}
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

private static void removeMethodInSuperInterface(List<MethodNode> toBeRemoved, MethodNode one, MethodNode two) {
  ClassNode oneDC = one.getDeclaringClass();
  ClassNode twoDC = two.getDeclaringClass();
  if (oneDC.implementsInterface(twoDC)) {
    toBeRemoved.add(two);
  } else {
    toBeRemoved.add(one);
  }
}
origin: org.codehaus.groovy/groovy

private static void implementComparable(ClassNode classNode) {
  if (!classNode.implementsInterface(COMPARABLE_TYPE)) {
    classNode.addInterface(makeClassSafeWithGenerics(Comparable.class, classNode));
  }
}
origin: org.codehaus.groovy/groovy

private void updateStaticCompileFlag(final MethodNode mn) {
  ClassNode classNode = getClassNode();
  AnnotatedNode node = mn;
  if (classNode.implementsInterface(ClassHelper.GENERATED_CLOSURE_Type)) {
    node = classNode.getOuterClass();
  }
  isInStaticallyCheckedMethod = mn != null && (
      StaticCompilationVisitor.isStaticallyCompiled(node)
          || classNode.implementsInterface(ClassHelper.GENERATED_CLOSURE_Type)&&classNode.getNodeMetaData(StaticCompilationMetadataKeys.STATIC_COMPILE_NODE)!=null);
}
origin: org.codehaus.groovy/groovy

  /**
   * Determines if the source class implements an interface or subclasses the target type.
   * This method takes the {@link org.codehaus.groovy.ast.tools.WideningCategories.LowestUpperBoundClassNode lowest
   * upper bound class node} type into account, allowing to remove unnecessary casts.
   * @param source the type of interest
   * @param targetType the target type of interest
   */
  public static boolean implementsInterfaceOrSubclassOf(final ClassNode source, final ClassNode targetType) {
    if (source.isDerivedFrom(targetType) || source.implementsInterface(targetType)) return true;
    if (targetType instanceof WideningCategories.LowestUpperBoundClassNode) {
      WideningCategories.LowestUpperBoundClassNode lub = (WideningCategories.LowestUpperBoundClassNode) targetType;
      if (implementsInterfaceOrSubclassOf(source, lub.getSuperClass())) return true;
      for (ClassNode classNode : lub.getInterfaces()) {
        if (source.implementsInterface(classNode)) return true;
      }
    }
    return false;
  }
}
origin: org.codehaus.groovy/groovy

private static boolean isCovariant(ClassNode left, ClassNode right) {
  if (left.isArray() && right.isArray()) {
    return isCovariant(left.getComponentType(), right.getComponentType());
  }
  return left.isDerivedFrom(right) || left.implementsInterface(right);
}
origin: org.codehaus.groovy/groovy

private void checkComparable(PropertyNode pNode) {
  if (pNode.getType().implementsInterface(COMPARABLE_TYPE) || isPrimitiveType(pNode.getType()) || hasAnnotation(pNode.getType(), MY_TYPE)) {
    return;
  }
  addError("Error during " + MY_TYPE_NAME + " processing: property '" +
      pNode.getName() + "' must be Comparable", pNode);
}
origin: org.codehaus.groovy/groovy

private boolean isAssignable(ClassNode node, ClassNode testNode) {
  if (node.isArray() && testNode.isArray()) {
    return isArrayAssignable(node.getComponentType(), testNode.getComponentType());
  }
  if (testNode.isInterface()) {
    if (node.equals(testNode) || node.implementsInterface(testNode)) return true;
  }
  return node.isDerivedFrom(testNode);
}
origin: org.codehaus.groovy/groovy

private void checkClassExtendsAllSelfTypes(ClassNode node) {
  int modifiers = node.getModifiers();
  if (!isInterface(modifiers)) {
    for (ClassNode anInterface : GeneralUtils.getInterfacesAndSuperInterfaces(node)) {
      if (Traits.isTrait(anInterface)) {
        LinkedHashSet<ClassNode> selfTypes = new LinkedHashSet<ClassNode>();
        for (ClassNode type : Traits.collectSelfTypes(anInterface, selfTypes, true, false)) {
          if (type.isInterface() && !node.implementsInterface(type)) {
            addError(getDescription(node)
                + " implements " + getDescription(anInterface)
                + " but does not implement self type " + getDescription(type),
                anInterface);
          } else if (!type.isInterface() && !node.isDerivedFrom(type)) {
            addError(getDescription(node)
                    + " implements " + getDescription(anInterface)
                    + " but does not extend self type " + getDescription(type),
                anInterface);
          }
        }
      }
    }
  }
}
origin: org.codehaus.groovy/groovy

private boolean compatibleArgumentType(ClassNode argumentType, ClassNode paramType) {
  if (argumentType == null) return false;
  if (ClassHelper.getWrapper(argumentType).equals(ClassHelper.getWrapper(paramType))) return true;
  if (paramType.isInterface()) return argumentType.implementsInterface(paramType);
  if (paramType.isArray() && argumentType.isArray())
    return compatibleArgumentType(argumentType.getComponentType(), paramType.getComponentType());
  return ClassHelper.getWrapper(argumentType).isDerivedFrom(ClassHelper.getWrapper(paramType));
}
origin: org.codehaus.groovy/groovy

protected void addPropertyMethod(MethodNode method) {
  classNode.addMethod(method);
  markAsGenerated(classNode, method);
  // GROOVY-4415 / GROOVY-4645: check that there's no abstract method which corresponds to this one
  List<MethodNode> abstractMethods = classNode.getAbstractMethods();
  if (abstractMethods == null) return;
  String methodName = method.getName();
  Parameter[] parameters = method.getParameters();
  ClassNode methodReturnType = method.getReturnType();
  for (MethodNode node : abstractMethods) {
    if (!node.getDeclaringClass().equals(classNode)) continue;
    if (node.getName().equals(methodName) && node.getParameters().length == parameters.length) {
      if (parameters.length == 1) {
        // setter
        ClassNode abstractMethodParameterType = node.getParameters()[0].getType();
        ClassNode methodParameterType = parameters[0].getType();
        if (!methodParameterType.isDerivedFrom(abstractMethodParameterType) && !methodParameterType.implementsInterface(abstractMethodParameterType)) {
          continue;
        }
      }
      ClassNode nodeReturnType = node.getReturnType();
      if (!methodReturnType.isDerivedFrom(nodeReturnType) && !methodReturnType.implementsInterface(nodeReturnType)) {
        continue;
      }
      // matching method, remove abstract status and use the same body
      node.setModifiers(node.getModifiers() ^ ACC_ABSTRACT);
      node.setCode(method.getCode());
    }
  }
}
origin: org.codehaus.groovy/groovy

public boolean implementsInterfaceOrIsSubclassOf(ClassNode type, ClassNode superOrInterface) {
  boolean result = type.equals(superOrInterface)
      || type.isDerivedFrom(superOrInterface)
      || type.implementsInterface(superOrInterface);
  if (result) {
    return true;
  }
  if (GROOVY_OBJECT_TYPE.equals(superOrInterface) && type.getCompileUnit()!=null) {
    // type is being compiled so it will implement GroovyObject later
    return true;
  }
  if (superOrInterface instanceof WideningCategories.LowestUpperBoundClassNode) {
    WideningCategories.LowestUpperBoundClassNode cn = (WideningCategories.LowestUpperBoundClassNode) superOrInterface;
    result = implementsInterfaceOrIsSubclassOf(type, cn.getSuperClass());
    if (result) {
      for (ClassNode interfaceNode : cn.getInterfaces()) {
        result = implementsInterfaceOrIsSubclassOf(type,interfaceNode);
        if (!result) break;
      }
    }
    if (result) return true;
  }
  if (type.isArray() && superOrInterface.isArray()) {
    return implementsInterfaceOrIsSubclassOf(type.getComponentType(), superOrInterface.getComponentType());
  }
  return false;
}
org.codehaus.groovy.astClassNodeimplementsInterface

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

  • Updating database using SQL prepared statement
  • setRequestProperty (URLConnection)
  • getApplicationContext (Context)
  • findViewById (Activity)
  • Color (java.awt)
    The Color class is used to encapsulate colors in the default sRGB color space or colors in arbitrary
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • ArrayList (java.util)
    ArrayList is an implementation of List, backed by an array. All optional operations including adding
  • SortedSet (java.util)
    SortedSet is a Set which iterates over its elements in a sorted order. The order is determined eithe
  • Manifest (java.util.jar)
    The Manifest class is used to obtain attribute information for a JarFile and its entries.
  • BoxLayout (javax.swing)
  • Top 12 Jupyter Notebook extensions
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