From d94eca4ee7fec0c404b4393be587cc2c071381b6 Mon Sep 17 00:00:00 2001 From: Anthony Stirling <77850077+Frooodle@users.noreply.github.com> Date: Sat, 7 Oct 2023 23:35:28 +0100 Subject: [PATCH] blank == null --- .../software/SPDF/config/AppConfig.java | 11 ----- .../SPDF/config/CustomEditorConfigurer.java | 42 ------------------- .../SPDF/config/EmptyStringAsNullEditor.java | 13 ------ .../SPDF/model/ApplicationProperties.java | 6 +++ 4 files changed, 6 insertions(+), 66 deletions(-) delete mode 100644 src/main/java/stirling/software/SPDF/config/CustomEditorConfigurer.java delete mode 100644 src/main/java/stirling/software/SPDF/config/EmptyStringAsNullEditor.java diff --git a/src/main/java/stirling/software/SPDF/config/AppConfig.java b/src/main/java/stirling/software/SPDF/config/AppConfig.java index 602102d0..5d4bad43 100644 --- a/src/main/java/stirling/software/SPDF/config/AppConfig.java +++ b/src/main/java/stirling/software/SPDF/config/AppConfig.java @@ -9,17 +9,6 @@ import stirling.software.SPDF.model.ApplicationProperties; @Configuration public class AppConfig { - @Bean - public CustomEditorConfigurer customEditorConfigurer() { - return new CustomEditorConfigurer(); - } - - @Bean - public PropertyEditorRegistrar propertyEditorRegistrar() { - return registry -> { - registry.registerCustomEditor(String.class, new EmptyStringAsNullEditor()); - }; - } @Autowired ApplicationProperties applicationProperties; diff --git a/src/main/java/stirling/software/SPDF/config/CustomEditorConfigurer.java b/src/main/java/stirling/software/SPDF/config/CustomEditorConfigurer.java deleted file mode 100644 index 6a0ac986..00000000 --- a/src/main/java/stirling/software/SPDF/config/CustomEditorConfigurer.java +++ /dev/null @@ -1,42 +0,0 @@ -package stirling.software.SPDF.config; -import java.beans.PropertyEditor; - -import org.springframework.beans.BeansException; -import org.springframework.beans.PropertyEditorRegistrar; -import org.springframework.beans.PropertyEditorRegistry; -import org.springframework.beans.factory.config.BeanPostProcessor; -import org.springframework.validation.DataBinder; - -public class CustomEditorConfigurer implements BeanPostProcessor { - - @Override - public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { - if (bean instanceof PropertyEditorRegistrar) { - ((PropertyEditorRegistrar) bean).registerCustomEditors(new PropertyEditorRegistry() { - @Override - public void registerCustomEditor(Class requiredType, String propertyPath, java.beans.PropertyEditor propertyEditor) { - DataBinder dataBinder = new DataBinder(bean); - dataBinder.registerCustomEditor(requiredType, propertyPath, propertyEditor); - } - - @Override - public void registerCustomEditor(Class requiredType, java.beans.PropertyEditor propertyEditor) { - DataBinder dataBinder = new DataBinder(bean); - dataBinder.registerCustomEditor(requiredType, propertyEditor); - } - - @Override - public PropertyEditor findCustomEditor(Class requiredType, String propertyPath) { - return null; - } - }); - } - - return bean; - } - - @Override - public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { - return bean; - } -} diff --git a/src/main/java/stirling/software/SPDF/config/EmptyStringAsNullEditor.java b/src/main/java/stirling/software/SPDF/config/EmptyStringAsNullEditor.java deleted file mode 100644 index fd8de476..00000000 --- a/src/main/java/stirling/software/SPDF/config/EmptyStringAsNullEditor.java +++ /dev/null @@ -1,13 +0,0 @@ -package stirling.software.SPDF.config; -import java.beans.PropertyEditorSupport; - -public class EmptyStringAsNullEditor extends PropertyEditorSupport { - @Override - public void setAsText(String text) { - if (text != null && text.trim().isEmpty()) { - setValue(null); - } else { - setValue(text); - } - } -} diff --git a/src/main/java/stirling/software/SPDF/model/ApplicationProperties.java b/src/main/java/stirling/software/SPDF/model/ApplicationProperties.java index a72479ad..dc068779 100644 --- a/src/main/java/stirling/software/SPDF/model/ApplicationProperties.java +++ b/src/main/java/stirling/software/SPDF/model/ApplicationProperties.java @@ -232,6 +232,8 @@ public class ApplicationProperties { private String appNameNavbar; public String getAppName() { + if(appName != null && appName.trim().length() == 0) + return null; return appName; } @@ -240,6 +242,8 @@ public class ApplicationProperties { } public String getHomeDescription() { + if(homeDescription != null && homeDescription.trim().length() == 0) + return null; return homeDescription; } @@ -248,6 +252,8 @@ public class ApplicationProperties { } public String getAppNameNavbar() { + if(appNameNavbar != null && appNameNavbar.trim().length() == 0) + return null; return appNameNavbar; }