From aff7c021e37e64162ce4e3fe5abd419072fb464f Mon Sep 17 00:00:00 2001 From: Christof Rabensteiner Date: Thu, 16 May 2019 14:26:03 +0200 Subject: Refactor + Document in preprocess - Refactor: Move ConfigType.merge's null check to caller. - Revise documentation of preprocess' public methods. --- .../at/gv/egiz/moazs/preprocess/ConfigUtil.java | 31 +++++++++------------- 1 file changed, 13 insertions(+), 18 deletions(-) (limited to 'src/main/java/at/gv/egiz/moazs/preprocess/ConfigUtil.java') diff --git a/src/main/java/at/gv/egiz/moazs/preprocess/ConfigUtil.java b/src/main/java/at/gv/egiz/moazs/preprocess/ConfigUtil.java index 79666a4..3fef4bd 100644 --- a/src/main/java/at/gv/egiz/moazs/preprocess/ConfigUtil.java +++ b/src/main/java/at/gv/egiz/moazs/preprocess/ConfigUtil.java @@ -5,7 +5,6 @@ import at.gv.zustellung.app2mzs.xsd.ServerType; import org.springframework.lang.Nullable; import org.springframework.stereotype.Component; -import javax.validation.constraints.Null; import java.util.Map; import static at.gv.zustellung.app2mzs.xsd.ConfigType.configTypeBuilder; @@ -18,10 +17,10 @@ public class ConfigUtil { private static final String MSG_URL_KEY = "msg.url"; /** - * Builds a ConvertType Object out of a Map on the Basis of it's Keys and Values. + * Convert a map into a Config object. * - * @param Map with keys and values. - * @return ConvertType Object + * @param map with well-defined indexes and values + * @return Config */ public ConfigType convert(Map values) { var server = serverTypeBuilder() @@ -38,26 +37,22 @@ public class ConfigUtil { } /** - * Combines Properties of Two ConfigType Objects; {@code primary} overrides {@code fallback}. + * Combine properties of two Configs; {@code primary} overrides {@code fallback}. * * @param primary * @param fallback - * @return Combined ConfigType + * @return Merged Config */ - public ConfigType merge(@Nullable ConfigType primary, ConfigType fallback) { + public ConfigType merge(ConfigType primary, ConfigType fallback) { var builder = configTypeBuilder(fallback); - if(primary != null) { - - if(primary.getServer() != null) { - builder.withServer(merge(primary.getServer(), fallback.getServer())); - } - - if(primary.isPerformQueryPersonRequest() != null) { - builder.withPerformQueryPersonRequest(primary.isPerformQueryPersonRequest()); - } + if(primary.getServer() != null) { + builder.withServer(merge(primary.getServer(), fallback.getServer())); + } + if(primary.isPerformQueryPersonRequest() != null) { + builder.withPerformQueryPersonRequest(primary.isPerformQueryPersonRequest()); } return builder.build(); @@ -79,10 +74,10 @@ public class ConfigUtil { } /** - * Checks if all mandatory fields are set. + * Check if all mandatory fields are set. * * @param profile - * @return + * @return true if all mandatory fields are set */ public boolean isComplete(@Nullable ConfigType profile) { //TODO: add check fo x509 certificate -- cgit v1.2.3