Interface AccessorNamingStrategy

All Known Implementing Classes:
DefaultAccessorNamingStrategy, FreeBuilderAccessorNamingStrategy, ImmutablesAccessorNamingStrategy

public interface AccessorNamingStrategy
A service provider interface for the mapping between method names and properties.
Author:
Christian Schuster, Gunnar Morling
  • Method Details

    • init

      default void init(MapStructProcessingEnvironment processingEnvironment)
      Initializes the accessor naming strategy with the MapStruct processing environment.
      Parameters:
      processingEnvironment - environment for facilities
      Since:
      1.3
    • getMethodType

      MethodType getMethodType(ExecutableElement method)
      Returns the type of the given method.
      Parameters:
      method - to be analyzed.
      Returns:
      the method type.
    • getPropertyName

      String getPropertyName(ExecutableElement getterOrSetterMethod)
      Returns the name of the property represented by the given getter or setter method.

      The default implementation will e.g. return "name" for public String getName() or public void setName(String name).

      Parameters:
      getterOrSetterMethod - to be analyzed.
      Returns:
      property name derived from the getterOrSetterMethod
    • getElementName

      String getElementName(ExecutableElement adderMethod)
      Returns the element name of the given adder method.

      The default implementation will e.g. return "item" for public void addItem(String item).

      Parameters:
      adderMethod - to be getterOrSetterMethod.
      Returns:
      getter name for collections
    • getCollectionGetterName

      @Deprecated String getCollectionGetterName(String property)
      Deprecated.
      MapStruct will not call this method anymore. Use getMethodType(ExecutableElement) to determine the MethodType. When collections somehow need to be treated special, it should be done in getMethodType(ExecutableElement) as well. In the future, this method will be removed.
      Returns the getter name of the given collection property.

      The default implementation will e.g. return "getItems" for "items".

      Parameters:
      property - to be getterOrSetterMethod.
      Returns:
      getter name for collection properties