Interface ModelObjectProcessor

All Known Implementing Classes:
DefaultModelObjectPool

public interface ModelObjectProcessor
A pluggable service for processing model objects during model building.

This service allows implementations to:

  • Pool identical objects to reduce memory footprint
  • Intern objects for faster equality comparisons
  • Apply custom optimization strategies
  • Transform or modify objects during building

Implementations are discovered via the Java ServiceLoader mechanism and should be registered in META-INF/services/org.apache.maven.api.model.ModelObjectProcessor.

The service is called during model building for all model objects, allowing implementations to decide which objects to process and how to optimize them.

Since:
4.0.0
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> T
    process(T object)
    Process a model object, potentially returning a pooled or optimized version.
    static <T> T
    processObject(T object)
    Process a model object using the first available processor implementation.
  • Method Details

    • process

      <T> T process(T object)
      Process a model object, potentially returning a pooled or optimized version.

      This method is called during model building for various model objects. Implementations can:

      • Return the same object if no processing is desired
      • Return a pooled equivalent object to reduce memory usage
      • Return a modified or optimized version of the object

      The implementation must ensure that the returned object is functionally equivalent to the input object from the perspective of the Maven model.

      Type Parameters:
      T - the type of the model object
      Parameters:
      object - the model object to process
      Returns:
      the processed object (may be the same instance, a pooled instance, or a modified instance)
      Throws:
      IllegalArgumentException - if the object cannot be processed
    • processObject

      static <T> T processObject(T object)
      Process a model object using the first available processor implementation.

      This method discovers processor implementations via ServiceLoader and uses the first one found. If no implementations are available, the object is returned unchanged. The processor is cached for performance.

      Type Parameters:
      T - the type of the model object
      Parameters:
      object - the model object to process
      Returns:
      the processed object