Interface MappingSetMerger
-
- All Known Implementing Classes:
MappingSetMergerImpl
public interface MappingSetMergerA service for merging mappings. The result of a mapping merge is a new mapping which contains the result you would expect to get after using the two mappings being merged in order, left, then right.
Put another way, merging 2 mappings means the deobfuscated output of the left
MappingSetand the obfuscated input of the rightMappingSetmatch, creating a singleMappingSetwith the obfuscated input of the left side and the deobfuscated output of the right side.More complex situations are likely to occur while merging mappings, so this table will go through the different possible cases and how a mapping set merger handles them in the default implementation:
Merge Situations Left Right Output Note A -> BB -> CA -> CTypical case, easiest to handle A -> BMissing A -> BStandalone mappings get copied Missing B -> CB -> CStandalone mappings get copied A -> BX -> YA -> BX -> YThis is no different than the 2 above cases with missing mappings on each side. This is just meant to be a further example that if two unrelated mappings are present, a standard merger won't know how to handle them other than copying both. A -> BA -> CA -> CBy default the right mapping is considered the "most up to date" mappings, so in the case where both mapping sets provide mappings for the same obfuscated name, the right mapping is used in the default implementation. A -> B
(types and names)B -> B(types)A -> C(names)A -> B(types)A -> C(names)This is an example of a special case situation where the left mapping only maps types, then the second mapping set only maps members, but from the expectation that the first mapping set was already applied. The default implementation should handle this case correctly. All of these cases can happen in a single mapping merge. That is to say, some cases may apply to some classes and methods but not others, but all during a single merge. It's important to note that it's illegal to merge a
nullmapping set with another set, both must exist. The Missing cases in the table refer to situations where one mapping set contains entries the other doesn't.- Since:
- 0.5.4
- See Also:
MappingSetMergerHandler- API Note:
- This class was added after the
MappingSet.merge(org.cadixdev.lorenz.MappingSet)and related methods were implemented. The merge methods are equivalent to this class, as they only call back to the default implementation of this class. - Implementation Note:
- The default implementation of this interface uses a
MappingSetMergerHandlerto handle each specific merging situation. To modify specific instances of merging behavior, it may be simpler to override that class instead and only modify the specific type of merge you want to change.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static MappingSetMergercreate(MappingSet left, MappingSet right)Creates a mapping set merger, using the default merger implementation with the defaultMappingSetMergerHandlerimplementation.static MappingSetMergercreate(MappingSet left, MappingSet right, MergeConfig config)Creates a mapping set merger, using the default merger implementation with the providedMappingSetMergerHandlerimplementation.default MappingSetmerge()Merge the twoMappingSets in this merger together, returning the result.MappingSetmerge(MappingSet target)Merge the twoMappingSets in this merger together into the providedtarget.FieldMappingmergeField(FieldMapping left, FieldMapping right, ClassMapping<?,?> target)Merge the two providedFieldMappings together into the providedtarget.InnerClassMappingmergeInnerClass(InnerClassMapping left, InnerClassMapping right, ClassMapping<?,?> target)Merge the members of the two providedInnerClassMappings together into the providedtarget.MethodMappingmergeMethod(MethodMapping left, MethodMapping right, ClassMapping<?,?> target)Merge the two providedMethodMappings together into the providedtarget.MethodParameterMappingmergeMethodParameter(MethodParameterMapping left, MethodParameterMapping right, MethodMapping target)Merge the two providedMethodParameterMappings together into the providedtarget.TopLevelClassMappingmergeTopLevelClass(TopLevelClassMapping left, TopLevelClassMapping right, MappingSet target)Merge the members of the two providedTopLevelClassMappings together into the providedtarget.
-
-
-
Method Detail
-
create
static MappingSetMerger create(MappingSet left, MappingSet right)
Creates a mapping set merger, using the default merger implementation with the defaultMappingSetMergerHandlerimplementation.- Parameters:
left- TheMappingSetfor the left side of the mergeright- TheMappingSetfor the right side of the merge- Returns:
- The merger
- See Also:
create(MappingSet, MappingSet, MergeConfig)
-
create
static MappingSetMerger create(MappingSet left, MappingSet right, MergeConfig config)
Creates a mapping set merger, using the default merger implementation with the providedMappingSetMergerHandlerimplementation.- Parameters:
left- TheMappingSetfor the left side of the mergeright- TheMappingSetfor the right side of the mergeconfig- TheMergeConfigconfiguration for this merge session- Returns:
- The merger
- See Also:
create(MappingSet, MappingSet)
-
merge
default MappingSet merge()
Merge the twoMappingSets in this merger together, returning the result. This is effectively the same as callingmerge(MappingSet)with a new mapping set and returning it.- Returns:
- The merged mapping set
- See Also:
merge(MappingSet)
-
merge
MappingSet merge(MappingSet target)
Merge the twoMappingSets in this merger together into the providedtarget. For ease of use the providedtargetmapping set is also returned.- Parameters:
target- The mapping set to insert the merged mappings into- Returns:
- The
targetparameter. - Implementation Requirements:
- The return value of this method should always be the same object provided in the
targetparameter. The result shouldn't be a copy.
-
mergeTopLevelClass
TopLevelClassMapping mergeTopLevelClass(TopLevelClassMapping left, TopLevelClassMapping right, MappingSet target)
Merge the members of the two providedTopLevelClassMappings together into the providedtarget.- Parameters:
left- The class mapping for the left side of the merge. May benull.right- The class mapping for the right side of the merge. May benull.target- The mapping set to insert the new merged mapping into. May not benull.- Returns:
- The new class mapping, or
nullif the mapping is to be removed. - Implementation Note:
- This method is used by the
merge(MappingSet)method in the default implementation, but can also be used to map a single class if called directly. If you are overriding the default implementation to change behavior, first make sure what you're trying to do can't be accomplished by overriding theMappingSetMergerHandlerinstead.
-
mergeInnerClass
InnerClassMapping mergeInnerClass(InnerClassMapping left, InnerClassMapping right, ClassMapping<?,?> target)
Merge the members of the two providedInnerClassMappings together into the providedtarget.- Parameters:
left- The class mapping for the left side of the merge. May benull.right- The class mapping for the right side of the merge. May benull.target- The class mapping to insert the new merged mapping into. May not benull.- Returns:
- The new class mapping, or
nullif the mapping is to be removed. - Implementation Note:
- This method is used by the
mergeTopLevelClass()method in the default implementation, but can also be used to map a single inner class if called directly. If you are overriding the default implementation to change behavior, first make sure what you're trying to do can't be accomplished by overriding theMappingSetMergerHandlerinstead.
-
mergeField
FieldMapping mergeField(FieldMapping left, FieldMapping right, ClassMapping<?,?> target)
Merge the two providedFieldMappings together into the providedtarget.- Parameters:
left- The field mapping for the left side of the merge. May benull.right- The field mapping for the right side of the merge. May benull.target- The class mapping to insert the new merged mapping into. May not benull.- Returns:
- The new field mapping, or
nullif the mapping is to be removed. - Implementation Note:
- This method is used by the
mergeTopLeveClass()andmergeInnerClass()methods in the default implementation, but can also be used to map a single field if called directly. If you are overriding the default implementation to change behavior, first make sure what you're trying to do can't be accomplished by overriding theMappingSetMergerHandlerinstead.
-
mergeMethod
MethodMapping mergeMethod(MethodMapping left, MethodMapping right, ClassMapping<?,?> target)
Merge the two providedMethodMappings together into the providedtarget.- Parameters:
left- The method mapping for the left side of the merge. May benull.right- The method mapping for the right side of the merge. May benull.target- The class mapping to insert the new merged mapping into. May not benull.- Returns:
- The new method mapping, or
nullif the mapping is to be removed. - Implementation Note:
- This method is used by the
mergeTopLeveClass()andmergeInnerClass()methods in the default implementation, but can also be used to map a single method if called directly. If you are overriding the default implementation to change behavior, first make sure what you're trying to do can't be accomplished by overriding theMappingSetMergerHandlerinstead.
-
mergeMethodParameter
MethodParameterMapping mergeMethodParameter(MethodParameterMapping left, MethodParameterMapping right, MethodMapping target)
Merge the two providedMethodParameterMappings together into the providedtarget.- Parameters:
left- The method parameter mapping for the left side of the merge. May benull.right- The method parameter mapping for the right side of the merge. May benull.target- The method mapping to insert the new merged mapping into. May not benull.- Returns:
- The new method parameter mapping, or
nullif the mapping is to be removed. - Implementation Note:
- This method is used by the
mergeMethod()method in the default implementation, but can also be used to map a single method parameter if called directly. If you are overriding the default implementation to change behavior, first make sure what you're trying to do can't be accomplished by overriding theMappingSetMergerHandlerinstead.
-
-