painless-operators.asciidoc 8.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. [[painless-operators]]
  2. === Operators
  3. An operator is the most basic action that can be taken to evaluate values in a
  4. script. An expression is one-to-many consecutive operations. Precedence is the
  5. order in which an operator will be evaluated relative to another operator.
  6. Associativity is the direction within an expression in which a specific operator
  7. is evaluated. The following table lists all available operators:
  8. [cols="<6,<3,^3,^2,^4"]
  9. |====
  10. | *Operator* | *Category* | *Symbol(s)* | *Precedence* | *Associativity*
  11. | <<precedence-operator, Precedence>> | <<painless-operators-general, General>> | () | 0 | left -> right
  12. | <<method-call-operator, Method Call>> | <<painless-operators-reference, Reference>> | . () | 1 | left -> right
  13. | <<field-access-operator, Field Access>> | <<painless-operators-reference, Reference>> | . | 1 | left -> right
  14. | <<null-safe-operator, Null Safe>> | <<painless-operators-reference, Reference>> | ?. | 1 | left -> right
  15. | <<function-call-operator, Function Call>> | <<painless-operators-general, General>> | () | 1 | left -> right
  16. | <<array-initialization-operator, Array Initialization>> | <<painless-operators-array, Array>> | [] {} | 1 | left -> right
  17. | <<array-access-operator, Array Access>> | <<painless-operators-array, Array>> | [] | 1 | left -> right
  18. | <<array-length-operator, Array Length>> | <<painless-operators-array, Array>> | . | 1 | left -> right
  19. | <<list-initialization-operator, List Initialization>> | <<painless-operators-reference, Reference>> | [] | 1 | left -> right
  20. | <<list-access-operator, List Access>> | <<painless-operators-reference, Reference>> | [] | 1 | left -> right
  21. | <<map-initialization-operator, Map Initialization>> | <<painless-operators-reference, Reference>> | [:] | 1 | left -> right
  22. | <<map-access-operator, Map Access>> | <<painless-operators-reference, Reference>> | [] | 1 | left -> right
  23. | <<post-increment-operator, Post Increment>> | <<painless-operators-numeric, Numeric>> | ++ | 1 | left -> right
  24. | <<post-decrement-operator, Post Decrement>> | <<painless-operators-numeric, Numeric>> | -- | 1 | left -> right
  25. | <<pre-increment-operator, Pre Increment>> | <<painless-operators-numeric, Numeric>> | ++ | 2 | right -> left
  26. | <<pre-decrement-operator, Pre Decrement>> | <<painless-operators-numeric, Numeric>> | -- | 2 | right -> left
  27. | <<unary-positive-operator, Unary Positive>> | <<painless-operators-numeric, Numeric>> | + | 2 | right -> left
  28. | <<unary-negative-operator, Unary Negative>> | <<painless-operators-numeric, Numeric>> | - | 2 | right -> left
  29. | <<boolean-not-operator, Boolean Not>> | <<painless-operators-boolean, Boolean>> | ! | 2 | right -> left
  30. | <<bitwise-not-operator, Bitwise Not>> | <<painless-operators-numeric, Numeric>> | ~ | 2 | right -> left
  31. | <<cast-operator, Cast>> | <<painless-operators-general, General>> | () | 3 | right -> left
  32. | <<new-instance-operator, New Instance>> | <<painless-operators-reference, Reference>> | new () | 3 | right -> left
  33. | <<new-array-operator, New Array>> | <<painless-operators-array, Array>> | new [] | 3 | right -> left
  34. | <<multiplication-operator, Multiplication>> | <<painless-operators-numeric, Numeric>> | * | 4 | left -> right
  35. | <<division-operator, Division>> | <<painless-operators-numeric, Numeric>> | / | 4 | left -> right
  36. | <<remainder-operator, Remainder>> | <<painless-operators-numeric, Numeric>> | % | 4 | left -> right
  37. | <<string-concatenation-operator, String Concatenation>> | <<painless-operators-reference, Reference>> | + | 5 | left -> right
  38. | <<addition-operator, Addition>> | <<painless-operators-numeric, Numeric>> | + | 5 | left -> right
  39. | <<subtraction-operator, Subtraction>> | <<painless-operators-numeric, Numeric>> | - | 5 | left -> right
  40. | <<left-shift-operator, Left Shift>> | <<painless-operators-numeric, Numeric>> | << | 6 | left -> right
  41. | <<right-shift-operator, Right Shift>> | <<painless-operators-numeric, Numeric>> | >> | 6 | left -> right
  42. | <<unsigned-right-shift-operator, Unsigned Right Shift>> | <<painless-operators-numeric, Numeric>> | >>> | 6 | left -> right
  43. | <<greater-than-operator, Greater Than>> | <<painless-operators-boolean, Boolean>> | > | 7 | left -> right
  44. | <<greater-than-or-equal-operator, Greater Than Or Equal>> | <<painless-operators-boolean, Boolean>> | >= | 7 | left -> right
  45. | <<less-than-operator, Less Than>> | <<painless-operators-boolean, Boolean>> | < | 7 | left -> right
  46. | <<less-than-or-equal-operator, Less Than Or Equal>> | <<painless-operators-boolean, Boolean>> | <= | 7 | left -> right
  47. | <<instanceof-operator, Instanceof>> | <<painless-operators-boolean, Boolean>> | instanceof | 8 | left -> right
  48. | <<equality-equals-operator, Equality Equals>> | <<painless-operators-boolean, Boolean>> | == | 9 | left -> right
  49. | <<equality-not-equals-operator, Equality Not Equals>> | <<painless-operators-boolean, Boolean>> | != | 9 | left -> right
  50. | <<identity-equals-operator, Identity Equals>> | <<painless-operators-boolean, Boolean>> | === | 9 | left -> right
  51. | <<identity-not-equals-operator, Identity Not Equals>> | <<painless-operators-boolean, Boolean>> | !== | 9 | left -> right
  52. | <<bitwise-and-operator, Bitwise And>> | <<painless-operators-numeric, Numeric>> | & | 10 | left -> right
  53. | <<boolean-xor-operator, Boolean Xor>> | <<painless-operators-boolean, Boolean>> | ^ | 11 | left -> right
  54. | <<bitwise-xor-operator, Bitwise Xor>> | <<painless-operators-numeric, Numeric>> | ^ | 11 | left -> right
  55. | <<bitwise-or-operator, Bitwise Or>> | <<painless-operators-numeric, Numeric>> | \| | 12 | left -> right
  56. | <<boolean-and-operator, Boolean And>> | <<painless-operators-boolean, Boolean>> | && | 13 | left -> right
  57. | <<boolean-or-operator, Boolean Or>> | <<painless-operators-boolean, Boolean>> | \|\| | 14 | left -> right
  58. | <<conditional-operator, Conditional>> | <<painless-operators-general, General>> | ? : | 15 | right -> left
  59. | <<elvis-operator, Elvis>> | <<painless-operators-general, General>> | ?: | 16 | right -> left
  60. | <<assignment-operator, Assignment>> | <<painless-operators-general, General>> | = | 17 | right -> left
  61. | <<compound-assignment-operator, Compound Assignment>> | <<painless-operators-general, General>> | $= | 17 | right -> left
  62. |====