Browse Source

Use String.isEmpty() (#10045)

tags/8.2.0.alpha2
Ahmed Ashour 6 years ago
parent
commit
867006d2f8
64 changed files with 94 additions and 94 deletions
  1. 2
    2
      client-compiler/src/main/java/com/vaadin/tools/ReportUsage.java
  2. 2
    2
      client/src/main/java/com/vaadin/client/JavaScriptConnectorHelper.java
  3. 3
    3
      client/src/main/java/com/vaadin/client/ResourceLoader.java
  4. 1
    1
      client/src/main/java/com/vaadin/client/VErrorMessage.java
  5. 1
    1
      client/src/main/java/com/vaadin/client/WidgetUtil.java
  6. 3
    3
      client/src/main/java/com/vaadin/client/componentlocator/SelectorPredicate.java
  7. 1
    1
      client/src/main/java/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java
  8. 3
    3
      client/src/main/java/com/vaadin/client/connectors/grid/GridDropTargetConnector.java
  9. 3
    3
      client/src/main/java/com/vaadin/client/ui/VAccordion.java
  10. 1
    1
      client/src/main/java/com/vaadin/client/ui/VCheckBoxGroup.java
  11. 4
    4
      client/src/main/java/com/vaadin/client/ui/VComboBox.java
  12. 3
    3
      client/src/main/java/com/vaadin/client/ui/VLink.java
  13. 2
    2
      client/src/main/java/com/vaadin/client/ui/VNotification.java
  14. 1
    1
      client/src/main/java/com/vaadin/client/ui/VRadioButtonGroup.java
  15. 1
    1
      client/src/main/java/com/vaadin/client/ui/VUpload.java
  16. 2
    2
      client/src/main/java/com/vaadin/client/ui/VWindow.java
  17. 1
    1
      client/src/main/java/com/vaadin/client/ui/layout/LayoutDependencyTree.java
  18. 1
    1
      client/src/main/java/com/vaadin/client/ui/window/WindowConnector.java
  19. 1
    1
      client/src/test/java/com/vaadin/client/ApplicationConnectionURLGenerationTest.java
  20. 4
    4
      compatibility-client/src/main/java/com/vaadin/v7/client/ui/VFilterSelect.java
  21. 2
    2
      compatibility-client/src/main/java/com/vaadin/v7/client/ui/VOptionGroup.java
  22. 2
    2
      compatibility-client/src/main/java/com/vaadin/v7/client/ui/VScrollTable.java
  23. 1
    1
      compatibility-client/src/main/java/com/vaadin/v7/client/ui/VUpload.java
  24. 1
    1
      compatibility-client/src/main/java/com/vaadin/v7/client/ui/calendar/schedule/DateCellDayEvent.java
  25. 1
    1
      compatibility-client/src/main/java/com/vaadin/v7/client/ui/calendar/schedule/SimpleDayCell.java
  26. 1
    1
      compatibility-client/src/main/java/com/vaadin/v7/client/ui/calendar/schedule/WeeklyLongEvents.java
  27. 1
    1
      compatibility-server/src/main/java/com/vaadin/v7/data/Validator.java
  28. 1
    1
      compatibility-server/src/main/java/com/vaadin/v7/data/util/NestedMethodProperty.java
  29. 1
    1
      compatibility-server/src/main/java/com/vaadin/v7/data/util/converter/StringToCollectionConverter.java
  30. 1
    1
      compatibility-server/src/main/java/com/vaadin/v7/data/util/sqlcontainer/RowId.java
  31. 2
    2
      compatibility-server/src/main/java/com/vaadin/v7/data/util/sqlcontainer/query/FreeformQuery.java
  32. 1
    1
      compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractSelect.java
  33. 1
    1
      compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractTextField.java
  34. 1
    1
      compatibility-server/src/main/java/com/vaadin/v7/ui/Calendar.java
  35. 2
    2
      compatibility-server/src/main/java/com/vaadin/v7/ui/ComboBox.java
  36. 1
    1
      compatibility-server/src/main/java/com/vaadin/v7/ui/RichTextArea.java
  37. 1
    1
      server/src/main/java/com/vaadin/server/AbstractErrorMessage.java
  38. 1
    1
      server/src/main/java/com/vaadin/server/BootstrapHandler.java
  39. 1
    1
      server/src/main/java/com/vaadin/server/LegacyApplicationUIProvider.java
  40. 1
    1
      server/src/main/java/com/vaadin/server/Page.java
  41. 1
    1
      server/src/main/java/com/vaadin/server/SizeWithUnit.java
  42. 1
    1
      server/src/main/java/com/vaadin/server/ThemeResource.java
  43. 1
    1
      server/src/main/java/com/vaadin/server/VaadinServlet.java
  44. 1
    1
      server/src/main/java/com/vaadin/ui/AbstractOrderedLayout.java
  45. 1
    1
      server/src/main/java/com/vaadin/ui/ComboBox.java
  46. 1
    1
      server/src/main/java/com/vaadin/ui/CustomLayout.java
  47. 1
    1
      server/src/main/java/com/vaadin/ui/MenuBar.java
  48. 1
    1
      server/src/main/java/com/vaadin/ui/declarative/DesignAttributeHandler.java
  49. 1
    1
      server/src/main/java/com/vaadin/ui/declarative/DesignContext.java
  50. 2
    2
      server/src/main/java/com/vaadin/ui/declarative/FieldBinder.java
  51. 1
    1
      server/src/main/java/com/vaadin/ui/declarative/converters/DesignShortcutActionConverter.java
  52. 1
    1
      server/src/test/java/com/vaadin/tests/CompileTransitionPropertyTest.java
  53. 1
    1
      shared/src/main/java/com/vaadin/shared/util/SharedUtil.java
  54. 1
    1
      uitest/src/main/java/com/vaadin/tests/Parameters.java
  55. 2
    2
      uitest/src/main/java/com/vaadin/tests/TestForContainerFilterable.java
  56. 1
    1
      uitest/src/main/java/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java
  57. 2
    2
      uitest/src/main/java/com/vaadin/tests/components/table/TextFieldRelativeWidth.java
  58. 1
    1
      uitest/src/main/java/com/vaadin/tests/components/textfield/TextChangeEvents.java
  59. 1
    1
      uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldWithPropertyFormatter.java
  60. 1
    1
      uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldsValueChangeMode.java
  61. 1
    1
      uitest/src/main/java/com/vaadin/tests/layouts/layouttester/BaseLayoutTestUI.java
  62. 1
    1
      uitest/src/main/java/com/vaadin/tests/minitutorials/v7a2/MyPickerWidget.java
  63. 4
    4
      uitest/src/main/java/com/vaadin/tests/themes/valo/CommonParts.java
  64. 1
    1
      uitest/src/main/java/com/vaadin/v7/tests/components/textfield/TextChangeEvents.java

+ 2
- 2
client-compiler/src/main/java/com/vaadin/tools/ReportUsage.java View File

@@ -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);

+ 2
- 2
client/src/main/java/com/vaadin/client/JavaScriptConnectorHelper.java View File

@@ -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);

+ 3
- 3
client/src/main/java/com/vaadin/client/ResourceLoader.java View File

@@ -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);
}
}

+ 1
- 1
client/src/main/java/com/vaadin/client/VErrorMessage.java View File

@@ -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

+ 1
- 1
client/src/main/java/com/vaadin/client/WidgetUtil.java View File

@@ -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", "");

+ 3
- 3
client/src/main/java/com/vaadin/client/componentlocator/SelectorPredicate.java View File

@@ -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;
}


+ 1
- 1
client/src/main/java/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java View File

@@ -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 {

+ 3
- 3
client/src/main/java/com/vaadin/client/connectors/grid/GridDropTargetConnector.java View File

@@ -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

+ 3
- 3
client/src/main/java/com/vaadin/client/ui/VAccordion.java View File

@@ -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);
}

+ 1
- 1
client/src/main/java/com/vaadin/client/ui/VCheckBoxGroup.java View File

@@ -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;
}

+ 4
- 4
client/src/main/java/com/vaadin/client/ui/VComboBox.java View File

@@ -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%");
}
}

+ 3
- 3
client/src/main/java/com/vaadin/client/ui/VLink.java View File

@@ -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();

+ 2
- 2
client/src/main/java/com/vaadin/client/ui/VNotification.java View File

@@ -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) {

+ 1
- 1
client/src/main/java/com/vaadin/client/ui/VRadioButtonGroup.java View File

@@ -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;
}

+ 1
- 1
client/src/main/java/com/vaadin/client/ui/VUpload.java View File

@@ -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

+ 2
- 2
client/src/main/java/com/vaadin/client/ui/VWindow.java View File

@@ -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) {

+ 1
- 1
client/src/main/java/com/vaadin/client/ui/layout/LayoutDependencyTree.java View File

@@ -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";

+ 1
- 1
client/src/main/java/com/vaadin/client/ui/window/WindowConnector.java View File

@@ -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

+ 1
- 1
client/src/test/java/com/vaadin/client/ApplicationConnectionURLGenerationTest.java View File

@@ -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"));


+ 4
- 4
compatibility-client/src/main/java/com/vaadin/v7/client/ui/VFilterSelect.java View File

@@ -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%");
}
}

+ 2
- 2
compatibility-client/src/main/java/com/vaadin/v7/client/ui/VOptionGroup.java View File

@@ -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());
}

+ 2
- 2
compatibility-client/src/main/java/com/vaadin/v7/client/ui/VScrollTable.java View File

@@ -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

+ 1
- 1
compatibility-client/src/main/java/com/vaadin/v7/client/ui/VUpload.java View File

@@ -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

+ 1
- 1
compatibility-client/src/main/java/com/vaadin/v7/client/ui/calendar/schedule/DateCellDayEvent.java View File

@@ -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);

+ 1
- 1
compatibility-client/src/main/java/com/vaadin/v7/client/ui/calendar/schedule/SimpleDayCell.java View File

@@ -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");

+ 1
- 1
compatibility-client/src/main/java/com/vaadin/v7/client/ui/calendar/schedule/WeeklyLongEvents.java View File

@@ -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) {

+ 1
- 1
compatibility-server/src/main/java/com/vaadin/v7/data/Validator.java View File

@@ -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) {

+ 1
- 1
compatibility-server/src/main/java/com/vaadin/v7/data/util/NestedMethodProperty.java View File

@@ -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 {

+ 1
- 1
compatibility-server/src/main/java/com/vaadin/v7/data/util/converter/StringToCollectionConverter.java View File

@@ -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();

+ 1
- 1
compatibility-server/src/main/java/com/vaadin/v7/data/util/sqlcontainer/RowId.java View File

@@ -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();

+ 2
- 2
compatibility-server/src/main/java/com/vaadin/v7/data/util/sqlcontainer/query/FreeformQuery.java View File

@@ -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;
}

+ 1
- 1
compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractSelect.java View File

@@ -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);
}
}

+ 1
- 1
compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractTextField.java View File

@@ -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();
}

/**

+ 1
- 1
compatibility-server/src/main/java/com/vaadin/v7/ui/Calendar.java View File

@@ -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 {

+ 2
- 2
compatibility-server/src/main/java/com/vaadin/v7/ui/ComboBox.java View File

@@ -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;

+ 1
- 1
compatibility-server/src/main/java/com/vaadin/v7/ui/RichTextArea.java View File

@@ -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

+ 1
- 1
server/src/main/java/com/vaadin/server/AbstractErrorMessage.java View File

@@ -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();
}
}

+ 1
- 1
server/src/main/java/com/vaadin/server/BootstrapHandler.java View File

@@ -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");

+ 1
- 1
server/src/main/java/com/vaadin/server/LegacyApplicationUIProvider.java View File

@@ -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

+ 1
- 1
server/src/main/java/com/vaadin/server/Page.java View File

@@ -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) {

+ 1
- 1
server/src/main/java/com/vaadin/server/SizeWithUnit.java View File

@@ -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 {

+ 1
- 1
server/src/main/java/com/vaadin/server/ThemeResource.java View File

@@ -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) == '/') {

+ 1
- 1
server/src/main/java/com/vaadin/server/VaadinServlet.java View File

@@ -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 += "/";
}

+ 1
- 1
server/src/main/java/com/vaadin/ui/AbstractOrderedLayout.java View File

@@ -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);

+ 1
- 1
server/src/main/java/com/vaadin/ui/ComboBox.java View File

@@ -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);
}
}

+ 1
- 1
server/src/main/java/com/vaadin/ui/CustomLayout.java View File

@@ -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";

+ 1
- 1
server/src/main/java/com/vaadin/ui/MenuBar.java View File

@@ -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);
}

+ 1
- 1
server/src/main/java/com/vaadin/ui/declarative/DesignAttributeHandler.java View File

@@ -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());

+ 1
- 1
server/src/main/java/com/vaadin/ui/declarative/DesignContext.java View File

@@ -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(

+ 2
- 2
server/src/main/java/com/vaadin/ui/declarative/FieldBinder.java View File

@@ -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();

+ 1
- 1
server/src/main/java/com/vaadin/ui/declarative/converters/DesignShortcutActionConverter.java View File

@@ -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);
}


+ 1
- 1
server/src/test/java/com/vaadin/tests/CompileTransitionPropertyTest.java View File

@@ -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());
}
}

+ 1
- 1
shared/src/main/java/com/vaadin/shared/util/SharedUtil.java View File

@@ -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

+ 1
- 1
uitest/src/main/java/com/vaadin/tests/Parameters.java View File

@@ -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] + "'";

+ 2
- 2
uitest/src/main/java/com/vaadin/tests/TestForContainerFilterable.java View File

@@ -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);
}

+ 1
- 1
uitest/src/main/java/com/vaadin/tests/components/orderedlayout/OrderedLayoutCases.java View File

@@ -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(

+ 2
- 2
uitest/src/main/java/com/vaadin/tests/components/table/TextFieldRelativeWidth.java View File

@@ -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%");

+ 1
- 1
uitest/src/main/java/com/vaadin/tests/components/textfield/TextChangeEvents.java View File

@@ -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];

+ 1
- 1
uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldWithPropertyFormatter.java View File

@@ -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;

+ 1
- 1
uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldsValueChangeMode.java View File

@@ -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];

+ 1
- 1
uitest/src/main/java/com/vaadin/tests/layouts/layouttester/BaseLayoutTestUI.java View File

@@ -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));

+ 1
- 1
uitest/src/main/java/com/vaadin/tests/minitutorials/v7a2/MyPickerWidget.java View File

@@ -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);

+ 4
- 4
uitest/src/main/java/com/vaadin/tests/themes/valo/CommonParts.java View File

@@ -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);

+ 1
- 1
uitest/src/main/java/com/vaadin/v7/tests/components/textfield/TextChangeEvents.java View File

@@ -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];

Loading…
Cancel
Save