Package ai.pipestream.common.util
Class MappingHelper
java.lang.Object
ai.pipestream.common.util.MappingHelper
Helper class for building mapping UIs and providing field discovery.
Supports frontend mappers by exposing schema information and validation.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic classstatic class -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionexportSchema(com.google.protobuf.Descriptors.Descriptor descriptor, int maxDepth) Exports a message schema as a tree structure for UI consumption.getAllFieldPaths(com.google.protobuf.Descriptors.Descriptor descriptor, int maxDepth) Gets all available field paths for a message type.getFieldInfos(com.google.protobuf.Descriptors.Descriptor descriptor, int maxDepth) Gets detailed information about all fields in a message.suggestTargetFields(String sourcePath, com.google.protobuf.Descriptors.Descriptor sourceDescriptor, com.google.protobuf.Descriptors.Descriptor targetDescriptor) Finds compatible target fields for a given source field.validateRule(String rule, com.google.protobuf.Descriptors.Descriptor sourceDescriptor, com.google.protobuf.Descriptors.Descriptor targetDescriptor) Validates a mapping rule without executing it.
-
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 descriptormaxDepth- 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 descriptormaxDepth- 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 descriptortargetDescriptor- 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 pathsourceDescriptor- Source message descriptortargetDescriptor- 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 descriptormaxDepth- Maximum depth to export- Returns:
- Schema tree
-