diff --git a/jOOQ/src/main/java/org/jooq/impl/LazyCatalog.java b/jOOQ/src/main/java/org/jooq/impl/LazyCatalog.java index 0f831da623..797faf0fb1 100644 --- a/jOOQ/src/main/java/org/jooq/impl/LazyCatalog.java +++ b/jOOQ/src/main/java/org/jooq/impl/LazyCatalog.java @@ -38,7 +38,6 @@ package org.jooq.impl; import java.util.List; -import java.util.concurrent.Callable; import java.util.stream.Stream; import org.jooq.Catalog; @@ -59,21 +58,21 @@ public final class LazyCatalog extends AbstractNamed implements Catalog { /** * Generated UID */ - private static final long serialVersionUID = -2260128711891951254L; + private static final long serialVersionUID = -2260128711891951254L; - final Callable callable; - transient Catalog catalog; + final LazySupplier supplier; + transient Catalog catalog; - public LazyCatalog(Name name, Callable callable) { + public LazyCatalog(Name name, LazySupplier supplier) { super(name, CommentImpl.NO_COMMENT); - this.callable = callable; + this.supplier = supplier; } private final Catalog catalog() { if (catalog == null) { try { - catalog = callable.call(); + catalog = supplier.get(); } catch (Exception e) { throw new RuntimeException(e); diff --git a/jOOQ/src/main/java/org/jooq/impl/LazySchema.java b/jOOQ/src/main/java/org/jooq/impl/LazySchema.java index 4ae95f8709..f4e07cb3ae 100644 --- a/jOOQ/src/main/java/org/jooq/impl/LazySchema.java +++ b/jOOQ/src/main/java/org/jooq/impl/LazySchema.java @@ -38,7 +38,6 @@ package org.jooq.impl; import java.util.List; -import java.util.concurrent.Callable; import java.util.stream.Stream; import org.jooq.Catalog; @@ -66,19 +65,19 @@ public final class LazySchema extends AbstractNamed implements Schema { */ private static final long serialVersionUID = -2260128711891951254L; - final Callable callable; - transient Schema schema; + final LazySupplier supplier; + transient Schema schema; - public LazySchema(Name name, Comment comment, Callable callable) { + public LazySchema(Name name, Comment comment, LazySupplier supplier) { super(name, comment); - this.callable = callable; + this.supplier = supplier; } private final Schema schema() { if (schema == null) { try { - schema = callable.call(); + schema = supplier.get(); } catch (Exception e) { throw new RuntimeException(e); diff --git a/jOOQ/src/main/java/org/jooq/impl/LazySupplier.java b/jOOQ/src/main/java/org/jooq/impl/LazySupplier.java new file mode 100644 index 0000000000..37986587cc --- /dev/null +++ b/jOOQ/src/main/java/org/jooq/impl/LazySupplier.java @@ -0,0 +1,61 @@ +/* + * 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. + * + * Other licenses: + * ----------------------------------------------------------------------------- + * Commercial licenses for this work are available. These replace the above + * ASL 2.0 and offer limited warranties, support, maintenance, and commercial + * database integrations. + * + * For more information, please visit: http://www.jooq.org/licenses + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + */ +package org.jooq.impl; + +import java.io.Serializable; +import java.util.function.Supplier; + +import org.jooq.Internal; + +/** + * A lazy supplier + */ +@Internal +@FunctionalInterface +public interface LazySupplier extends Serializable, Supplier { + + /** + * Gets a result. + * + * @return a result + */ + + @Override + + T get(); +}