@@ -143,7 +143,7 @@ public class ReportUsage { | |||
appendUserAgentProperty(extra, "os.name"); | |||
appendUserAgentProperty(extra, "os.version"); | |||
if (extra.length() > 0) { | |||
if (extra.length() != 0) { | |||
userAgent += " (" + extra.toString() + ")"; | |||
} | |||
@@ -154,7 +154,7 @@ public class ReportUsage { | |||
String propName) { | |||
String propValue = System.getProperty(propName); | |||
if (propValue != null) { | |||
if (sb.length() > 0) { | |||
if (sb.length() != 0) { | |||
sb.append(';').append(' '); | |||
} | |||
sb.append(propName); |
@@ -331,7 +331,7 @@ public class JavaScriptConnectorHelper { | |||
} | |||
private ServerConnector getConnector(String connectorId) { | |||
if (connectorId == null || connectorId.length() == 0) { | |||
if (connectorId == null || connectorId.isEmpty()) { | |||
return connector; | |||
} | |||
@@ -364,7 +364,7 @@ public class JavaScriptConnectorHelper { | |||
// TODO Resolve conflicts using argument count and types | |||
String interfaceList = ""; | |||
for (String iface : interfaces) { | |||
if (interfaceList.length() != 0) { | |||
if (!interfaceList.isEmpty()) { | |||
interfaceList += ", "; | |||
} | |||
interfaceList += getJsInterfaceName(iface); |
@@ -141,7 +141,7 @@ public class ResourceLoader { | |||
for (int i = 0; i < scripts.getLength(); i++) { | |||
ScriptElement element = ScriptElement.as(scripts.getItem(i)); | |||
String src = element.getSrc(); | |||
if (src != null && src.length() != 0) { | |||
if (src != null && !src.isEmpty()) { | |||
loadedResources.add(src); | |||
} | |||
} | |||
@@ -152,11 +152,11 @@ public class ResourceLoader { | |||
String rel = linkElement.getRel(); | |||
String href = linkElement.getHref(); | |||
if ("stylesheet".equalsIgnoreCase(rel) && href != null | |||
&& href.length() != 0) { | |||
&& !href.isEmpty()) { | |||
loadedResources.add(href); | |||
} | |||
if ("import".equalsIgnoreCase(rel) && href != null | |||
&& href.length() != 0) { | |||
&& !href.isEmpty()) { | |||
loadedResources.add(href); | |||
} | |||
} |
@@ -49,7 +49,7 @@ public class VErrorMessage extends FlowPanel { | |||
public void updateMessage(String htmlErrorMessage) { | |||
clear(); | |||
if (htmlErrorMessage == null || htmlErrorMessage.length() == 0) { | |||
if (htmlErrorMessage == null || htmlErrorMessage.isEmpty()) { | |||
add(new HTML(" ")); | |||
} else { | |||
// pre-formatted on the server as div per child |
@@ -934,7 +934,7 @@ public class WidgetUtil { | |||
public static void forceWebkitRedraw(Element element) { | |||
Style style = element.getStyle(); | |||
String s = style.getProperty("webkitTransform"); | |||
if (s == null || s.length() == 0) { | |||
if (s == null || s.isEmpty()) { | |||
style.setProperty("webkitTransform", "scale(1)"); | |||
} else { | |||
style.setProperty("webkitTransform", ""); |
@@ -42,9 +42,9 @@ public class SelectorPredicate { | |||
} | |||
/** | |||
* Generate a list of predicates from a single predicate string | |||
* Generates a list of predicates from a single predicate string. | |||
* | |||
* @param str | |||
* @param path | |||
* a comma separated string of predicates | |||
* @return a List of Predicate objects | |||
*/ | |||
@@ -52,7 +52,7 @@ public class SelectorPredicate { | |||
List<SelectorPredicate> predicates = new ArrayList<>(); | |||
String predicateStr = extractPredicateString(path); | |||
if (null == predicateStr || predicateStr.length() == 0) { | |||
if (null == predicateStr || predicateStr.isEmpty()) { | |||
return predicates; | |||
} | |||
@@ -424,7 +424,7 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { | |||
ComponentConnector root, Element actualRoot) { | |||
String[] pathComponents = path.split(SUBPART_SEPARATOR); | |||
List<ComponentConnector> connectors; | |||
if (pathComponents[0].length() > 0) { | |||
if (!pathComponents[0].isEmpty()) { | |||
connectors = findConnectorsByPath(pathComponents[0], | |||
Arrays.asList(root)); | |||
} else { |
@@ -273,7 +273,7 @@ public class GridDropTargetConnector extends DropTargetExtensionConnector { | |||
if ("thead".equalsIgnoreCase(parentTagName)) { | |||
// for empty grid or ON_TOP mode, drop as last row, | |||
// otherwise as above first visible row | |||
if (visibleRowRange.length() == 0 | |||
if (visibleRowRange.isEmpty() | |||
|| getState().dropMode == DropMode.ON_TOP) { | |||
return tableWrapper; | |||
} else { | |||
@@ -283,7 +283,7 @@ public class GridDropTargetConnector extends DropTargetExtensionConnector { | |||
} else if ("tfoot".equalsIgnoreCase(parentTagName)) { | |||
// for empty grid or ON_TOP mode, drop as last row, | |||
// otherwise as below last visible row | |||
if (visibleRowRange.length() == 0 | |||
if (visibleRowRange.isEmpty() | |||
|| getState().dropMode == DropMode.ON_TOP) { | |||
return tableWrapper; | |||
} else { | |||
@@ -299,7 +299,7 @@ public class GridDropTargetConnector extends DropTargetExtensionConnector { | |||
// the drag is on top of the tablewrapper | |||
// if no rows in grid, or if the drop mode is ON_TOP, then there is no | |||
// target row for the drop | |||
if (visibleRowRange.length() == 0 | |||
if (visibleRowRange.isEmpty() | |||
|| getState().dropMode == DropMode.ON_TOP) { | |||
return tableWrapper; | |||
} else { // if dragged under the last row to empty space, drop target |
@@ -376,13 +376,13 @@ public class VAccordion extends VTabsheetBase { | |||
* Updates a tabs stylename from the child UIDL | |||
* | |||
* @param uidl | |||
* The child uidl of the tab | |||
* The child UIDL of the tab | |||
*/ | |||
private void updateTabStyleName(String newStyleName) { | |||
if (newStyleName != null && newStyleName.length() != 0) { | |||
if (newStyleName != null && !newStyleName.isEmpty()) { | |||
if (!newStyleName.equals(styleName)) { | |||
// If we have a new style name | |||
if (styleName != null && styleName.length() != 0) { | |||
if (styleName != null && !styleName.isEmpty()) { | |||
// Remove old style name if present | |||
removeStyleDependentName(styleName); | |||
} |
@@ -124,7 +124,7 @@ public class VCheckBoxGroup extends FocusableFlowPanelComposite | |||
} | |||
String iconUrl = item.getString(ListingJsonConstants.JSONKEY_ITEM_ICON); | |||
if (iconUrl != null && iconUrl.length() != 0) { | |||
if (iconUrl != null && !iconUrl.isEmpty()) { | |||
Icon icon = client.getIcon(iconUrl); | |||
itemHtml = icon.getElement().getString() + itemHtml; | |||
} |
@@ -1287,7 +1287,7 @@ public class VComboBox extends Composite implements Field, KeyDownHandler, | |||
String height = getElement().getStyle().getHeight(); | |||
String preferredHeight = getPreferredHeight(pageLength); | |||
return !(height == null || height.length() == 0 | |||
return !(height == null || height.isEmpty() | |||
|| height.equals(preferredHeight)); | |||
} | |||
@@ -2038,7 +2038,7 @@ public class VComboBox extends Composite implements Field, KeyDownHandler, | |||
if (selectedItemIcon != null) { | |||
panel.remove(selectedItemIcon); | |||
} | |||
if (iconUri == null || iconUri.length() == 0) { | |||
if (iconUri == null || iconUri.isEmpty()) { | |||
if (selectedItemIcon != null) { | |||
selectedItemIcon = null; | |||
afterSelectedItemIconChange(); | |||
@@ -2422,7 +2422,7 @@ public class VComboBox extends Composite implements Field, KeyDownHandler, | |||
for (ComboBoxSuggestion suggestion : currentSuggestions) { | |||
// Collect captions so we can calculate minimum width for | |||
// textarea | |||
if (captions.length() > 0) { | |||
if (!captions.isEmpty()) { | |||
captions += "|"; | |||
} | |||
captions += WidgetUtil | |||
@@ -2658,7 +2658,7 @@ public class VComboBox extends Composite implements Field, KeyDownHandler, | |||
@Override | |||
public void setWidth(String width) { | |||
super.setWidth(width); | |||
if (width.length() != 0) { | |||
if (!width.isEmpty()) { | |||
tb.setWidth("100%"); | |||
} | |||
} |
@@ -98,15 +98,15 @@ public class VLink extends HTML implements ClickHandler, HasEnabled { | |||
} | |||
if (targetWidth > 0) { | |||
features += (features.length() > 0 ? "," : "") + "width=" | |||
features += (features.isEmpty() ? "" : ",") + "width=" | |||
+ targetWidth; | |||
} | |||
if (targetHeight > 0) { | |||
features += (features.length() > 0 ? "," : "") + "height=" | |||
features += (features.isEmpty() ? "" : ",") + "height=" | |||
+ targetHeight; | |||
} | |||
if (features.length() > 0) { | |||
if (!features.isEmpty()) { | |||
// if 'special features' are set, use window.open(), unless | |||
// a modifier key is held (ctrl to open in new tab etc) | |||
Event e = DOM.eventGetCurrentEvent(); |
@@ -247,7 +247,7 @@ public class VNotification extends VOverlay { | |||
removeStyleDependentName(temporaryStyle); | |||
temporaryStyle = null; | |||
} | |||
if (style != null && style.length() > 0) { | |||
if (style != null && !style.isEmpty()) { | |||
temporaryStyle = style; | |||
addStyleName(style); | |||
addStyleDependentName(style); | |||
@@ -635,7 +635,7 @@ public class VNotification extends VOverlay { | |||
html.append("</p>"); | |||
} | |||
if (html.length() > 0) { | |||
if (html.length() != 0) { | |||
// Add error description | |||
if (details != null) { |
@@ -143,7 +143,7 @@ public class VRadioButtonGroup extends FocusableFlowPanelComposite | |||
} | |||
String iconUrl = item.getString(ListingJsonConstants.JSONKEY_ITEM_ICON); | |||
if (iconUrl != null && iconUrl.length() != 0) { | |||
if (iconUrl != null && !iconUrl.isEmpty()) { | |||
Icon icon = client.getIcon(iconUrl); | |||
itemHtml = icon.getElement().getString() + itemHtml; | |||
} |
@@ -332,7 +332,7 @@ public class VUpload extends SimplePanel { | |||
VConsole.log("Submit cancelled (disabled or already submitted)"); | |||
return; | |||
} | |||
if (fu.getFilename().length() == 0) { | |||
if (fu.getFilename().isEmpty()) { | |||
VConsole.log("Submitting empty selection (no file)"); | |||
} | |||
// flush possibly pending variable changes, so they will be handled |
@@ -1204,7 +1204,7 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, | |||
// Override PopupPanel which sets the width to the contents | |||
getElement().getStyle().setProperty("width", width); | |||
// Update v-has-width in case undefined window is resized | |||
setStyleName("v-has-width", width != null && width.length() > 0); | |||
setStyleName("v-has-width", width != null && !width.isEmpty()); | |||
} | |||
@Override | |||
@@ -1212,7 +1212,7 @@ public class VWindow extends VOverlay implements ShortcutActionHandlerOwner, | |||
// Override PopupPanel which sets the height to the contents | |||
getElement().getStyle().setProperty("height", height); | |||
// Update v-has-height in case undefined window is resized | |||
setStyleName("v-has-height", height != null && height.length() > 0); | |||
setStyleName("v-has-height", height != null && !height.isEmpty()); | |||
} | |||
private void onDragEvent(Event event) { |
@@ -615,7 +615,7 @@ public class LayoutDependencyTree { | |||
} | |||
private static String getSizeDefinition(String size) { | |||
if (size == null || size.length() == 0) { | |||
if (size == null || size.isEmpty()) { | |||
return "undefined"; | |||
} else if (size.endsWith("%")) { | |||
return "relative"; |
@@ -252,7 +252,7 @@ public class WindowConnector extends AbstractSingleComponentContainerConnector | |||
childStyle.setPosition(Position.ABSOLUTE); | |||
Style wrapperStyle = contentElement.getStyle(); | |||
if (window.getElement().getStyle().getWidth().length() == 0 | |||
if (window.getElement().getStyle().getWidth().isEmpty() | |||
&& !content.isRelativeWidth()) { | |||
/* | |||
* Need to lock width to make undefined width work even with |
@@ -56,7 +56,7 @@ public class ApplicationConnectionURLGenerationTest { | |||
SharedUtil.addGetParameters(URIS[i], "a=b&c=d")); | |||
// Fragments | |||
if (URIS_WITH_ABCD_PARAM_AND_FRAGMENT[i].length() > 0) { | |||
if (!URIS_WITH_ABCD_PARAM_AND_FRAGMENT[i].isEmpty()) { | |||
assertEquals(URIS_WITH_ABCD_PARAM_AND_FRAGMENT[i], SharedUtil | |||
.addGetParameters(URIS[i] + "#fragment", "a=b&c=d")); | |||
@@ -1339,7 +1339,7 @@ public class VFilterSelect extends Composite | |||
String height = getElement().getStyle().getHeight(); | |||
String preferredHeight = getPreferredHeight(pageLength); | |||
return !(height == null || height.length() == 0 | |||
return !(height == null || height.isEmpty() | |||
|| height.equals(preferredHeight)); | |||
} | |||
@@ -1916,7 +1916,7 @@ public class VFilterSelect extends Composite | |||
*/ | |||
public void setSelectedItemIcon(String iconUri) { | |||
if (iconUri == null || iconUri.length() == 0) { | |||
if (iconUri == null || iconUri.isEmpty()) { | |||
if (selectedItemIcon != null) { | |||
panel.remove(selectedItemIcon); | |||
selectedItemIcon = null; | |||
@@ -2302,7 +2302,7 @@ public class VFilterSelect extends Composite | |||
for (FilterSelectSuggestion suggestion : currentSuggestions) { | |||
// Collect captions so we can calculate minimum width for | |||
// textarea | |||
if (captions.length() > 0) { | |||
if (!captions.isEmpty()) { | |||
captions += "|"; | |||
} | |||
captions += WidgetUtil | |||
@@ -2549,7 +2549,7 @@ public class VFilterSelect extends Composite | |||
@Override | |||
public void setWidth(String width) { | |||
super.setWidth(width); | |||
if (width.length() != 0) { | |||
if (!width.isEmpty()) { | |||
tb.setWidth("100%"); | |||
} | |||
} |
@@ -143,7 +143,7 @@ public class VOptionGroup extends VOptionGroupBase | |||
} | |||
String iconUrl = opUidl.getStringAttribute("icon"); | |||
if (iconUrl != null && iconUrl.length() != 0) { | |||
if (iconUrl != null && !iconUrl.isEmpty()) { | |||
Icon icon = client.getIcon(iconUrl); | |||
itemHtml = icon.getElement().getString() + itemHtml; | |||
} | |||
@@ -162,7 +162,7 @@ public class VOptionGroup extends VOptionGroupBase | |||
op = new RadioButton(paintableId); | |||
op.setStyleName("v-radiobutton"); | |||
} | |||
if (iconUrl != null && iconUrl.length() != 0) { | |||
if (iconUrl != null && !iconUrl.isEmpty()) { | |||
WidgetUtil.sinkOnloadForImages(op.getElement()); | |||
op.addHandler(iconLoadHandler, LoadEvent.getType()); | |||
} |
@@ -7256,8 +7256,8 @@ public class VScrollTable extends FlowPanel | |||
@Override | |||
public void setHeight(String height) { | |||
if (height.length() == 0 | |||
&& getElement().getStyle().getHeight().length() != 0) { | |||
if (height.isEmpty() | |||
&& !getElement().getStyle().getHeight().isEmpty()) { | |||
/* | |||
* Changing from defined to undefined size -> should do a size init | |||
* to take page length into account again |
@@ -314,7 +314,7 @@ public class VUpload extends SimplePanel { | |||
VConsole.log("Submit cancelled (disabled or already submitted)"); | |||
return; | |||
} | |||
if (fu.getFilename().length() == 0) { | |||
if (fu.getFilename().isEmpty()) { | |||
VConsole.log("Submitting empty selection (no file)"); | |||
} | |||
// flush possibly pending variable changes, so they will be handled |
@@ -91,7 +91,7 @@ public class DateCellDayEvent extends FocusableHTML | |||
weekGrid = parent; | |||
Style s = getElement().getStyle(); | |||
if (event.getStyleName().length() > 0) { | |||
if (!event.getStyleName().isEmpty()) { | |||
addStyleDependentName(event.getStyleName()); | |||
} | |||
s.setPosition(Position.ABSOLUTE); |
@@ -283,7 +283,7 @@ public class SimpleDayCell extends FocusableFlowPanel implements MouseUpHandler, | |||
eventDiv.setTimeSpecificEvent(false); | |||
Date from = e.getStart(); | |||
Date to = e.getEnd(); | |||
if (e.getStyleName().length() > 0) { | |||
if (!e.getStyleName().isEmpty()) { | |||
eventDiv.addStyleName("month-event " + e.getStyleName()); | |||
} else { | |||
eventDiv.addStyleName("month-event"); |
@@ -98,7 +98,7 @@ public class WeeklyLongEvents extends HorizontalPanel implements HasTooltipKey { | |||
eventLabel.addStyleDependentName("continued-to"); | |||
} | |||
final String extraStyle = calendarEvent.getStyleName(); | |||
if (extraStyle != null && extraStyle.length() > 0) { | |||
if (extraStyle != null && !extraStyle.isEmpty()) { | |||
eventLabel.addStyleDependentName(extraStyle + "-all-day"); | |||
} | |||
if (!started) { |
@@ -136,7 +136,7 @@ public interface Validator extends Serializable { | |||
*/ | |||
public boolean isInvisible() { | |||
String msg = getMessage(); | |||
if (msg != null && msg.length() > 0) { | |||
if (msg != null && !msg.isEmpty()) { | |||
return false; | |||
} | |||
if (causes != null) { |
@@ -146,7 +146,7 @@ public class NestedMethodProperty<T> extends AbstractProperty<T> { | |||
} | |||
for (int i = 0; i < simplePropertyNames.length; i++) { | |||
String simplePropertyName = simplePropertyNames[i].trim(); | |||
if (simplePropertyName.length() > 0) { | |||
if (!simplePropertyName.isEmpty()) { | |||
lastSimplePropertyName = simplePropertyName; | |||
lastClass = propertyClass; | |||
try { |
@@ -187,7 +187,7 @@ public class StringToCollectionConverter | |||
} | |||
builder.append(delimiter); | |||
} | |||
if (builder.length() > 0) { | |||
if (builder.length() != 0) { | |||
return builder.substring(0, builder.length() - delimiter.length()); | |||
} else { | |||
return builder.toString(); |
@@ -73,7 +73,7 @@ public class RowId implements Serializable { | |||
builder.append(id); | |||
builder.append('/'); | |||
} | |||
if (builder.length() > 0) { | |||
if (builder.length() != 0) { | |||
return builder.substring(0, builder.length() - 1); | |||
} | |||
return builder.toString(); |
@@ -267,7 +267,7 @@ public class FreeformQuery extends AbstractTransactionalQuery | |||
StatementHelper sh = ((FreeformStatementDelegate) delegate) | |||
.getCountStatement(); | |||
if (sh != null && sh.getQueryString() != null | |||
&& sh.getQueryString().length() > 0) { | |||
&& !sh.getQueryString().isEmpty()) { | |||
return true; | |||
} | |||
} catch (UnsupportedOperationException e) { | |||
@@ -276,7 +276,7 @@ public class FreeformQuery extends AbstractTransactionalQuery | |||
} | |||
try { | |||
String queryString = delegate.getQueryString(0, 50); | |||
return queryString != null && queryString.length() > 0; | |||
return queryString != null && !queryString.isEmpty(); | |||
} catch (UnsupportedOperationException e) { | |||
return false; | |||
} |
@@ -465,7 +465,7 @@ public abstract class AbstractSelect extends AbstractField<Object> implements | |||
// New option entered (and it is allowed) | |||
if (isNewItemsAllowed()) { | |||
final String newitem = (String) variables.get("newitem"); | |||
if (newitem != null && newitem.length() > 0) { | |||
if (newitem != null && !newitem.isEmpty()) { | |||
getNewItemHandler().addNewItem(newitem); | |||
} | |||
} |
@@ -327,7 +327,7 @@ public abstract class AbstractTextField extends AbstractField<String> implements | |||
@Override | |||
public boolean isEmpty() { | |||
return super.isEmpty() || getValue().length() == 0; | |||
return super.isEmpty() || getValue().isEmpty(); | |||
} | |||
/** |
@@ -1825,7 +1825,7 @@ public class Calendar extends AbstractLegacyComponent | |||
@Override | |||
public void weekClick(String event) { | |||
if (event.length() > 0 && event.contains("w")) { | |||
if (!event.isEmpty() && event.contains("w")) { | |||
String[] splitted = event.split("w"); | |||
if (splitted.length == 2) { | |||
try { |
@@ -188,7 +188,7 @@ public class ComboBox extends AbstractSelect | |||
} | |||
private boolean isFilteringNeeded() { | |||
return filterstring != null && filterstring.length() > 0 | |||
return filterstring != null && !filterstring.isEmpty() | |||
&& filteringMode != FilteringMode.OFF; | |||
} | |||
@@ -762,7 +762,7 @@ public class ComboBox extends AbstractSelect | |||
} else if (isNewItemsAllowed()) { | |||
// New option entered (and it is allowed) | |||
final String newitem = (String) variables.get("newitem"); | |||
if (newitem != null && newitem.length() > 0) { | |||
if (newitem != null && !newitem.isEmpty()) { | |||
getNewItemHandler().addNewItem(newitem); | |||
// rebuild list | |||
filterstring = null; |
@@ -294,7 +294,7 @@ public class RichTextArea extends AbstractField<String> | |||
@Override | |||
public boolean isEmpty() { | |||
return super.isEmpty() || getValue().length() == 0; | |||
return super.isEmpty() || getValue().isEmpty(); | |||
} | |||
@Override |
@@ -129,7 +129,7 @@ public abstract class AbstractErrorMessage implements ErrorMessage { | |||
sb.append("</div>\n"); | |||
} | |||
} | |||
if (sb.length() > 0) { | |||
if (sb.length() != 0) { | |||
result = sb.toString(); | |||
} | |||
} |
@@ -659,7 +659,7 @@ public abstract class BootstrapHandler extends SynchronizedRequestHandler { | |||
mainDiv.addClass(context.getThemeName()); | |||
mainDiv.addClass(context.getUIClass().getSimpleName() | |||
.toLowerCase(Locale.ENGLISH)); | |||
if (style != null && style.length() != 0) { | |||
if (style != null && !style.isEmpty()) { | |||
mainDiv.attr("style", style); | |||
} | |||
mainDiv.appendElement("div").addClass("v-app-loading"); |
@@ -78,7 +78,7 @@ public abstract class LegacyApplicationUIProvider extends UIProvider { | |||
VaadinRequest request = event.getRequest(); | |||
String pathInfo = request.getPathInfo(); | |||
String name = null; | |||
if (pathInfo != null && pathInfo.length() > 0) { | |||
if (pathInfo != null && !pathInfo.isEmpty()) { | |||
Matcher matcher = WINDOW_NAME_PATTERN.matcher(pathInfo); | |||
if (matcher.matches()) { | |||
// Skip the initial slash |
@@ -203,7 +203,7 @@ public class Page implements Serializable { | |||
private void paintContent(PaintTarget target) throws PaintException { | |||
target.startTag("open"); | |||
target.addAttribute("src", resource); | |||
if (name != null && name.length() > 0) { | |||
if (name != null && !name.isEmpty()) { | |||
target.addAttribute("name", name); | |||
} | |||
if (!tryToOpenAsPopup) { |
@@ -98,7 +98,7 @@ public class SizeWithUnit implements Serializable { | |||
unit = Unit.PIXELS; | |||
} else { | |||
String symbol = matcher.group(2); | |||
if ((symbol != null && symbol.length() > 0) | |||
if ((symbol != null && !symbol.isEmpty()) | |||
|| defaultUnit == null) { | |||
unit = Unit.getUnitFromSymbol(symbol); | |||
} else { |
@@ -45,7 +45,7 @@ public class ThemeResource implements Resource { | |||
if (resourceId == null) { | |||
throw new NullPointerException("Resource ID must not be null"); | |||
} | |||
if (resourceId.length() == 0) { | |||
if (resourceId.isEmpty()) { | |||
throw new IllegalArgumentException("Resource ID can not be empty"); | |||
} | |||
if (resourceId.charAt(0) == '/') { |
@@ -1412,7 +1412,7 @@ public class VaadinServlet extends HttpServlet implements Constants { | |||
servletPath = request.getContextPath() + request.getServletPath(); | |||
} | |||
if (servletPath.length() == 0 | |||
if (servletPath.isEmpty() | |||
|| servletPath.charAt(servletPath.length() - 1) != '/') { | |||
servletPath += "/"; | |||
} |
@@ -476,7 +476,7 @@ public abstract class AbstractOrderedLayout extends AbstractLayout | |||
// handle expand ratio | |||
if (attr.hasKey(":expand")) { | |||
String value = attr.get(":expand"); | |||
if (value.length() > 0) { | |||
if (!value.isEmpty()) { | |||
try { | |||
float ratio = Float.valueOf(value); | |||
setExpandRatio(newChild, ratio); |
@@ -155,7 +155,7 @@ public class ComboBox<T> extends AbstractSingleSelect<T> | |||
public void createNewItem(String itemValue) { | |||
// New option entered | |||
if (getNewItemHandler() != null && itemValue != null | |||
&& itemValue.length() > 0) { | |||
&& !itemValue.isEmpty()) { | |||
getNewItemHandler().accept(itemValue); | |||
} | |||
} |
@@ -307,7 +307,7 @@ public class CustomLayout extends AbstractLayout implements LegacyComponent { | |||
// Workaround to make the CommunicationManager read the template file | |||
// and send it to the client | |||
String templateName = getState(false).templateName; | |||
if (templateName != null && templateName.length() != 0) { | |||
if (templateName != null && !templateName.isEmpty()) { | |||
Set<Object> usedResources = ((JsonPaintTarget) target) | |||
.getUsedResources(); | |||
String resourceName = "layouts/" + templateName + ".html"; |
@@ -139,7 +139,7 @@ public class MenuBar extends AbstractComponent | |||
} | |||
String description = item.getDescription(); | |||
if (description != null && description.length() > 0) { | |||
if (description != null && !description.isEmpty()) { | |||
target.addAttribute(MenuBarConstants.ATTRIBUTE_ITEM_DESCRIPTION, | |||
description); | |||
} |
@@ -327,7 +327,7 @@ public class DesignAttributeHandler implements Serializable { | |||
String[] words = propertyName.split("(?<!^)(?=[A-Z])"); | |||
StringBuilder builder = new StringBuilder(); | |||
for (int i = 0; i < words.length; i++) { | |||
if (builder.length() > 0) { | |||
if (builder.length() != 0) { | |||
builder.append("-"); | |||
} | |||
builder.append(words[i].toLowerCase()); |
@@ -530,7 +530,7 @@ public class DesignContext implements Serializable { | |||
// global id: only update the mapping, the id has already been set for | |||
// the component | |||
String id = component.getId(); | |||
if (id != null && id.length() > 0) { | |||
if (id != null && !id.isEmpty()) { | |||
boolean mappingExists = mapId(id, component); | |||
if (mappingExists) { | |||
throw new DesignException( |
@@ -176,7 +176,7 @@ public class FieldBinder implements Serializable { | |||
try { | |||
// create and validate field name | |||
String fieldName = asFieldName(identifier); | |||
if (fieldName.length() == 0) { | |||
if (fieldName.isEmpty()) { | |||
return false; | |||
} | |||
// validate that the field can be found | |||
@@ -231,7 +231,7 @@ public class FieldBinder implements Serializable { | |||
} | |||
} | |||
// lowercase first letter | |||
if (result.length() > 0 && Character.isLetter(result.charAt(0))) { | |||
if (result.length() != 0 && Character.isLetter(result.charAt(0))) { | |||
result.setCharAt(0, Character.toLowerCase(result.charAt(0))); | |||
} | |||
return result.toString(); |
@@ -123,7 +123,7 @@ public class DesignShortcutActionConverter | |||
@Override | |||
public Result<ShortcutAction> convertToModel(String value, | |||
ValueContext context) { | |||
if (value.length() == 0) { | |||
if (value.isEmpty()) { | |||
return Result.ok(null); | |||
} | |||
@@ -69,6 +69,6 @@ public class CompileTransitionPropertyTest { | |||
// Only whitespace should remain after removing the style rules | |||
modifiedStyle = modifiedStyle.replaceAll("(\\s)", ""); | |||
assertTrue("Unexpected style rules for .my-label: " + modifiedStyle, | |||
modifiedStyle.length() == 0); | |||
modifiedStyle.isEmpty()); | |||
} | |||
} |
@@ -235,7 +235,7 @@ public class SharedUtil implements Serializable { | |||
* @return The modified URI with the get parameters in extraParams added. | |||
*/ | |||
public static String addGetParameters(String uri, String extraParams) { | |||
if (extraParams == null || extraParams.length() == 0) { | |||
if (extraParams == null || extraParams.isEmpty()) { | |||
return uri; | |||
} | |||
// RFC 3986: The query component is indicated by the first question |
@@ -119,7 +119,7 @@ public class Parameters extends com.vaadin.server.LegacyApplication | |||
final String[] values = entry.getValue(); | |||
String v = ""; | |||
for (int j = 0; j < values.length; j++) { | |||
if (v.length() > 0) { | |||
if (!v.isEmpty()) { | |||
v += ", "; | |||
} | |||
v += "'" + values[j] + "'"; |
@@ -76,11 +76,11 @@ public class TestForContainerFilterable extends CustomComponent { | |||
@Override | |||
public void buttonClick(ClickEvent event) { | |||
ic.removeAllContainerFilters(); | |||
if (fooFilter.getValue().length() > 0) { | |||
if (!fooFilter.getValue().isEmpty()) { | |||
ic.addContainerFilter("foo", fooFilter.getValue(), false, | |||
false); | |||
} | |||
if (barFilter.getValue().length() > 0) { | |||
if (!barFilter.getValue().isEmpty()) { | |||
ic.addContainerFilter("bar", barFilter.getValue(), true, | |||
true); | |||
} |
@@ -52,7 +52,7 @@ public class OrderedLayoutCases extends AbstractReindeerTestUI { | |||
public void valueChange(ValueChangeEvent event) { | |||
String value = event.getProperty().getValue() | |||
.toString(); | |||
if (value.length() == 0) { | |||
if (value.isEmpty()) { | |||
setCaption(null); | |||
} else if (value.equals("Long")) { | |||
setCaption( |
@@ -57,7 +57,7 @@ public class TextFieldRelativeWidth extends AbstractReindeerTestUI { | |||
Object itemId = idc.addItemAt(size - 1); | |||
Item newItem = idc.getItem(itemId); | |||
TextField tf = new TextField(); | |||
if (inputPrompt != null && inputPrompt.length() > 0) { | |||
if (inputPrompt != null && !inputPrompt.isEmpty()) { | |||
tf.setInputPrompt(inputPrompt); | |||
} | |||
tf.setWidth("100%"); | |||
@@ -70,7 +70,7 @@ public class TextFieldRelativeWidth extends AbstractReindeerTestUI { | |||
newItem = idc.getItem(itemId); | |||
tf = new TextField(); | |||
if (inputPromptChild != null && inputPromptChild.length() > 0) { | |||
if (inputPromptChild != null && !inputPromptChild.isEmpty()) { | |||
tf.setInputPrompt(inputPromptChild); | |||
} | |||
tf.setWidth("100%"); |
@@ -110,7 +110,7 @@ public class TextChangeEvents extends AbstractTestUIWithLog { | |||
} | |||
private String findMatch(String currentTextContent) { | |||
if (currentTextContent.length() > 0) { | |||
if (!currentTextContent.isEmpty()) { | |||
for (int i = 0; i < names.length; i++) { | |||
if (names[i].startsWith(currentTextContent)) { | |||
return names[i]; |
@@ -78,7 +78,7 @@ public class TextFieldWithPropertyFormatter extends TestBase { | |||
@Override | |||
public BigDecimal parse(String formattedValue) throws Exception { | |||
if (formattedValue != null | |||
&& formattedValue.trim().length() != 0) { | |||
&& !formattedValue.trim().isEmpty()) { | |||
BigDecimal value = (BigDecimal) df.parse(formattedValue); | |||
value = value.setScale(2, BigDecimal.ROUND_HALF_UP); | |||
return value; |
@@ -138,7 +138,7 @@ public class TextFieldsValueChangeMode extends AbstractTestUIWithLog { | |||
} | |||
private String findMatch(String currentTextContent) { | |||
if (currentTextContent.length() > 0) { | |||
if (!currentTextContent.isEmpty()) { | |||
for (int i = 0; i < names.length; i++) { | |||
if (names[i].startsWith(currentTextContent)) { | |||
return names[i]; |
@@ -220,7 +220,7 @@ public abstract class BaseLayoutTestUI extends AbstractReindeerTestUI { | |||
comp.setIcon(ICONS[i]); | |||
} | |||
if (ErrorMessage != null) { | |||
if (ErrorMessage.length() == 0) { | |||
if (ErrorMessage.isEmpty()) { | |||
comp.setComponentError(new UserError(null)); | |||
} else { | |||
comp.setComponentError(new UserError(ErrorMessage)); |
@@ -35,7 +35,7 @@ public class MyPickerWidget extends ComplexPanel { | |||
} | |||
public void setButtonText(String buttonText, boolean adjustSpace) { | |||
if (buttonText == null || buttonText.length() == 0) { | |||
if (buttonText == null || buttonText.isEmpty()) { | |||
buttonText = "..."; | |||
} | |||
button.setText(buttonText); |
@@ -153,7 +153,7 @@ public class CommonParts extends VerticalLayout implements View { | |||
title.setPlaceholder("Title for the notification"); | |||
title.addValueChangeListener(event -> { | |||
if (title.getValue() == null | |||
|| title.getValue().length() == 0) { | |||
|| title.getValue().isEmpty()) { | |||
notification.setCaption(null); | |||
} else { | |||
notification.setCaption(title.getValue()); | |||
@@ -167,7 +167,7 @@ public class CommonParts extends VerticalLayout implements View { | |||
description.addStyleName(ValoTheme.TEXTAREA_SMALL); | |||
description.addValueChangeListener(listener -> { | |||
if (description.getValue() == null | |||
|| description.getValue().length() == 0) { | |||
|| description.getValue().isEmpty()) { | |||
notification.setDescription(null); | |||
} else { | |||
notification.setDescription(description.getValue()); | |||
@@ -218,11 +218,11 @@ public class CommonParts extends VerticalLayout implements View { | |||
+ item.getText().toLowerCase(); | |||
} | |||
} | |||
if (styleString.trim().length() > 0) { | |||
if (!styleString.trim().isEmpty()) { | |||
notification.setStyleName( | |||
(typeString + " " + styleString.trim()) | |||
.trim()); | |||
} else if (typeString.length() > 0) { | |||
} else if (!typeString.isEmpty()) { | |||
notification.setStyleName(typeString.trim()); | |||
} else { | |||
notification.setStyleName(null); |
@@ -122,7 +122,7 @@ public class TextChangeEvents extends TestBase { | |||
} | |||
private String findMatch(String currentTextContent) { | |||
if (currentTextContent.length() > 0) { | |||
if (!currentTextContent.isEmpty()) { | |||
for (int i = 0; i < names.length; i++) { | |||
if (names[i].startsWith(currentTextContent)) { | |||
return names[i]; |