java.lang.Object
org.springframework.expression.spel.ast.SpelNodeImpl
org.springframework.expression.spel.ast.Indexer
All Implemented Interfaces:
Opcodes, SpelNode

public class Indexer extends SpelNodeImpl
An Indexer can index into some proceeding structure to access a particular element of the structure.

Numerical index values are zero-based, such as when accessing the nth element of an array in Java.

Supported Structures

  • Arrays: the nth element
  • Collections (lists, sets, etc.): the nth element
  • Strings: the nth character as a String
  • Maps: the value for the specified key
  • Objects: the property with the specified name
  • Custom Structures: via registered IndexAccessor implementations

Null-safe Indexing

As of Spring Framework 6.2, null-safe indexing is supported via the '?.' operator. For example, 'colors?.[0]' will evaluate to null if colors is null and will otherwise evaluate to the 0th color.

Since:
3.0
Author:
Andy Clement, Phillip Webb, Stephane Nicoll, Sam Brannen
See Also: