diff --git a/java8/pom.xml b/java8/pom.xml new file mode 100644 index 00000000..37433fb4 --- /dev/null +++ b/java8/pom.xml @@ -0,0 +1,30 @@ + + + + 4.0.0 + spring-data-java8-stub + + + org.springframework.data.build + spring-data-build + 1.4.0.BUILD-SNAPSHOT + + + Spring Data Build - Java 8 Stubs + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + 1.6 + 1.6 + + + + + + diff --git a/java8/src/main/java/java/util/Optional.java b/java8/src/main/java/java/util/Optional.java new file mode 100644 index 00000000..087a3456 --- /dev/null +++ b/java8/src/main/java/java/util/Optional.java @@ -0,0 +1,47 @@ +/* + * Copyright 2014 the original author or authors. + * + * 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 java.util; + +/** + * Stub implementation of JDK 8's {@link Optional}. + * + * @author Oliver Gierke + */ +@SuppressWarnings("unused") +public final class Optional { + + private static final Optional EMPTY = new Optional(null); + + private final T value; + + private Optional(T value) { + this.value = value; + } + + public static Optional of(T value) { + return new Optional(value); + } + + public static Optional ofNullable(T value) { + return value == null ? Optional. empty() : of(value); + } + + @SuppressWarnings("unchecked") + public static Optional empty() { + Optional t = (Optional) EMPTY; + return t; + } +} diff --git a/pom.xml b/pom.xml index ac3c1198..96f26be8 100644 --- a/pom.xml +++ b/pom.xml @@ -18,6 +18,7 @@ resources + java8 parent bom