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

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

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

origin: org.codehaus.groovy/groovy

/**
 * Returns true if the specified class node is annotated with the {@link Trait} interface.
 * @param cNode a class node
 * @return true if the specified class node is annotated with the {@link Trait} interface.
 */
public static boolean isAnnotatedWithTrait(final ClassNode cNode) {
  List<AnnotationNode> traitAnn = cNode.getAnnotations(Traits.TRAIT_CLASSNODE);
  return traitAnn != null && !traitAnn.isEmpty();
}
origin: org.codehaus.groovy/groovy

private static boolean notTransform(ClassNode annotationClassNode) {
  return annotationClassNode.getAnnotations(ASTTRANSFORMCLASS_TYPE).isEmpty();
}
origin: org.codehaus.groovy/groovy

static boolean makeImmutable(ClassNode cNode) {
  List<AnnotationNode> annotations = cNode.getAnnotations(ImmutablePropertyUtils.IMMUTABLE_OPTIONS_TYPE);
  AnnotationNode annoImmutable = annotations.isEmpty() ? null : annotations.get(0);
  return annoImmutable != null;
}
origin: org.codehaus.groovy/groovy

@Override
public List<AnnotationNode> getAnnotations() {
  List<AnnotationNode> nodes = new LinkedList<AnnotationNode>();
  for (ClassNode delegate : delegates) {
    List<AnnotationNode> annotations = delegate.getAnnotations();
    if (annotations != null) nodes.addAll(annotations);
  }
  return nodes;
}
origin: org.codehaus.groovy/groovy

@Override
public List<AnnotationNode> getAnnotations(final ClassNode type) {
  List<AnnotationNode> nodes = new LinkedList<AnnotationNode>();
  for (ClassNode delegate : delegates) {
    List<AnnotationNode> annotations = delegate.getAnnotations(type);
    if (annotations != null) nodes.addAll(annotations);
  }
  return nodes;
}
origin: org.codehaus.groovy/groovy

@Override
public List<AnnotationNode> getAnnotations() {
  lazyInitSupers();
  return super.getAnnotations();
}
origin: org.codehaus.groovy/groovy

@Override
public List<AnnotationNode> getAnnotations(ClassNode type) {
  lazyInitSupers();
  return super.getAnnotations(type);
}
origin: org.codehaus.groovy/groovy

private static boolean isCloneableType(ClassNode fieldType) {
  return isOrImplements(fieldType, CLONEABLE_TYPE) || !fieldType.getAnnotations(MY_TYPE).isEmpty();
}
origin: org.codehaus.groovy/groovy

public List<AnnotationNode> getAnnotations(ClassNode type) {
  if (redirect!=null) return redirect.getAnnotations(type);
  lazyClassInit();
  return super.getAnnotations(type);
}
origin: org.codehaus.groovy/groovy

public List<AnnotationNode> getAnnotations() {
  if (redirect!=null) return redirect.getAnnotations();
  lazyClassInit();
  return super.getAnnotations();
}
origin: org.codehaus.groovy/groovy

private static List<AnnotationNode> getTargetListFromAnnotations(ClassNode alias) {
  List<AnnotationNode> annotations = alias.getAnnotations();
  if (annotations.size() < 2) {
    return Collections.emptyList();
  }
  List<AnnotationNode> ret = new ArrayList<AnnotationNode>(annotations.size());
  for (AnnotationNode an : annotations) {
    ClassNode type = an.getClassNode();
    if (type.getName().equals(AnnotationCollector.class.getName()) || "java.lang.annotation".equals(type.getPackageName())) continue;
    AnnotationNode toAdd = new AnnotationNode(type);
    copyMembers(an, toAdd);
    ret.add(toAdd);
  }
  return ret;
}
origin: org.codehaus.groovy/groovy

private static ClassNode getSerializeClass(ClassNode alias) {
  List<AnnotationNode> annotations = alias.getAnnotations(ClassHelper.make(AnnotationCollector.class));
  if (!annotations.isEmpty()) {
    AnnotationNode annotationNode = annotations.get(0);
    Expression member = annotationNode.getMember("serializeClass");
    if (member instanceof ClassExpression) {
      ClassExpression ce = (ClassExpression) member;
      if (!ce.getType().getName().equals(AnnotationCollector.class.getName())) {
        alias = ce.getType();
      }
    }
  }
  return alias;
}
origin: org.codehaus.groovy/groovy

private static boolean hasImmutableAnnotation(ClassNode type) {
  List<AnnotationNode> annotations = type.getAnnotations();
  for (AnnotationNode next : annotations) {
    String name = next.getClassNode().getName();
    if (matchingMarkerName(name)) return true;
  }
  return false;
}
origin: org.codehaus.groovy/groovy

private void lazyInit() {
  if (lazyInitDone) return;
  synchronized (initLock) {
    if (!lazyInitDone) {
      for (AnnotationNode annotation : getClassNode().getAnnotations()) {
        VMPluginFactory.getPlugin().configureAnnotationNodeFromDefinition(annotation, this);
      }
      lazyInitDone = true;
    }
  }
}
origin: org.codehaus.groovy/groovy

  public static List<String> getKnownImmutableClasses(AbstractASTTransformation xform, ClassNode cNode) {
    List<AnnotationNode> annotations = cNode.getAnnotations(ImmutablePropertyUtils.IMMUTABLE_OPTIONS_TYPE);
    AnnotationNode anno = annotations.isEmpty() ? null : annotations.get(0);
    final List<String> immutableClasses = new ArrayList<String>();

    if (anno == null) return immutableClasses;
    final Expression expression = anno.getMember(MEMBER_KNOWN_IMMUTABLE_CLASSES);
    if (expression == null) return immutableClasses;

    if (!(expression instanceof ListExpression)) {
      xform.addError("Use the Groovy list notation [el1, el2] to specify known immutable classes via \"" + MEMBER_KNOWN_IMMUTABLE_CLASSES + "\"", anno);
      return immutableClasses;
    }

    final ListExpression listExpression = (ListExpression) expression;
    for (Expression listItemExpression : listExpression.getExpressions()) {
      if (listItemExpression instanceof ClassExpression) {
        immutableClasses.add(listItemExpression.getType().getName());
      }
    }

    return immutableClasses;
  }
}
origin: org.codehaus.groovy/groovy

/**
 * Copies annotation from the trait to the helper, excluding the trait annotation itself
 * @param cNode the trait class node
 * @param helper the helper class node
 */
private static void copyClassAnnotations(final ClassNode cNode, final ClassNode helper) {
  List<AnnotationNode> annotations = cNode.getAnnotations();
  for (AnnotationNode annotation : annotations) {
    if (!annotation.getClassNode().equals(Traits.TRAIT_CLASSNODE)) {
      helper.addAnnotation(annotation);
    }
  }
}
origin: org.codehaus.groovy/groovy

public static List<String> getKnownImmutables(AbstractASTTransformation xform, ClassNode cNode) {
  List<AnnotationNode> annotations = cNode.getAnnotations(ImmutablePropertyUtils.IMMUTABLE_OPTIONS_TYPE);
  AnnotationNode anno = annotations.isEmpty() ? null : annotations.get(0);
  final List<String> immutables = new ArrayList<String>();
  if (anno == null) return immutables;
  final Expression expression = anno.getMember(MEMBER_KNOWN_IMMUTABLES);
  if (expression == null) return immutables;
  if (!(expression instanceof ListExpression)) {
    xform.addError("Use the Groovy list notation [el1, el2] to specify known immutable property names via \"" + MEMBER_KNOWN_IMMUTABLES + "\"", anno);
    return immutables;
  }
  final ListExpression listExpression = (ListExpression) expression;
  for (Expression listItemExpression : listExpression.getExpressions()) {
    if (listItemExpression instanceof ConstantExpression) {
      immutables.add((String) ((ConstantExpression) listItemExpression).getValue());
    }
  }
  if (!xform.checkPropertyList(cNode, immutables, "knownImmutables", anno, "immutable class", false)) return immutables;
  return immutables;
}
origin: org.codehaus.groovy/groovy

public void configureAnnotation(AnnotationNode node) {
  ClassNode type = node.getClassNode();
  VMPlugin plugin = VMPluginFactory.getPlugin();
  List<AnnotationNode> annotations = type.getAnnotations();
  for (AnnotationNode an : annotations) {
    plugin.configureAnnotationNodeFromDefinition(an, node);
  }
  plugin.configureAnnotationNodeFromDefinition(node, node);
}
origin: org.codehaus.groovy/groovy

public static PropertyHandler createPropertyHandler(AbstractASTTransformation xform, GroovyClassLoader loader, ClassNode cNode) {
  List<AnnotationNode> annotations = cNode.getAnnotations(PROPERTY_OPTIONS_TYPE);
  AnnotationNode anno = annotations.isEmpty() ? null : annotations.get(0);
  if (anno == null) return new groovy.transform.options.DefaultPropertyHandler();
origin: org.codehaus.groovy/groovy

private void processClass(ClassNode cNode, AnnotationNode node) {
  if (cNode.isInterface()) {
    addError("Error processing interface '" + cNode.getName() +
        "'. " + MY_TYPE_NAME + " only allowed for classes.", cNode);
    return;
  }
  boolean copyConstructorAnnotations = memberHasValue(node, "constructorAnnotations", true);
  boolean copyParameterAnnotations = memberHasValue(node, "parameterAnnotations", true);
  ClassNode sNode = cNode.getSuperClass();
  List<AnnotationNode> superAnnotations = sNode.getAnnotations(MY_TYPE);
  if (superAnnotations.size() == 1) {
    // We need @InheritConstructors from parent classes processed first
    // so force that order here. The transformation is benign on an already
    // processed node so processing twice in any order won't matter bar
    // a very small time penalty.
    processClass(sNode, node);
  }
  for (ConstructorNode cn : sNode.getDeclaredConstructors()) {
    addConstructorUnlessAlreadyExisting(cNode, cn, copyConstructorAnnotations, copyParameterAnnotations);
  }
}
org.codehaus.groovy.astClassNodegetAnnotations

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
  • 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.
  • isInterface
  • getMethod,
  • isInterface,
  • getNameWithoutPackage,
  • isScript,
  • getDeclaredMethod,
  • getGenericsTypes,
  • getDeclaredConstructors,
  • getModifiers,
  • getTypeClass

Popular in Java

  • Reading from database using SQL prepared statement
  • getResourceAsStream (ClassLoader)
  • getSupportFragmentManager (FragmentActivity)
  • setContentView (Activity)
  • Color (java.awt)
    The Color class is used to encapsulate colors in the default sRGB color space or colors in arbitrary
  • RandomAccessFile (java.io)
    Allows reading from and writing to a file in a random-access manner. This is different from the uni-
  • URL (java.net)
    A Uniform Resource Locator that identifies the location of an Internet resource as specified by RFC
  • StringTokenizer (java.util)
    Breaks a string into tokens; new code should probably use String#split.> // Legacy code: StringTo
  • TreeMap (java.util)
    Walk the nodes of the tree left-to-right or right-to-left. Note that in descending iterations, next
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • 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