/** * Add default values for optional fields that are not filled in the payload. * <p> * Payload should be checked for validity first, there is no error handling inside this method anymore. * </p> * * @param checkedPayload The checked payload to add optional fields to. * @throws ClassCastException If the {@link TenantConstants#FIELD_ADAPTERS_TYPE} element is not a {@link JsonArray} * or the JsonArray contains elements that are not of type {@link JsonObject}. */ protected final void addNotPresentFieldsWithDefaultValuesForTenant(final JsonObject checkedPayload) { if (!checkedPayload.containsKey(TenantConstants.FIELD_ENABLED)) { log.trace("adding 'enabled' key to payload"); checkedPayload.put(TenantConstants.FIELD_ENABLED, Boolean.TRUE); } final JsonArray adapters = checkedPayload.getJsonArray(TenantConstants.FIELD_ADAPTERS); if (adapters != null) { adapters.forEach(elem -> addNotPresentFieldsWithDefaultValuesForAdapter((JsonObject) elem)); } }
/** * Add default values for optional fields that are not filled in the payload. * <p> * Payload should be checked for validity first, there is no error handling inside this method anymore. * </p> * * @param checkedPayload The checked payload to add optional fields to. * @throws ClassCastException If the {@link TenantConstants#FIELD_ADAPTERS_TYPE} element is not a {@link JsonArray} * or the JsonArray contains elements that are not of type {@link JsonObject}. */ protected final void addNotPresentFieldsWithDefaultValuesForTenant(final JsonObject checkedPayload) { if (!checkedPayload.containsKey(TenantConstants.FIELD_ENABLED)) { log.trace("adding 'enabled' key to payload"); checkedPayload.put(TenantConstants.FIELD_ENABLED, Boolean.TRUE); } final JsonArray adapters = checkedPayload.getJsonArray(TenantConstants.FIELD_ADAPTERS); if (adapters != null) { adapters.forEach(elem -> addNotPresentFieldsWithDefaultValuesForAdapter((JsonObject) elem)); } }