appendUserAgentProperty(extra, "os.name");
appendUserAgentProperty(extra, "os.version");
- if (extra.length() > 0) {
+ if (extra.length() != 0) {
userAgent += " (" + extra.toString() + ")";
}
String propName) {
String propValue = System.getProperty(propName);
if (propValue != null) {
- if (sb.length() > 0) {
+ if (sb.length() != 0) {
sb.append(';').append(' ');
}
sb.append(propName);
}
private ServerConnector getConnector(String connectorId) {
- if (connectorId == null || connectorId.length() == 0) {
+ if (connectorId == null || connectorId.isEmpty()) {
return connector;
}
// 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);
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);
}
}
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);
}
}
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
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", "");
}
/**
- * 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
*/
List<SelectorPredicate> predicates = new ArrayList<>();
String predicateStr = extractPredicateString(path);
- if (null == predicateStr || predicateStr.length() == 0) {
+ if (null == predicateStr || predicateStr.isEmpty()) {
return predicates;
}
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 {
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 {
} 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 {
// 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
* 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);
}
}
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;
}
String height = getElement().getStyle().getHeight();
String preferredHeight = getPreferredHeight(pageLength);
- return !(height == null || height.length() == 0
+ return !(height == null || height.isEmpty()
|| height.equals(preferredHeight));
}
if (selectedItemIcon != null) {
panel.remove(selectedItemIcon);
}
- if (iconUri == null || iconUri.length() == 0) {
+ if (iconUri == null || iconUri.isEmpty()) {
if (selectedItemIcon != null) {
selectedItemIcon = null;
afterSelectedItemIconChange();
for (ComboBoxSuggestion suggestion : currentSuggestions) {
// Collect captions so we can calculate minimum width for
// textarea
- if (captions.length() > 0) {
+ if (!captions.isEmpty()) {
captions += "|";
}
captions += WidgetUtil
@Override
public void setWidth(String width) {
super.setWidth(width);
- if (width.length() != 0) {
+ if (!width.isEmpty()) {
tb.setWidth("100%");
}
}
}
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();
removeStyleDependentName(temporaryStyle);
temporaryStyle = null;
}
- if (style != null && style.length() > 0) {
+ if (style != null && !style.isEmpty()) {
temporaryStyle = style;
addStyleName(style);
addStyleDependentName(style);
html.append("</p>");
}
- if (html.length() > 0) {
+ if (html.length() != 0) {
// Add error description
if (details != null) {
}
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;
}
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
// 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
// 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) {
}
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";
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
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"));
String height = getElement().getStyle().getHeight();
String preferredHeight = getPreferredHeight(pageLength);
- return !(height == null || height.length() == 0
+ return !(height == null || height.isEmpty()
|| height.equals(preferredHeight));
}
*/
public void setSelectedItemIcon(String iconUri) {
- if (iconUri == null || iconUri.length() == 0) {
+ if (iconUri == null || iconUri.isEmpty()) {
if (selectedItemIcon != null) {
panel.remove(selectedItemIcon);
selectedItemIcon = null;
for (FilterSelectSuggestion suggestion : currentSuggestions) {
// Collect captions so we can calculate minimum width for
// textarea
- if (captions.length() > 0) {
+ if (!captions.isEmpty()) {
captions += "|";
}
captions += WidgetUtil
@Override
public void setWidth(String width) {
super.setWidth(width);
- if (width.length() != 0) {
+ if (!width.isEmpty()) {
tb.setWidth("100%");
}
}
}
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;
}
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());
}
@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
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
weekGrid = parent;
Style s = getElement().getStyle();
- if (event.getStyleName().length() > 0) {
+ if (!event.getStyleName().isEmpty()) {
addStyleDependentName(event.getStyleName());
}
s.setPosition(Position.ABSOLUTE);
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");
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) {
*/
public boolean isInvisible() {
String msg = getMessage();
- if (msg != null && msg.length() > 0) {
+ if (msg != null && !msg.isEmpty()) {
return false;
}
if (causes != null) {
}
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 {
}
builder.append(delimiter);
}
- if (builder.length() > 0) {
+ if (builder.length() != 0) {
return builder.substring(0, builder.length() - delimiter.length());
} else {
return builder.toString();
builder.append(id);
builder.append('/');
}
- if (builder.length() > 0) {
+ if (builder.length() != 0) {
return builder.substring(0, builder.length() - 1);
}
return builder.toString();
StatementHelper sh = ((FreeformStatementDelegate) delegate)
.getCountStatement();
if (sh != null && sh.getQueryString() != null
- && sh.getQueryString().length() > 0) {
+ && !sh.getQueryString().isEmpty()) {
return true;
}
} catch (UnsupportedOperationException e) {
}
try {
String queryString = delegate.getQueryString(0, 50);
- return queryString != null && queryString.length() > 0;
+ return queryString != null && !queryString.isEmpty();
} catch (UnsupportedOperationException e) {
return false;
}
// 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);
}
}
@Override
public boolean isEmpty() {
- return super.isEmpty() || getValue().length() == 0;
+ return super.isEmpty() || getValue().isEmpty();
}
/**
@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 {
}
private boolean isFilteringNeeded() {
- return filterstring != null && filterstring.length() > 0
+ return filterstring != null && !filterstring.isEmpty()
&& filteringMode != FilteringMode.OFF;
}
} 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;
@Override
public boolean isEmpty() {
- return super.isEmpty() || getValue().length() == 0;
+ return super.isEmpty() || getValue().isEmpty();
}
@Override
sb.append("</div>\n");
}
}
- if (sb.length() > 0) {
+ if (sb.length() != 0) {
result = sb.toString();
}
}
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");
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
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) {
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 {
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) == '/') {
servletPath = request.getContextPath() + request.getServletPath();
}
- if (servletPath.length() == 0
+ if (servletPath.isEmpty()
|| servletPath.charAt(servletPath.length() - 1) != '/') {
servletPath += "/";
}
// 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);
public void createNewItem(String itemValue) {
// New option entered
if (getNewItemHandler() != null && itemValue != null
- && itemValue.length() > 0) {
+ && !itemValue.isEmpty()) {
getNewItemHandler().accept(itemValue);
}
}
// 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";
}
String description = item.getDescription();
- if (description != null && description.length() > 0) {
+ if (description != null && !description.isEmpty()) {
target.addAttribute(MenuBarConstants.ATTRIBUTE_ITEM_DESCRIPTION,
description);
}
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());
// 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(
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
}
}
// 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();
@Override
public Result<ShortcutAction> convertToModel(String value,
ValueContext context) {
- if (value.length() == 0) {
+ if (value.isEmpty()) {
return Result.ok(null);
}
// 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());
}
}
\ No newline at end of file
* @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
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] + "'";
@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);
}
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(
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%");
newItem = idc.getItem(itemId);
tf = new TextField();
- if (inputPromptChild != null && inputPromptChild.length() > 0) {
+ if (inputPromptChild != null && !inputPromptChild.isEmpty()) {
tf.setInputPrompt(inputPromptChild);
}
tf.setWidth("100%");
}
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];
@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;
}
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];
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));
}
public void setButtonText(String buttonText, boolean adjustSpace) {
- if (buttonText == null || buttonText.length() == 0) {
+ if (buttonText == null || buttonText.isEmpty()) {
buttonText = "...";
}
button.setText(buttonText);
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());
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());
+ 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);
}
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];