All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sourceforge.pmd.lang.apex.ast.ASTAnnotation Maven / Gradle / Ivy

There is a newer version: 7.5.0
Show newest version
/*
 * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
 */

package net.sourceforge.pmd.lang.apex.ast;

import java.util.NavigableSet;

import com.google.common.collect.ImmutableSortedSet;
import com.google.summit.ast.modifier.AnnotationModifier;

public final class ASTAnnotation extends AbstractApexNode.Single {

    /**
     * Valid annotations in the Apex language.
     *
     * 

Includes all annotations from the official * documentation, plus *

    *
  • {@code AllowCertifiedApex}
  • *
  • {@code HiddenFromDoc}
  • *
  • {@code NamespaceGuard}
  • *
  • {@code PermGuard}
  • *
  • {@code PrivateApi}
  • *
  • {@code SfdcOnly}
  • *
  • {@code UseConnectDeserializer}
  • *
  • {@code UseConnectSerializer}
  • *
  • {@code VisibleApiVersion}
  • *
* for backward compatibility. */ private static final NavigableSet NORMALIZED_ANNOTATION_NAMES = ImmutableSortedSet.orderedBy(String.CASE_INSENSITIVE_ORDER).add( "AllowCertifiedApex", "AuraEnabled", "Deprecated", "Future", "HiddenFromDoc", "HttpDelete", "HttpGet", "HttpPatch", "HttpPost", "HttpPut", "InvocableMethod", "InvocableVariable", "IsTest", "JsonAccess", "NamespaceAccessible", "NamespaceGuard", "PermGuard", "PrivateApi", "ReadOnly", "RemoteAction", "RestResource", "SfdcOnly", "SuppressWarnings", "TestSetup", "TestVisible", "UseConnectDeserializer", "UseConnectSerializer", "VisibleApiVersion" ).build(); ASTAnnotation(AnnotationModifier annotationModifier) { super(annotationModifier); } @Override protected R acceptApexVisitor(ApexVisitor visitor, P data) { return visitor.visit(this, data); } /** * Returns the normalized annotation name for known, valid annotations. * The normalized name is in PascalCase. If an unknown annotation is used, * the raw name (as in the source code) is returned. * * @see #getRawName() */ public String getName() { // If resolvable to a known name, return the case-normalized name. String rawName = getRawName(); if (NORMALIZED_ANNOTATION_NAMES.contains(rawName)) { return NORMALIZED_ANNOTATION_NAMES.floor(rawName); } return rawName; } /** * Returns the annotation name as it appears in the source code. * This allows to verify the casing. * * @since 7.1.0 */ public String getRawName() { return node.getName().getString(); } @Override public String getImage() { return getName(); } public boolean isResolved() { return NORMALIZED_ANNOTATION_NAMES.contains(getRawName()); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy