Class MappingHelper

java.lang.Object
ai.pipestream.common.util.MappingHelper

public class MappingHelper extends Object
Helper class for building mapping UIs and providing field discovery. Supports frontend mappers by exposing schema information and validation.
  • Constructor Details

    • MappingHelper

      public MappingHelper()
  • Method Details

    • getAllFieldPaths

      public List<String> getAllFieldPaths(com.google.protobuf.Descriptors.Descriptor descriptor, int maxDepth)
      Gets all available field paths for a message type. Useful for populating dropdowns in a UI.
      Parameters:
      descriptor - The message descriptor
      maxDepth - Maximum nesting depth to traverse (prevents infinite recursion)
      Returns:
      List of all field paths in dot notation
    • getFieldInfos

      public List<MappingHelper.FieldInfo> getFieldInfos(com.google.protobuf.Descriptors.Descriptor descriptor, int maxDepth)
      Gets detailed information about all fields in a message. Returns metadata useful for UI rendering.
      Parameters:
      descriptor - The message descriptor
      maxDepth - Maximum nesting depth
      Returns:
      List of field information objects
    • validateRule

      public MappingHelper.ValidationResult validateRule(String rule, com.google.protobuf.Descriptors.Descriptor sourceDescriptor, com.google.protobuf.Descriptors.Descriptor targetDescriptor)
      Validates a mapping rule without executing it.
      Parameters:
      rule - The mapping rule (e.g., "target.field = source.field")
      sourceDescriptor - Source message descriptor
      targetDescriptor - Target message descriptor
      Returns:
      Validation result with any errors
    • suggestTargetFields

      public List<MappingHelper.FieldSuggestion> suggestTargetFields(String sourcePath, com.google.protobuf.Descriptors.Descriptor sourceDescriptor, com.google.protobuf.Descriptors.Descriptor targetDescriptor)
      Finds compatible target fields for a given source field. Useful for auto-suggestion in UI.
      Parameters:
      sourcePath - The source field path
      sourceDescriptor - Source message descriptor
      targetDescriptor - Target message descriptor
      Returns:
      List of compatible target field paths, sorted by compatibility score
    • exportSchema

      public MappingHelper.SchemaNode exportSchema(com.google.protobuf.Descriptors.Descriptor descriptor, int maxDepth)
      Exports a message schema as a tree structure for UI consumption.
      Parameters:
      descriptor - The message descriptor
      maxDepth - Maximum depth to export
      Returns:
      Schema tree