1 /*
2 * Licensed under the Apache License, Version 2.0 (the "License");
3 * you may not use this file except in compliance with the License.
4 * You may obtain a copy of the License at
5 *
6 * http://www.apache.org/licenses/LICENSE-2.0
7 *
8 * Unless required by applicable law or agreed to in writing, software
9 * distributed under the License is distributed on an "AS IS" BASIS,
10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 * See the License for the specific language governing permissions and
12 * limitations under the License.
13 */
14
15 package org.basepom.mojo.propertyhelper.beans;
16
17 import static com.google.common.base.Preconditions.checkNotNull;
18
19 import java.util.Optional;
20 import java.util.UUID;
21
22 import com.google.common.annotations.VisibleForTesting;
23
24 public class UuidDefinition
25 extends AbstractDefinition<UuidDefinition> {
26
27 /**
28 * Value for this uuid. Field injected by Maven.
29 */
30 String value = null;
31
32 public UuidDefinition() {
33 }
34
35 public Optional<UUID> getValue() {
36 return Optional.ofNullable(value).map(UUID::fromString);
37 }
38
39 @VisibleForTesting
40 public UuidDefinition setValue(final String value) {
41 this.value = checkNotNull(value, "value is null");
42 return this;
43 }
44 }