Skip to content

Commit

Permalink
move 'capitalizeFirstLetter' method to StringUtil
Browse files Browse the repository at this point in the history
Signed-off-by: Ceki Gulcu <[email protected]>
  • Loading branch information
ceki committed Feb 23, 2024
1 parent 097da9d commit 1e1c2a7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import ch.qos.logback.core.joran.util.beans.BeanUtil;
import ch.qos.logback.core.spi.ContextAwareBase;
import ch.qos.logback.core.util.AggregationType;
import ch.qos.logback.core.util.StringUtil;

import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException;
Expand Down Expand Up @@ -53,7 +54,7 @@ public AggregationAssessor(BeanDescriptionCache beanDescriptionCache, Class objC
* @return the computed {@link AggregationType}
*/
public AggregationType computeAggregationType(String name) {
String cName = capitalizeFirstLetter(name);
String cName = StringUtil.capitalizeFirstLetter(name);

Method addMethod = findAdderMethod(cName);

Expand Down Expand Up @@ -82,9 +83,10 @@ public AggregationType computeAggregationType(String name) {
}
}

String capitalizeFirstLetter(String name) {
return name.substring(0, 1).toUpperCase() + name.substring(1);
}

// String capitalizeFirstLetter(String name) {
// return StringUtil.capitalizeFirstLetter(name);
// }

Method findAdderMethod(String name) {
String propertyName = BeanUtil.toLowerCamelCase(name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import ch.qos.logback.core.spi.ContextAwareBase;
import ch.qos.logback.core.util.AggregationType;
import ch.qos.logback.core.util.PropertySetterException;
import ch.qos.logback.core.util.StringUtil;

import java.lang.reflect.Method;

Expand Down Expand Up @@ -208,7 +209,7 @@ public void addBasicProperty(String name, String strValue) {
return;
}

name = aggregationAssessor.capitalizeFirstLetter(name);
name = StringUtil.capitalizeFirstLetter(name);
Method adderMethod =aggregationAssessor.findAdderMethod(name);

if (adderMethod == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,11 @@ public static boolean isNullOrEmpty(String str) {
public static boolean notNullNorEmpty(String str) {
return !isNullOrEmpty(str);
}

public static String capitalizeFirstLetter(String name) {
if(isNullOrEmpty(name))
return name;
else
return name.substring(0, 1).toUpperCase() + name.substring(1);
}
}

0 comments on commit 1e1c2a7

Please sign in to comment.