Search in sources :

Example 1 with EMandatory

use of com.helger.commons.state.EMandatory in project phase4 by phax.

the class PModePayloadProfileJsonConverter method convertToNative.

@Nonnull
public static PModePayloadProfile convertToNative(final IJsonObject aElement) {
    final String sName = aElement.getAsString(NAME);
    final String sMimeType = aElement.getAsString(MIME_TYPE);
    final IMimeType aMimeType;
    try {
        aMimeType = MimeTypeParser.parseMimeType(sMimeType);
    } catch (final MimeTypeParserException ex) {
        throw new IllegalArgumentException("Failed to parse MIME Type '" + sMimeType + "'", ex);
    }
    final String sXSDFilename = aElement.getAsString(XSD_FILENAME);
    final Integer aMaxSizeKB = aElement.getAsIntObj(MAX_SIZE_KB);
    final EMandatory eMandatory = EMandatory.valueOf(aElement.getAsBoolean(MANDATORY, PModePayloadProfile.DEFAULT_MANDATORY));
    return new PModePayloadProfile(sName, aMimeType, sXSDFilename, aMaxSizeKB, eMandatory);
}
Also used : IMimeType(com.helger.commons.mime.IMimeType) EMandatory(com.helger.commons.state.EMandatory) MimeTypeParserException(com.helger.commons.mime.MimeTypeParserException) Nonnull(javax.annotation.Nonnull)

Example 2 with EMandatory

use of com.helger.commons.state.EMandatory in project phase4 by phax.

the class PModePayloadProfileMicroTypeConverter method convertToNative.

@Nonnull
public PModePayloadProfile convertToNative(final IMicroElement aElement) {
    final String sName = aElement.getAttributeValue(ATTR_NAME);
    final String sMimeType = aElement.getAttributeValue(ATTR_MIME_TYPE);
    final IMimeType aMimeType;
    try {
        aMimeType = MimeTypeParser.parseMimeType(sMimeType);
    } catch (final MimeTypeParserException ex) {
        throw new IllegalArgumentException("Failed to parse MIME Type '" + sMimeType + "'", ex);
    }
    final String sXSDFilename = aElement.getAttributeValue(ATTR_XSD_FILENAME);
    final Integer aMaxSizeKB = aElement.getAttributeValueWithConversion(ATTR_MAX_SIZE_KB, Integer.class);
    final EMandatory eMandatory = EMandatory.valueOf(aElement.getAttributeValueAsBool(ATTR_MANDATORY, PModePayloadProfile.DEFAULT_MANDATORY));
    return new PModePayloadProfile(sName, aMimeType, sXSDFilename, aMaxSizeKB, eMandatory);
}
Also used : IMimeType(com.helger.commons.mime.IMimeType) EMandatory(com.helger.commons.state.EMandatory) MimeTypeParserException(com.helger.commons.mime.MimeTypeParserException) Nonnull(javax.annotation.Nonnull)

Example 3 with EMandatory

use of com.helger.commons.state.EMandatory in project phase4 by phax.

the class PModePropertyJsonConverter method convertToNative.

@Nonnull
public static PModeProperty convertToNative(@Nonnull final IJsonObject aElement) {
    final String sName = aElement.getAsString(NAME);
    final String sDescription = aElement.getAsString(DESCRIPTION);
    final String sDataType = aElement.getAsString(DATA_TYPE);
    final EMandatory eMandatory = EMandatory.valueOf(aElement.getAsBoolean(MANDATORY, PModeProperty.DEFAULT_MANDATORY));
    return new PModeProperty(sName, sDescription, sDataType, eMandatory);
}
Also used : EMandatory(com.helger.commons.state.EMandatory) Nonnull(javax.annotation.Nonnull)

Example 4 with EMandatory

use of com.helger.commons.state.EMandatory in project phase4 by phax.

the class PModePropertyMicroTypeConverter method convertToNative.

@Nonnull
public PModeProperty convertToNative(@Nonnull final IMicroElement aElement) {
    final String sName = aElement.getAttributeValue(ATTR_NAME);
    final String sDescription = aElement.getAttributeValue(ATTR_DESCRIPTION);
    final String sDataType = aElement.getAttributeValue(ATTR_DATA_TYPE);
    final EMandatory eMandatory = EMandatory.valueOf(aElement.getAttributeValueAsBool(ATTR_MANDATORY, PModeProperty.DEFAULT_MANDATORY));
    return new PModeProperty(sName, sDescription, sDataType, eMandatory);
}
Also used : EMandatory(com.helger.commons.state.EMandatory) Nonnull(javax.annotation.Nonnull)

Aggregations

EMandatory (com.helger.commons.state.EMandatory)4 Nonnull (javax.annotation.Nonnull)4 IMimeType (com.helger.commons.mime.IMimeType)2 MimeTypeParserException (com.helger.commons.mime.MimeTypeParserException)2