• Intro Headers Instructions Macros Commands
Fork me on GitHub
    • Getting Started
      • Introduction
      • How to install bnd
      • Guided Tour Workspace & Projects
      • bnd / bndlib Features and JAR Wrapping Techniques
      • FAQ - Frequently Asked Questions
    • Concepts and Practices
      • Concepts
      • Background
      • Best practices
    • Build and Development
      • Build
      • Generating JARs
      • Versioning
      • Baselining
      • Service Components
      • Metatype
      • Contracts
      • Bundle Annotations
      • Accessor Properties
      • SPI Annotations
    • Dependency and Launching
      • Resolving Dependencies
      • Launching
      • Startlevels
    • Testing
      • Testing
      • Testing with Launchpad
    • Packaging and Distribution
      • Packaging Applications
      • JPMS Libraries
      • Wrapping Libraries to OSGi Bundles
    • Documentation and Tools
      • Generating Documentation
      • bnd CLI Commands
      • For Developers
      • Templates for Workspaces
      • Tips for Windows users
      • Tools bound to bnd
    • Reference Material
      • Reference
      • Headers
      • Instruction Reference
      • Instruction Index
      • Macro Reference
      • Macro Index
      • Plugins
      • External Plugins
    • Configuration and Troubleshooting
      • Settings
      • Errors
      • Warnings
  • map ';' MACRO (';' LIST)*

    Prev Next
    Macro
    Transform each element of a list using a macro function

    Summary

    The map macro applies a transformation function (specified as a macro name) to each element of one or more lists, collecting the results into a new comma-separated list. This is similar to the functional programming map operation.

    Syntax

    ${map;<macro-name>[;<list>...]}
    

    Parameters

    • macro-name - Name of a macro to invoke for each element (without the ${} wrapper)
    • list - One or more semicolon-separated lists to process

    Behavior

    • Combines all provided lists into a single list
    • For each element, invokes: ${<macro-name>;<element>}
    • Collects all transformation results
    • Returns results as a comma-separated string

    Examples

    Transform list elements:

    # Define transformation macro
    upper;${toupper;$1}
    
    # Map to uppercase
    ${map;upper;apple,banana,cherry}
    

    Add prefix to each element:

    # Define prefix macro
    add-prefix;modified-$1
    
    ${map;add-prefix;file1,file2,file3}
    # Returns: "modified-file1,modified-file2,modified-file3"
    

    Process file list:

    # Define file processor
    process;${basename;$1}
    
    ${map;process;/path/to/file1.jar;/path/to/file2.jar}
    # Returns basenames of files
    

    Calculate transformations:

    # Define calculation macro
    double;${multiply;$1;2}
    
    ${map;double;1,2,3,4,5}
    # Returns: "2,4,6,8,10"
    

    Use Cases

    • Transforming lists with complex logic
    • Applying consistent transformations to all elements
    • Building derived lists from source data
    • Functional-style list processing
    • Batch operations on list elements
    • Data transformation pipelines

    Notes

    • The invoked macro receives one argument: the element value
    • Unlike ${foreach}, no index is passed to the macro
    • The macro must be defined before use (either as a property or built-in)
    • Results are joined with commas
    • Empty lists produce empty results
    • See also: ${foreach} for transformations that need the element index
    • See also: ${apply} for passing entire lists to a macro

    See test cases in MacroTestsForDocsExamples.java

Prev Next
Search
    • Home