public class MessageDiff extends Object
The comparison checks message version, message type, field values and repeating groups.
Use isSimilar() for a strict comparison, where repeating group instances must be
in the same order, or isLogicallySimilar() when repeating group instance order
should be ignored.
The comparison can be customized with a MessageDiffListener to ignore selected
tag/value differences.
| Modifier and Type | Field and Description |
|---|---|
static String |
NO_DIFF
Returned when two messages are equal according to the strict comparison.
|
static String |
NO_DIFF_LOGICALLY
Returned when two messages are equal according to the logical comparison.
|
static String |
UNKNOWN_ERROR
Fallback description used when the comparison cannot classify the difference more precisely.
|
| Constructor and Description |
|---|
MessageDiff(Message message1,
Message message2)
Creates a diff helper for the supplied messages.
|
| Modifier and Type | Method and Description |
|---|---|
MessageDiffListener |
getDiffListener()
Returns the listener used to ignore selected differences.
|
boolean |
isLogicallySimilar()
Compares the messages using the logical comparison mode.
|
static boolean |
isLogicallySimilar(Message message1,
Message message2)
Compares the messages using the logical comparison mode.
|
boolean |
isSimilar()
Compares the messages using the strict comparison mode.
|
static boolean |
isSimilar(Message message1,
Message message2)
Compares the messages using the strict comparison mode.
|
void |
setDiffListener(MessageDiffListener diffListener)
Sets the listener used to ignore selected differences.
|
String |
toString()
Returns the description of the last comparison result.
|
public static final String NO_DIFF
public static final String NO_DIFF_LOGICALLY
public static final String UNKNOWN_ERROR
public MessageDiff(Message message1, Message message2)
message1 - first message to comparemessage2 - second message to compareNullPointerException - if message1 or message2 is nullpublic MessageDiffListener getDiffListener()
public void setDiffListener(MessageDiffListener diffListener)
diffListener - listener to useNullPointerException - if diffListener is nullpublic boolean isSimilar()
The strict comparison checks message version, message type, field values and repeating group instance order.
true if the messages are strictly similar, false otherwisepublic static boolean isSimilar(Message message1, Message message2)
message1 - first message to comparemessage2 - second message to comparetrue if the messages are strictly similar, false otherwiseNullPointerException - if message1 or message2 is nullpublic boolean isLogicallySimilar()
The logical comparison ignores repeating group instance order and compares group contents by value.
true if the messages are logically similar, false otherwisepublic static boolean isLogicallySimilar(Message message1, Message message2)
message1 - first message to comparemessage2 - second message to comparetrue if the messages are logically similar, false otherwiseNullPointerException - if message1 or message2 is nullCopyright © 2005–2026 Onix Solutions. All rights reserved.