diff --git a/phase4-lib/src/main/java/com/helger/phase4/model/pmode/PModePartyJsonConverter.java b/phase4-lib/src/main/java/com/helger/phase4/model/pmode/PModePartyJsonConverter.java
index 7267a3931..91645f19f 100644
--- a/phase4-lib/src/main/java/com/helger/phase4/model/pmode/PModePartyJsonConverter.java
+++ b/phase4-lib/src/main/java/com/helger/phase4/model/pmode/PModePartyJsonConverter.java
@@ -43,11 +43,16 @@ private PModePartyJsonConverter ()
@Nonnull
public static IJsonObject convertToJson (@Nonnull final PModeParty aValue)
{
- return new JsonObject ().add (ID_TYPE, aValue.getIDType ())
- .add (ID_VALUE, aValue.getIDValue ())
- .add (ROLE, aValue.getRole ())
- .add (USER_NAME, aValue.getUserName ())
- .add (PASSWORD, aValue.getPassword ());
+ final IJsonObject ret = new JsonObject ();
+ if (aValue.hasIDType ())
+ ret.add (ID_TYPE, aValue.getIDType ());
+ ret.add (ID_VALUE, aValue.getIDValue ());
+ ret.add (ROLE, aValue.getRole ());
+ if (aValue.hasUserName ())
+ ret.add (USER_NAME, aValue.getUserName ());
+ if (aValue.hasPassword ())
+ ret.add (PASSWORD, aValue.getPassword ());
+ return ret;
}
@Nonnull
diff --git a/phase4-lib/src/main/java/com/helger/phase4/model/pmode/PModePayloadService.java b/phase4-lib/src/main/java/com/helger/phase4/model/pmode/PModePayloadService.java
index e69d836aa..da69796f7 100644
--- a/phase4-lib/src/main/java/com/helger/phase4/model/pmode/PModePayloadService.java
+++ b/phase4-lib/src/main/java/com/helger/phase4/model/pmode/PModePayloadService.java
@@ -49,6 +49,15 @@ public final EAS4CompressionMode getCompressionMode ()
return m_eCompressionMode;
}
+ /**
+ * @return true
if a compression mode is set, false
+ * if not.
+ */
+ public final boolean hasCompressionMode ()
+ {
+ return m_eCompressionMode != null;
+ }
+
/**
* @return The ID of the used compression mode or null
if no
* compression mode is set.
diff --git a/phase4-lib/src/main/java/com/helger/phase4/model/pmode/PModePayloadServiceJsonConverter.java b/phase4-lib/src/main/java/com/helger/phase4/model/pmode/PModePayloadServiceJsonConverter.java
index d1d8bfddb..18949ab09 100644
--- a/phase4-lib/src/main/java/com/helger/phase4/model/pmode/PModePayloadServiceJsonConverter.java
+++ b/phase4-lib/src/main/java/com/helger/phase4/model/pmode/PModePayloadServiceJsonConverter.java
@@ -40,7 +40,10 @@ private PModePayloadServiceJsonConverter ()
@Nonnull
public static IJsonObject convertToJson (@Nonnull final PModePayloadService aValue)
{
- return new JsonObject ().add (COMPRESSION_MODE, aValue.getCompressionModeID ());
+ final IJsonObject ret = new JsonObject ();
+ if (aValue.hasCompressionMode ())
+ ret.add (COMPRESSION_MODE, aValue.getCompressionModeID ());
+ return ret;
}
@Nonnull
diff --git a/phase4-lib/src/main/java/com/helger/phase4/model/pmode/leg/PModeLegJsonConverter.java b/phase4-lib/src/main/java/com/helger/phase4/model/pmode/leg/PModeLegJsonConverter.java
index a7bdc16ae..5a53f87e6 100644
--- a/phase4-lib/src/main/java/com/helger/phase4/model/pmode/leg/PModeLegJsonConverter.java
+++ b/phase4-lib/src/main/java/com/helger/phase4/model/pmode/leg/PModeLegJsonConverter.java
@@ -31,11 +31,11 @@
@Immutable
public final class PModeLegJsonConverter
{
- private static final String ELEMENT_PROTOCOL = "Protocol";
- private static final String ELEMENT_BUSINESS_INFORMATION = "BusinessInfo";
- private static final String ELEMENT_ERROR_HANDLING = "ErrorHandling";
- private static final String ELEMENT_RELIABILITY = "Reliability";
- private static final String ELEMENT_SECURITY = "Security";
+ private static final String PROTOCOL = "Protocol";
+ private static final String BUSINESS_INFORMATION = "BusinessInfo";
+ private static final String ERROR_HANDLING = "ErrorHandling";
+ private static final String RELIABILITY = "Reliability";
+ private static final String SECURITY = "Security";
private PModeLegJsonConverter ()
{}
@@ -45,38 +45,37 @@ public static IJsonObject convertToJson (@Nonnull final PModeLeg aValue)
{
final IJsonObject ret = new JsonObject ();
if (aValue.hasProtocol ())
- ret.addJson (ELEMENT_PROTOCOL, PModeLegProtocolJsonConverter.convertToJson (aValue.getProtocol ()));
+ ret.addJson (PROTOCOL, PModeLegProtocolJsonConverter.convertToJson (aValue.getProtocol ()));
if (aValue.hasBusinessInfo ())
- ret.addJson (ELEMENT_BUSINESS_INFORMATION,
+ ret.addJson (BUSINESS_INFORMATION,
PModeLegBusinessInformationJsonConverter.convertToJson (aValue.getBusinessInfo ()));
if (aValue.hasErrorHandling ())
- ret.addJson (ELEMENT_ERROR_HANDLING,
- PModeLegErrorHandlingJsonConverter.convertToJson (aValue.getErrorHandling ()));
+ ret.addJson (ERROR_HANDLING, PModeLegErrorHandlingJsonConverter.convertToJson (aValue.getErrorHandling ()));
if (aValue.hasReliability ())
- ret.addJson (ELEMENT_RELIABILITY, PModeLegReliabilityJsonConverter.convertToJson (aValue.getReliability ()));
+ ret.addJson (RELIABILITY, PModeLegReliabilityJsonConverter.convertToJson (aValue.getReliability ()));
if (aValue.hasSecurity ())
- ret.addJson (ELEMENT_SECURITY, PModeLegSecurityJsonConverter.convertToJson (aValue.getSecurity ()));
+ ret.addJson (SECURITY, PModeLegSecurityJsonConverter.convertToJson (aValue.getSecurity ()));
return ret;
}
@Nonnull
public static PModeLeg convertToNative (@Nonnull final IJsonObject aElement)
{
- final IJsonObject aProt = aElement.getAsObject (ELEMENT_PROTOCOL);
+ final IJsonObject aProt = aElement.getAsObject (PROTOCOL);
final PModeLegProtocol aProtocol = aProt == null ? null : PModeLegProtocolJsonConverter.convertToNative (aProt);
- final IJsonObject aBI = aElement.getAsObject (ELEMENT_BUSINESS_INFORMATION);
+ final IJsonObject aBI = aElement.getAsObject (BUSINESS_INFORMATION);
final PModeLegBusinessInformation aBusinessInformation = aBI == null ? null
: PModeLegBusinessInformationJsonConverter.convertToNative (aBI);
- final IJsonObject aEH = aElement.getAsObject (ELEMENT_ERROR_HANDLING);
+ final IJsonObject aEH = aElement.getAsObject (ERROR_HANDLING);
final PModeLegErrorHandling aErrorHandling = aEH == null ? null
: PModeLegErrorHandlingJsonConverter.convertToNative (aEH);
- final IJsonObject aR = aElement.getAsObject (ELEMENT_RELIABILITY);
+ final IJsonObject aR = aElement.getAsObject (RELIABILITY);
final PModeLegReliability aReliability = aR == null ? null : PModeLegReliabilityJsonConverter.convertToNative (aR);
- final IJsonObject aS = aElement.getAsObject (ELEMENT_SECURITY);
+ final IJsonObject aS = aElement.getAsObject (SECURITY);
final PModeLegSecurity aSecurity = aS == null ? null : PModeLegSecurityJsonConverter.convertToNative (aS);
return new PModeLeg (aProtocol, aBusinessInformation, aErrorHandling, aReliability, aSecurity);