Use String#isEmpty()

This commit is contained in:
Gary Gregory 2023-11-28 17:46:42 -05:00
parent 573ea67cda
commit 0efee0bf95
18 changed files with 34 additions and 34 deletions

View File

@ -76,7 +76,7 @@ public class JettyJasperInitializer extends JasperInitializer
public TldScanner newTldScanner(ServletContext context, boolean namespaceAware, boolean validate, boolean blockExternal) public TldScanner newTldScanner(ServletContext context, boolean namespaceAware, boolean validate, boolean blockExternal)
{ {
String tmp = context.getInitParameter("org.eclipse.jetty.jsp.precompiled"); String tmp = context.getInitParameter("org.eclipse.jetty.jsp.precompiled");
if (tmp != null && !tmp.equals("") && Boolean.valueOf(tmp)) if (tmp != null && !tmp.isEmpty() && Boolean.valueOf(tmp))
{ {
if (LOG.isDebugEnabled()) if (LOG.isDebugEnabled())
LOG.debug("Jsp precompilation detected"); LOG.debug("Jsp precompilation detected");

View File

@ -82,7 +82,7 @@ public class ResourceAnnotationHandler extends AbstractIntrospectableAnnotationH
String name = resource.name(); String name = resource.name();
String mappedName = resource.mappedName(); String mappedName = resource.mappedName();
if (name == null || name.trim().equals("")) if (name == null || name.trim().isEmpty())
throw new IllegalStateException("Class level Resource annotations must contain a name (Common Annotations Spec Section 2.3)"); throw new IllegalStateException("Class level Resource annotations must contain a name (Common Annotations Spec Section 2.3)");
try try
@ -121,8 +121,8 @@ public class ResourceAnnotationHandler extends AbstractIntrospectableAnnotationH
String name = clazz.getName() + "/" + field.getName(); String name = clazz.getName() + "/" + field.getName();
//allow @Resource name= to override the field name //allow @Resource name= to override the field name
name = (resource.name() != null && !resource.name().trim().equals("") ? resource.name() : name); name = (resource.name() != null && !resource.name().trim().isEmpty() ? resource.name() : name);
String mappedName = (resource.mappedName() != null && !resource.mappedName().trim().equals("") ? resource.mappedName() : null); String mappedName = (resource.mappedName() != null && !resource.mappedName().trim().isEmpty() ? resource.mappedName() : null);
//get the type of the Field //get the type of the Field
Class<?> type = field.getType(); Class<?> type = field.getType();
@ -267,8 +267,8 @@ public class ResourceAnnotationHandler extends AbstractIntrospectableAnnotationH
name = name.substring(0, 1).toLowerCase(Locale.ENGLISH) + name.substring(1); name = name.substring(0, 1).toLowerCase(Locale.ENGLISH) + name.substring(1);
name = clazz.getName() + "/" + name; name = clazz.getName() + "/" + name;
name = (resource.name() != null && !resource.name().trim().equals("") ? resource.name() : name); name = (resource.name() != null && !resource.name().trim().isEmpty() ? resource.name() : name);
String mappedName = (resource.mappedName() != null && !resource.mappedName().trim().equals("") ? resource.mappedName() : null); String mappedName = (resource.mappedName() != null && !resource.mappedName().trim().isEmpty() ? resource.mappedName() : null);
Class<?> paramType = method.getParameterTypes()[0]; Class<?> paramType = method.getParameterTypes()[0];
Class<?> resourceType = resource.type(); Class<?> resourceType = resource.type();

View File

@ -49,7 +49,7 @@ public class ResourcesAnnotationHandler extends AbstractIntrospectableAnnotation
String name = resArray[j].name(); String name = resArray[j].name();
String mappedName = resArray[j].mappedName(); String mappedName = resArray[j].mappedName();
if (name == null || name.trim().equals("")) if (name == null || name.trim().isEmpty())
throw new IllegalStateException("Class level Resource annotations must contain a name (Common Annotations Spec Section 2.3)"); throw new IllegalStateException("Class level Resource annotations must contain a name (Common Annotations Spec Section 2.3)");
try try

View File

@ -77,7 +77,7 @@ public class WebFilterAnnotation extends DiscoveredAnnotation
return; return;
} }
String name = (filterAnnotation.filterName().equals("") ? clazz.getName() : filterAnnotation.filterName()); String name = (filterAnnotation.filterName().isEmpty() ? clazz.getName() : filterAnnotation.filterName());
String[] urlPatterns = filterAnnotation.value(); String[] urlPatterns = filterAnnotation.value();
if (urlPatterns.length == 0) if (urlPatterns.length == 0)
urlPatterns = filterAnnotation.urlPatterns(); urlPatterns = filterAnnotation.urlPatterns();

View File

@ -96,7 +96,7 @@ public class WebServletAnnotation extends DiscoveredAnnotation
urlPatternList.add(ServletPathSpec.normalize(p)); urlPatternList.add(ServletPathSpec.normalize(p));
} }
String servletName = (annotation.name().equals("") ? clazz.getName() : annotation.name()); String servletName = (annotation.name().isEmpty() ? clazz.getName() : annotation.name());
MetaData metaData = _context.getMetaData(); MetaData metaData = _context.getMetaData();
ServletMapping mapping = null; //the new mapping ServletMapping mapping = null; //the new mapping

View File

@ -290,7 +290,7 @@ public class ServletPathSpec extends AbstractPathSpec
private static void assertValidServletPathSpec(String servletPathSpec) private static void assertValidServletPathSpec(String servletPathSpec)
{ {
if ((servletPathSpec == null) || servletPathSpec.equals("")) if ((servletPathSpec == null) || servletPathSpec.isEmpty())
{ {
return; // empty path spec return; // empty path spec
} }

View File

@ -227,7 +227,7 @@ public class NamingContext implements Context, Dumpable
{ {
String firstComponent = cname.get(0); String firstComponent = cname.get(0);
if (firstComponent.equals("")) if (firstComponent.isEmpty())
return this; return this;
Binding binding = getBinding(firstComponent); Binding binding = getBinding(firstComponent);
@ -293,7 +293,7 @@ public class NamingContext implements Context, Dumpable
String firstComponent = cname.get(0); String firstComponent = cname.get(0);
Object ctx = null; Object ctx = null;
if (firstComponent.equals("")) if (firstComponent.isEmpty())
ctx = this; ctx = this;
else else
{ {
@ -1028,10 +1028,10 @@ public class NamingContext implements Context, Dumpable
{ {
if (canonicalName.size() > 1) if (canonicalName.size() > 1)
{ {
if (canonicalName.get(0).equals("")) if (canonicalName.get(0).isEmpty())
canonicalName = canonicalName.getSuffix(1); canonicalName = canonicalName.getSuffix(1);
if (canonicalName.get(canonicalName.size() - 1).equals("")) if (canonicalName.get(canonicalName.size() - 1).isEmpty())
canonicalName = canonicalName.getPrefix(canonicalName.size() - 1); canonicalName = canonicalName.getPrefix(canonicalName.size() - 1);
} }
} }

View File

@ -320,7 +320,7 @@ public class javaRootURLContext implements Context
{ {
String newName = name; String newName = name;
if ((name != null) && (!name.equals(""))) if ((name != null) && (!name.isEmpty()))
{ {
if (name.startsWith(URL_PREFIX)) if (name.startsWith(URL_PREFIX))
newName = name.substring(URL_PREFIX.length()); newName = name.substring(URL_PREFIX.length());

View File

@ -148,7 +148,7 @@ public class localContextRoot implements Context
{ {
String firstComponent = cname.get(0); String firstComponent = cname.get(0);
if (firstComponent.equals("")) if (firstComponent.isEmpty())
return this; return this;
Binding binding = __root.getBinding(firstComponent); Binding binding = __root.getBinding(firstComponent);

View File

@ -272,7 +272,7 @@ public class JspcMojo extends AbstractMojo
getLog().info("generatedClasses=" + generatedClasses); getLog().info("generatedClasses=" + generatedClasses);
getLog().info("webXmlFragment=" + webXmlFragment); getLog().info("webXmlFragment=" + webXmlFragment);
getLog().info("webXml=" + webXml); getLog().info("webXml=" + webXml);
getLog().info("insertionMarker=" + (insertionMarker == null || insertionMarker.equals("") ? END_OF_WEBAPP : insertionMarker)); getLog().info("insertionMarker=" + (insertionMarker == null || insertionMarker.isEmpty() ? END_OF_WEBAPP : insertionMarker));
getLog().info("keepSources=" + keepSources); getLog().info("keepSources=" + keepSources);
getLog().info("mergeFragment=" + mergeFragment); getLog().info("mergeFragment=" + mergeFragment);
if (sourceVersion != null) if (sourceVersion != null)
@ -351,7 +351,7 @@ public class JspcMojo extends AbstractMojo
try try
{ {
if (jspFiles == null | jspFiles.equals("")) if (jspFiles == null | jspFiles.isEmpty())
{ {
getLog().info("No files selected to precompile"); getLog().info("No files selected to precompile");
} }
@ -456,7 +456,7 @@ public class JspcMojo extends AbstractMojo
// marker // marker
boolean atInsertPoint = false; boolean atInsertPoint = false;
boolean atEOF = false; boolean atEOF = false;
String marker = (insertionMarker == null || insertionMarker.equals("") ? END_OF_WEBAPP : insertionMarker); String marker = (insertionMarker == null || insertionMarker.isEmpty() ? END_OF_WEBAPP : insertionMarker);
while (!atInsertPoint && !atEOF) while (!atInsertPoint && !atEOF)
{ {
String line = webXmlReader.readLine(); String line = webXmlReader.readLine();

View File

@ -48,7 +48,7 @@ public class NamingEntryUtil
public static boolean bindToENC(Object scope, String asName, String mappedName) public static boolean bindToENC(Object scope, String asName, String mappedName)
throws NamingException throws NamingException
{ {
if (asName == null || asName.trim().equals("")) if (asName == null || asName.trim().isEmpty())
throw new NamingException("No name for NamingEntry"); throw new NamingException("No name for NamingEntry");
if (mappedName == null || "".equals(mappedName)) if (mappedName == null || "".equals(mappedName))

View File

@ -532,12 +532,12 @@ public class PlusDescriptorProcessor extends IterativeDescriptorProcessor
String className = node.getString("lifecycle-callback-class", false, true); String className = node.getString("lifecycle-callback-class", false, true);
String methodName = node.getString("lifecycle-callback-method", false, true); String methodName = node.getString("lifecycle-callback-method", false, true);
if (className == null || className.equals("")) if (className == null || className.isEmpty())
{ {
LOG.warn("No lifecycle-callback-class specified"); LOG.warn("No lifecycle-callback-class specified");
return; return;
} }
if (methodName == null || methodName.equals("")) if (methodName == null || methodName.isEmpty())
{ {
LOG.warn("No lifecycle-callback-method specified for class {}", className); LOG.warn("No lifecycle-callback-method specified for class {}", className);
return; return;
@ -610,12 +610,12 @@ public class PlusDescriptorProcessor extends IterativeDescriptorProcessor
{ {
String className = node.getString("lifecycle-callback-class", false, true); String className = node.getString("lifecycle-callback-class", false, true);
String methodName = node.getString("lifecycle-callback-method", false, true); String methodName = node.getString("lifecycle-callback-method", false, true);
if (className == null || className.equals("")) if (className == null || className.isEmpty())
{ {
LOG.warn("No lifecycle-callback-class specified for pre-destroy"); LOG.warn("No lifecycle-callback-class specified for pre-destroy");
return; return;
} }
if (methodName == null || methodName.equals("")) if (methodName == null || methodName.isEmpty())
{ {
LOG.warn("No lifecycle-callback-method specified for pre-destroy class {}", className); LOG.warn("No lifecycle-callback-method specified for pre-destroy class {}", className);
return; return;
@ -697,12 +697,12 @@ public class PlusDescriptorProcessor extends IterativeDescriptorProcessor
XmlParser.Node injectionNode = itor.next(); XmlParser.Node injectionNode = itor.next();
String targetClassName = injectionNode.getString("injection-target-class", false, true); String targetClassName = injectionNode.getString("injection-target-class", false, true);
String targetName = injectionNode.getString("injection-target-name", false, true); String targetName = injectionNode.getString("injection-target-name", false, true);
if ((targetClassName == null) || targetClassName.equals("")) if ((targetClassName == null) || targetClassName.isEmpty())
{ {
LOG.warn("No classname found in injection-target"); LOG.warn("No classname found in injection-target");
continue; continue;
} }
if ((targetName == null) || targetName.equals("")) if ((targetName == null) || targetName.isEmpty())
{ {
LOG.warn("No field or method name in injection-target"); LOG.warn("No field or method name in injection-target");
continue; continue;

View File

@ -118,9 +118,9 @@ public class JDBCLoginService extends AbstractLoginService
final String userRoleTableUserKey = properties.getProperty("userroletableuserkey"); final String userRoleTableUserKey = properties.getProperty("userroletableuserkey");
final String userRoleTableRoleKey = properties.getProperty("userroletablerolekey"); final String userRoleTableRoleKey = properties.getProperty("userroletablerolekey");
if (_jdbcDriver == null || _jdbcDriver.equals("") || if (_jdbcDriver == null || _jdbcDriver.isEmpty() ||
_url == null || _url.equals("") || _url == null || _url.isEmpty() ||
_userName == null || _userName.equals("") || _userName == null || _userName.isEmpty() ||
_password == null) _password == null)
{ {
LOG.warn("UserRealm {} has not been properly configured", getName()); LOG.warn("UserRealm {} has not been properly configured", getName());

View File

@ -86,7 +86,7 @@ public abstract class BaseHolder<T> extends AbstractLifeCycle implements Dumpabl
throws Exception throws Exception
{ {
//if no class already loaded and no classname, make permanently unavailable //if no class already loaded and no classname, make permanently unavailable
if (_class == null && (_className == null || _className.equals(""))) if (_class == null && (_className == null || _className.isEmpty()))
throw new UnavailableException("No class in holder " + toString()); throw new UnavailableException("No class in holder " + toString());
//try to load class //try to load class

View File

@ -48,7 +48,7 @@ public class IntrospectionUtil
{ {
if (clazz == null) if (clazz == null)
throw new NoSuchMethodException("No class"); throw new NoSuchMethodException("No class");
if (methodName == null || methodName.trim().equals("")) if (methodName == null || methodName.trim().isEmpty())
throw new NoSuchMethodException("No method name"); throw new NoSuchMethodException("No method name");
Method method = null; Method method = null;

View File

@ -175,7 +175,7 @@ public class JarResource extends URLResource
//directory. Remove the name of the subdirectory so //directory. Remove the name of the subdirectory so
//that we don't wind up creating it too. //that we don't wind up creating it too.
entryName = entryName.substring(subEntryName.length()); entryName = entryName.substring(subEntryName.length());
if (!entryName.equals("")) if (!entryName.isEmpty())
{ {
//the entry is //the entry is
shouldExtract = true; shouldExtract = true;

View File

@ -521,7 +521,7 @@ public class XmlParser
for (int i = 0; i < attrs.getLength(); i++) for (int i = 0; i < attrs.getLength(); i++)
{ {
String name = attrs.getLocalName(i); String name = attrs.getLocalName(i);
if (name == null || name.equals("")) if (name == null || name.isEmpty())
name = attrs.getQName(i); name = attrs.getQName(i);
_attrs[i] = new Attribute(name, attrs.getValue(i)); _attrs[i] = new Attribute(name, attrs.getValue(i));
} }

View File

@ -88,7 +88,7 @@ public class HttpTesting
if (parsingHeader) if (parsingHeader)
{ {
if (line.equals("")) if (line.isEmpty())
{ {
parsingHeader = false; parsingHeader = false;
continue; continue;