@@ -91,8 +91,10 @@ public Iterator<PropertySource<?>> iterator() {
91
91
* Add the given property source object with highest precedence.
92
92
*/
93
93
public void addFirst (PropertySource <?> propertySource ) {
94
- logger .debug (String .format ("Adding [%s] PropertySource with highest search precedence" ,
95
- propertySource .getName ()));
94
+ if (logger .isDebugEnabled ()) {
95
+ logger .debug (String .format ("Adding [%s] PropertySource with highest search precedence" ,
96
+ propertySource .getName ()));
97
+ }
96
98
removeIfPresent (propertySource );
97
99
this .propertySourceList .addFirst (propertySource );
98
100
}
@@ -101,8 +103,10 @@ public void addFirst(PropertySource<?> propertySource) {
101
103
* Add the given property source object with lowest precedence.
102
104
*/
103
105
public void addLast (PropertySource <?> propertySource ) {
104
- logger .debug (String .format ("Adding [%s] PropertySource with lowest search precedence" ,
105
- propertySource .getName ()));
106
+ if (logger .isDebugEnabled ()) {
107
+ logger .debug (String .format ("Adding [%s] PropertySource with lowest search precedence" ,
108
+ propertySource .getName ()));
109
+ }
106
110
removeIfPresent (propertySource );
107
111
this .propertySourceList .addLast (propertySource );
108
112
}
@@ -112,8 +116,10 @@ public void addLast(PropertySource<?> propertySource) {
112
116
* than the named relative property source.
113
117
*/
114
118
public void addBefore (String relativePropertySourceName , PropertySource <?> propertySource ) {
115
- logger .debug (String .format ("Adding [%s] PropertySource with search precedence immediately higher than [%s]" ,
116
- propertySource .getName (), relativePropertySourceName ));
119
+ if (logger .isDebugEnabled ()) {
120
+ logger .debug (String .format ("Adding [%s] PropertySource with search precedence immediately higher than [%s]" ,
121
+ propertySource .getName (), relativePropertySourceName ));
122
+ }
117
123
assertLegalRelativeAddition (relativePropertySourceName , propertySource );
118
124
removeIfPresent (propertySource );
119
125
int index = assertPresentAndGetIndex (relativePropertySourceName );
@@ -125,8 +131,10 @@ public void addBefore(String relativePropertySourceName, PropertySource<?> prope
125
131
* than the named relative property source.
126
132
*/
127
133
public void addAfter (String relativePropertySourceName , PropertySource <?> propertySource ) {
128
- logger .debug (String .format ("Adding [%s] PropertySource with search precedence immediately lower than [%s]" ,
129
- propertySource .getName (), relativePropertySourceName ));
134
+ if (logger .isDebugEnabled ()) {
135
+ logger .debug (String .format ("Adding [%s] PropertySource with search precedence immediately lower than [%s]" ,
136
+ propertySource .getName (), relativePropertySourceName ));
137
+ }
130
138
assertLegalRelativeAddition (relativePropertySourceName , propertySource );
131
139
removeIfPresent (propertySource );
132
140
int index = assertPresentAndGetIndex (relativePropertySourceName );
@@ -145,7 +153,9 @@ public int precedenceOf(PropertySource<?> propertySource) {
145
153
* @param name the name of the property source to find and remove
146
154
*/
147
155
public PropertySource <?> remove (String name ) {
148
- logger .debug (String .format ("Removing [%s] PropertySource" , name ));
156
+ if (logger .isDebugEnabled ()) {
157
+ logger .debug (String .format ("Removing [%s] PropertySource" , name ));
158
+ }
149
159
int index = this .propertySourceList .indexOf (PropertySource .named (name ));
150
160
return index == -1 ? null : this .propertySourceList .remove (index );
151
161
}
@@ -158,8 +168,10 @@ public PropertySource<?> remove(String name) {
158
168
* @see #contains
159
169
*/
160
170
public void replace (String name , PropertySource <?> propertySource ) {
161
- logger .debug (String .format ("Replacing [%s] PropertySource with [%s]" ,
162
- name , propertySource .getName ()));
171
+ if (logger .isDebugEnabled ()) {
172
+ logger .debug (String .format ("Replacing [%s] PropertySource with [%s]" ,
173
+ name , propertySource .getName ()));
174
+ }
163
175
int index = assertPresentAndGetIndex (name );
164
176
this .propertySourceList .set (index , propertySource );
165
177
}
0 commit comments