diff --git a/flow-data/src/main/java/com/vaadin/flow/data/converter/StringToUuidConverter.java b/flow-data/src/main/java/com/vaadin/flow/data/converter/StringToUuidConverter.java new file mode 100644 index 00000000000..288d7a688fa --- /dev/null +++ b/flow-data/src/main/java/com/vaadin/flow/data/converter/StringToUuidConverter.java @@ -0,0 +1,96 @@ +/* + * Copyright 2000-2018 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +package com.vaadin.flow.data.converter; + +import com.vaadin.flow.data.binder.ErrorMessageProvider; +import com.vaadin.flow.data.binder.Result; +import com.vaadin.flow.data.binder.ValueContext; +import org.slf4j.LoggerFactory; + +import java.util.UUID; + +/** + * A converter that converts from {@link String} to {@link UUID} and back. + *
+ * Leading and trailing white spaces are ignored when converting from a String. + *
+ *+ * 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 + * http://www.ietf.org/rfc/rfc4122.txt + *
+ * + * @author Vaadin Ltd + */ +public class StringToUuidConverter implements Converternull
.
+ *
+ * @param errorMessageProvider the error message provider to use if conversion fails
+ */
+ public StringToUuidConverter(ErrorMessageProvider errorMessageProvider) {
+ this.errorMessageProvider = errorMessageProvider;
+ }
+
+ @Override
+ public Result