Skip to content

Commit

Permalink
[#2815] change StringUtils API
Browse files Browse the repository at this point in the history
  - isNotEmpty(String) -> hasLength(String)
  • Loading branch information
emeroad committed Jun 12, 2017
1 parent a63e74f commit 1dac94a
Show file tree
Hide file tree
Showing 14 changed files with 17 additions and 18 deletions.
Expand Up @@ -40,7 +40,7 @@ public static boolean isEmpty(final String string) {
return string == null || string.isEmpty();
}

public static boolean isNotEmpty(final String string) {
public static boolean hasLength(final String string) {
return string != null && string.length() > 0;
}

Expand Down
Expand Up @@ -405,7 +405,7 @@ private void recordCookie(HttpMethod httpMethod, Trace trace) {
}

final String value = cookie.getValue();
if (StringUtils.isNotEmpty(value)) {
if (StringUtils.hasLength(value)) {
if (cookieSampler.isSampling()) {
final SpanEventRecorder recorder = trace.currentSpanEventRecorder();
recorder.recordAttribute(AnnotationKey.HTTP_COOKIE, StringUtils.abbreviate(value, MAX_READ_SIZE));
Expand Down
Expand Up @@ -297,7 +297,7 @@ protected void recordCookie(HttpMessage httpMessage, Trace trace) {
org.apache.http.Header[] cookies = httpMessage.getHeaders("Cookie");
for (org.apache.http.Header header : cookies) {
final String value = header.getValue();
if (StringUtils.isNotEmpty(value)) {
if (StringUtils.hasLength(value)) {
if (cookieSampler.isSampling()) {
final SpanEventRecorder recorder = trace.currentSpanEventRecorder();
recorder.recordAttribute(AnnotationKey.HTTP_COOKIE, StringUtils.abbreviate(value, 1024));
Expand Down
Expand Up @@ -448,7 +448,7 @@ public void after(final Object target, final Object[] args, final Object result,
final HttpServletRequest request = (HttpServletRequest) args[0];
if (!excludeProfileMethodFilter.filter(request.getMethod())) {
final String parameters = getRequestParameter(request, 64, 512);
if (StringUtils.isNotEmpty(parameters)) {
if (StringUtils.hasLength(parameters)) {
recorder.recordAttribute(AnnotationKey.HTTP_PARAM, parameters);
}
}
Expand Down
Expand Up @@ -154,7 +154,7 @@ public void after(Object target, Object[] args, Object result, Throwable throwab
SpanEventRecorder recorder = trace.currentSpanEventRecorder();
final Request request = getRequest(args);
final String parameters = getRequestParameter(request, 64, 512);
if (StringUtils.isNotEmpty(parameters)) {
if (StringUtils.hasLength(parameters)) {
recorder.recordAttribute(AnnotationKey.HTTP_PARAM, parameters);
}

Expand Down
Expand Up @@ -29,7 +29,7 @@ public ServiceType getApplicationType() {

@Override
public boolean detect(ConditionProvider provider) {
if (StringUtils.isNotEmpty(bootstrapMains)) {
if (StringUtils.hasLength(bootstrapMains)) {
return provider.checkMainClass(bootstrapMains) && provider.checkForClass(REQUIRED_CLASS);
}
return provider.checkForClass(REQUIRED_CLASS);
Expand Down
Expand Up @@ -137,7 +137,7 @@ public void after(Object target, Object[] args, Object result, Throwable throwab
final HttpServletRequest request = (HttpServletRequest) args[0];
if (!excludeProfileMethodFilter.filter(request.getMethod())) {
final String parameters = getRequestParameter(request, 64, 512);
if (StringUtils.isNotEmpty(parameters)) {
if (StringUtils.hasLength(parameters)) {
recorder.recordAttribute(AnnotationKey.HTTP_PARAM, parameters);
}
}
Expand Down
Expand Up @@ -63,23 +63,23 @@ private Map<Integer, SpringBeansTarget> addBackwardCompatibilityTarget(ProfilerC
final Map<Integer, SpringBeansTarget> result = new HashMap<Integer, SpringBeansTarget>();
final String namePatternRegexs = config.readString(SPRING_BEANS_NAME_PATTERN, null);
// bean name.
if (StringUtils.isNotEmpty(namePatternRegexs)) {
if (StringUtils.hasLength(namePatternRegexs)) {
final SpringBeansTarget target = new SpringBeansTarget();
target.setNamePatterns(namePatternRegexs);
result.put(-1, target);
}

// class name.
final String classPatternRegexs = config.readString(SPRING_BEANS_CLASS_PATTERN, null);
if (StringUtils.isNotEmpty(classPatternRegexs)) {
if (StringUtils.hasLength(classPatternRegexs)) {
final SpringBeansTarget target = new SpringBeansTarget();
target.setClassPatterns(classPatternRegexs);
result.put(-2, target);
}

// annotation.
final String annotations = config.readString(SPRING_BEANS_ANNOTATION, null);
if (StringUtils.isNotEmpty(annotations)) {
if (StringUtils.hasLength(annotations)) {
final SpringBeansTarget target = new SpringBeansTarget();
target.setAnnotations(annotations);
result.put(-3, target);
Expand Down
Expand Up @@ -317,7 +317,7 @@ public void after(Object target, Object[] args, Object result, Throwable throwab
final HttpServletRequest request = (HttpServletRequest) args[0];
if (!excludeProfileMethodFilter.filter(request.getMethod())) {
final String parameters = getRequestParameter(request, 64, 512);
if (StringUtils.isNotEmpty(parameters)) {
if (StringUtils.hasLength(parameters)) {
recorder.recordAttribute(AnnotationKey.HTTP_PARAM, parameters);
}
}
Expand Down
Expand Up @@ -82,7 +82,7 @@ public void addAnnotation(Annotation annotation) {

public void setExceptionInfo(int exceptionClassId, String exceptionMessage) {
final TIntStringValue exceptionInfo = new TIntStringValue(exceptionClassId);
if (StringUtils.isNotEmpty(exceptionMessage)) {
if (StringUtils.hasLength(exceptionMessage)) {
exceptionInfo.setStringValue(exceptionMessage);
}
super.setExceptionInfo(exceptionInfo);
Expand Down
Expand Up @@ -63,7 +63,7 @@ public void setExceptionInfo(boolean markError, int exceptionClassId, String exc

void setExceptionInfo(int exceptionClassId, String exceptionMessage) {
final TIntStringValue exceptionInfo = new TIntStringValue(exceptionClassId);
if (StringUtils.isNotEmpty(exceptionMessage)) {
if (StringUtils.hasLength(exceptionMessage)) {
exceptionInfo.setStringValue(exceptionMessage);
}
super.setExceptionInfo(exceptionInfo);
Expand Down
Expand Up @@ -19,7 +19,6 @@
import com.navercorp.pinpoint.common.util.StringUtils;
import com.navercorp.pinpoint.profiler.context.Annotation;
import com.navercorp.pinpoint.profiler.context.DefaultTrace;
import com.navercorp.pinpoint.profiler.context.Span;
import com.navercorp.pinpoint.profiler.context.SpanEvent;
import com.navercorp.pinpoint.profiler.metadata.SqlMetaDataService;
import com.navercorp.pinpoint.profiler.metadata.StringMetaDataService;
Expand Down Expand Up @@ -82,10 +81,10 @@ public void recordSqlParsingResult(ParsingResult parsingResult, String bindValue

final TIntStringStringValue tSqlValue = new TIntStringStringValue(parsingResult.getId());
final String output = parsingResult.getOutput();
if (StringUtils.isNotEmpty(output)) {
if (StringUtils.hasLength(output)) {
tSqlValue.setStringValue1(output);
}
if (StringUtils.isNotEmpty(bindValue)) {
if (StringUtils.hasLength(bindValue)) {
tSqlValue.setStringValue2(bindValue);
}
recordSqlParam(tSqlValue);
Expand Down
Expand Up @@ -223,7 +223,7 @@ private ClusterOption getClusterOption(Map handshakeResponse) {
private List<Role> getRoles(List roleNames) {
List<Role> roles = new ArrayList<Role>();
for (Object roleName : roleNames) {
if (roleName instanceof String && StringUtils.isNotEmpty((String) roleName)) {
if (roleName instanceof String && StringUtils.hasLength((String) roleName)) {
roles.add(Role.getValue((String) roleName));
}
}
Expand Down
Expand Up @@ -402,7 +402,7 @@ private ClusterOption getClusterOption(Map handshakeResponse) {
private List<Role> getRoles(List roleNames) {
List<Role> roles = new ArrayList<Role>();
for (Object roleName : roleNames) {
if (roleName instanceof String && StringUtils.isNotEmpty((String) roleName)) {
if (roleName instanceof String && StringUtils.hasLength((String) roleName)) {
roles.add(Role.getValue((String) roleName));
}
}
Expand Down

0 comments on commit 1dac94a

Please sign in to comment.