Interface MapDifference<K,V>
- Type Parameters:
K- key type | 键类型V- value type | 值类型
public interface MapDifference<K,V>
MapDifference - Result of comparing two maps
MapDifference - 比较两个 Map 的结果
Represents the difference between two maps, including entries only in the left, only in the right, in common, and with differing values.
表示两个 Map 之间的差异,包括仅在左边的条目、仅在右边的条目、共同的条目和值不同的条目。
Features | 主要功能:
- Entries only on left - 仅在左边的条目
- Entries only on right - 仅在右边的条目
- Entries in common - 共同的条目
- Entries with differing values - 值不同的条目
Usage Examples | 使用示例:
MapDifference<String, Integer> diff = MapUtil.difference(map1, map2);
if (!diff.areEqual()) {
Map<String, Integer> onlyLeft = diff.entriesOnlyOnLeft();
Map<String, Integer> onlyRight = diff.entriesOnlyOnRight();
Map<String, ValueDifference<Integer>> differing = diff.entriesDiffering();
}
Security | 安全性:
- Thread-safe: No - 线程安全: 否
- Null-safe: Yes - 空值安全: 是
- Since:
- JDK 25, opencode-base-collections V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceValueDifference - Represents different values for the same key ValueDifference - 表示相同键的不同值 -
Method Summary
Modifier and TypeMethodDescriptionbooleanareEqual()Check if the two maps are equal 是否相等Get entries where keys are the same but values differ 值不同的条目Get entries common to both maps (same key and value) 共同的条目Get entries only in the left map 仅在左边的条目Get entries only in the right map 仅在右边的条目
-
Method Details
-
areEqual
boolean areEqual()Check if the two maps are equal 是否相等- Returns:
- true if equal | 如果相等则返回 true
-
entriesOnlyOnLeft
-
entriesOnlyOnRight
-
entriesInCommon
-
entriesDiffering
Map<K, MapDifference.ValueDifference<V>> entriesDiffering()Get entries where keys are the same but values differ 值不同的条目- Returns:
- differing entries | 值不同的条目
-