An Apex annotation modifies the way that a method or class is used, similar to
annotations in Java. Annotations are defined with an initial @ symbol, followed by the appropriate keyword.
To add an annotation to a method, specify it immediately before the method or class definition. For example:
public with sharing class MyClass { @Future Public static void myMethod(String a) { //long-running Apex code } }
Apex supports these annotations.
- @AuraEnabled
- @Deprecated
- @Future
- @InvocableMethod
- @InvocableVariable
- @IsTest
- @JsonAccess
- @NamespaceAccessible
- @ReadOnly
- @RemoteAction
- @SuppressWarnings
- @TestSetup
- @TestVisible
- Apex REST annotations:
- @ReadOnly
- @RestResource (urlMapping='/yourUrl'), where yourURL is a placeholder value
- @HttpDelete
- @HttpGet
- @HttpPatch
- @HttpPost
- @HttpPut
You can use multiple annotations for the same class or method. Specify each annotation on a separate line immediately before the class or method definition. Some annotations can’t be used together. If applicable, these limitations are documented on the page for the annotation.