11package de .rwth .idsg .steve .utils ;
22
33import com .google .common .base .Strings ;
4- import lombok .extern .log4j . Log4j2 ;
4+ import lombok .extern .slf4j . Slf4j ;
55
66import java .io .FileNotFoundException ;
77import java .io .InputStream ;
1313 * @author Sevket Goekay <goekay@dbis.rwth-aachen.de>
1414 * @since 01.10.2015
1515 */
16- @ Log4j2
16+ @ Slf4j
1717public class PropertiesFileLoader {
1818
1919 private Properties prop ;
@@ -45,12 +45,7 @@ public String getString(String key) {
4545 throw new IllegalArgumentException ("The property '" + key + "' has no value set" );
4646 }
4747
48- String trimmed = s .trim ();
49- if (!trimmed .equals (s )) {
50- log .warn ("The property '{}' has leading or trailing spaces which were removed!" , key );
51- }
52-
53- return trimmed ;
48+ return trim (key , s );
5449 }
5550
5651 public boolean getBoolean (String key ) {
@@ -70,7 +65,7 @@ public String getOptionalString(String key) {
7065 if (Strings .isNullOrEmpty (s )) {
7166 return null ;
7267 }
73- return s ;
68+ return trim ( key , s ) ;
7469 }
7570
7671 public Boolean getOptionalBoolean (String key ) {
@@ -90,4 +85,16 @@ public Integer getOptionalInt(String key) {
9085 return Integer .parseInt (s );
9186 }
9287 }
88+
89+ // -------------------------------------------------------------------------
90+ // Private helpers
91+ // -------------------------------------------------------------------------
92+
93+ private static String trim (String key , String value ) {
94+ String trimmed = value .trim ();
95+ if (!trimmed .equals (value )) {
96+ log .warn ("The property '{}' has leading or trailing spaces which were removed!" , key );
97+ }
98+ return trimmed ;
99+ }
93100}
0 commit comments