Browse Source

Code format (#11548)

* Code format

* Merge branch 'master' into code-format
tags/8.9.0.alpha1
Sun Zhe 5 years ago
parent
commit
b92df6d587
No account linked to committer's email address

+ 17
- 14
server/src/main/java/com/vaadin/data/converter/StringToUuidConverter.java View File

* Leading and trailing white spaces are ignored when converting from a String. * Leading and trailing white spaces are ignored when converting from a String.
* </p> * </p>
* <p> * <p>
* The String representation uses the canonical format of 32-characters with a hyphen
* to separate each of five groups of hexadecimal digits as defined in:
* The String representation uses the canonical format of 32-characters with a
* hyphen to separate each of five groups of hexadecimal digits as defined in:
* RFC 4122: A Universally Unique IDentifier (UUID) URN Namespace * RFC 4122: A Universally Unique IDentifier (UUID) URN Namespace
* http://www.ietf.org/rfc/rfc4122.txt * http://www.ietf.org/rfc/rfc4122.txt
* </p> * </p>
* @author Vaadin Ltd * @author Vaadin Ltd
* @since 8.8 * @since 8.8
*/ */
public class StringToUuidConverter implements Converter <String, UUID> {
public class StringToUuidConverter implements Converter<String, UUID> {


private ErrorMessageProvider errorMessageProvider; private ErrorMessageProvider errorMessageProvider;


/** /**
* Constructs a converter for String to UUID and back. * Constructs a converter for String to UUID and back.
* *
* @param errorMessage the error message to use if conversion fails
* @param errorMessage
* the error message to use if conversion fails
*/ */
public StringToUuidConverter(String errorMessage) { public StringToUuidConverter(String errorMessage) {
this(ctx -> errorMessage); this(ctx -> errorMessage);
} }


/** /**
* Constructs a new converter instance with the given error message provider.
* Empty strings are converted to <code>null</code>.
* Constructs a new converter instance with the given error message
* provider. Empty strings are converted to <code>null</code>.
* *
* @param errorMessageProvider the error message provider to use if conversion fails
* @param errorMessageProvider
* the error message provider to use if conversion fails
*/ */
public StringToUuidConverter(ErrorMessageProvider errorMessageProvider) { public StringToUuidConverter(ErrorMessageProvider errorMessageProvider) {
this.errorMessageProvider = errorMessageProvider; this.errorMessageProvider = errorMessageProvider;
} }


@Override @Override
public Result <UUID> convertToModel(String value, ValueContext context) {
public Result<UUID> convertToModel(String value, ValueContext context) {
if (value == null) { if (value == null) {
return Result.ok( null );
return Result.ok(null);
} }


// Remove leading and trailing white space // Remove leading and trailing white space
} }


if (null != uuid) { if (null != uuid) {
return Result.ok(uuid); // Return the UUID object, converted from String.
return Result.ok(uuid); // Return the UUID object, converted from
// String.
} else { } else {
return Result.error( this.errorMessageProvider.apply(context) );
return Result.error(this.errorMessageProvider.apply(context));
} }
} }


@Override @Override
public String convertToPresentation (UUID value, ValueContext context) {
if ( value == null ) {
public String convertToPresentation(UUID value, ValueContext context) {
if (value == null) {
return null; return null;
} }
// `java.util.UUID::toString` generates a textual representation of a // `java.util.UUID::toString` generates a textual representation of a
// UUID’s 128-bits as a lowercase hexadecimal `String` in canonical // UUID’s 128-bits as a lowercase hexadecimal `String` in canonical
// 32-character format with four hyphens separating groups of digits. // 32-character format with four hyphens separating groups of digits.
// https://docs.oracle.com/javase/10/docs/api/java/util/UUID.html#toString() // https://docs.oracle.com/javase/10/docs/api/java/util/UUID.html#toString()
return value.toString();
return value.toString();
} }
} }

+ 7
- 7
server/src/main/java/com/vaadin/server/BrowserWindowOpener.java View File

* Creates a window opener that will open windows containing the provided UI * Creates a window opener that will open windows containing the provided UI
* class. * class.
* <p> * <p>
* Note: The new UI instance will not work with dependency injection (CDI and
* Spring). Use {@link BrowserWindowOpener(String)} instead.
* {@code VaadinServlet.getCurrent().getServletContext().getContextPath()} gives
* the current context path.
*
* Note: The new UI instance will not work with dependency injection (CDI
* and Spring). Use {@link BrowserWindowOpener(String)} instead.
* {@code VaadinServlet.getCurrent().getServletContext().getContextPath()}
* gives the current context path.
*
* @param uiClass * @param uiClass
* the UI class that should be opened when the extended component * the UI class that should be opened when the extended component
* is clicked * is clicked
* <p> * <p>
* Note: The new UI instance will not work with dependency injection (CDI * Note: The new UI instance will not work with dependency injection (CDI
* and Spring). Use {@link BrowserWindowOpener(String)} instead. * and Spring). Use {@link BrowserWindowOpener(String)} instead.
* {@code VaadinServlet.getCurrent().getServletContext().getContextPath()} gives
* the current context path.
* {@code VaadinServlet.getCurrent().getServletContext().getContextPath()}
* gives the current context path.
* *
* @param uiClass * @param uiClass
* the UI class that should be opened when the extended component * the UI class that should be opened when the extended component

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

.test(getItemCaptionOfItem(item), filterText)); .test(getItemCaptionOfItem(item), filterText));
} }


// Helper method for the above to make lambda more readable
// Helper method for the above to make lambda more readable
private String getItemCaptionOfItem(T item) { private String getItemCaptionOfItem(T item) {
String caption = getItemCaptionGenerator().apply(item); String caption = getItemCaptionGenerator().apply(item);
if (caption == null) { if (caption == null) {
caption = ""; caption = "";
}
}
return caption; return caption;
} }
/** /**
* Sets the data items of this listing and a simple string filter with which * Sets the data items of this listing and a simple string filter with which
* the item string and the text the user has input are compared. * the item string and the text the user has input are compared.

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

} }


/** /**
* Returns the width (in pixels). By default a column width is
* Returns the width (in pixels). By default a column width is
* {@value com.vaadin.shared.ui.grid.GridConstants#DEFAULT_COLUMN_WIDTH_PX} * {@value com.vaadin.shared.ui.grid.GridConstants#DEFAULT_COLUMN_WIDTH_PX}
* (undefined). * (undefined).
* *
* @param nestedNullBehavior * @param nestedNullBehavior
* the behavior when * the behavior when
* @return the newly added column, not <code>null</code> * @return the newly added column, not <code>null</code>
*
*
* @since 8.8 * @since 8.8
*/ */
public Column<T, ?> addColumn(String propertyName, public Column<T, ?> addColumn(String propertyName,

+ 3
- 3
server/src/main/java/com/vaadin/ui/Slider.java View File

} }


/** /**
* Sets the slider to update its value when the user clicks on it.
* By default, the slider value is updated by dragging the slider's handle
* or clicking arrows.
* Sets the slider to update its value when the user clicks on it. By
* default, the slider value is updated by dragging the slider's handle or
* clicking arrows.
* *
* @param updateValueOnClick * @param updateValueOnClick
* {@code true} to update the value of the slider on click, * {@code true} to update the value of the slider on click,

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

import elemental.json.JsonValue; import elemental.json.JsonValue;


public class CustomJSONSerializerTest { public class CustomJSONSerializerTest {
public static class Foo { public static class Foo {


} }

+ 1
- 1
uitest/src/main/java/com/vaadin/tests/components/panel/PanelHTMLCaption.java View File

changeCaptionFormat.setId("buttonId"); changeCaptionFormat.setId("buttonId");
addComponent(changeCaptionFormat); addComponent(changeCaptionFormat);
} }
}
}

+ 2
- 1
uitest/src/test/java/com/vaadin/tests/components/combobox/ComboBoxSelectingNewItemValueChangeTest.java View File

SelectionType selectionType) { SelectionType selectionType) {
// clear() would cause an additional value change in chrome 70+ // clear() would cause an additional value change in chrome 70+
// since it always makes blur after clear() // since it always makes blur after clear()
comboBoxElement.sendKeys(Keys.BACK_SPACE, Keys.BACK_SPACE, Keys.BACK_SPACE);
comboBoxElement.sendKeys(Keys.BACK_SPACE, Keys.BACK_SPACE,
Keys.BACK_SPACE);
sendKeysToInput(input); sendKeysToInput(input);
switch (selectionType) { switch (selectionType) {
case ENTER: case ENTER:

+ 0
- 1
uitest/src/test/java/com/vaadin/tests/components/panel/PanelHTMLCaptionTest.java View File

import org.junit.Test; import org.junit.Test;
import org.openqa.selenium.By; import org.openqa.selenium.By;



public class PanelHTMLCaptionTest extends MultiBrowserTest { public class PanelHTMLCaptionTest extends MultiBrowserTest {
@Test @Test
public void testCaptionDisplayedAsText() { public void testCaptionDisplayedAsText() {

+ 1
- 1
uitest/src/test/java/com/vaadin/tests/components/slider/SliderHandleBaseClickTest.java View File

sleep(100); sleep(100);
assertEquals(String.format( assertEquals(String.format(
"Slider value should not have changed. Expected 3.0 , but was %f", "Slider value should not have changed. Expected 3.0 , but was %f",
getSliderValue()), 3.0,getSliderValue(), 0.0);
getSliderValue()), 3.0, getSliderValue(), 0.0);
// Enable click event handling // Enable click event handling
findElement(By.id("toggleHandling")).click(); findElement(By.id("toggleHandling")).click();
} }

+ 1
- 2
uitest/src/test/java/com/vaadin/tests/components/window/WindowHeaderButtonKeyboardActionsTest.java View File

closeButton.equals(driver.switchTo().activeElement())); closeButton.equals(driver.switchTo().activeElement()));


pressKeyAndWait(Keys.ENTER); pressKeyAndWait(Keys.ENTER);
assertTrue(
"Window is not closed when focus is shifted back-and-forth",
assertTrue("Window is not closed when focus is shifted back-and-forth",
findElements(By.className("v-window")).size() == 0); findElements(By.className("v-window")).size() == 0);
} }



+ 2
- 2
uitest/src/test/java/com/vaadin/v7/tests/components/grid/basicfeatures/server/GridIndexedContainerInsertSelectTest.java View File

} }


/** /**
* Test asserting that issue https://github.com/vaadin/framework/issues/11477
* is fixed.
* Test asserting that issue
* https://github.com/vaadin/framework/issues/11477 is fixed.
*/ */
@Test @Test
public void test_insertRowAfterSelected_newRowIsSelected() { public void test_insertRowAfterSelected_newRowIsSelected() {

Loading…
Cancel
Save