[ https://issues.apache.org/jira/browse/FLINK-3700?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15236058#comment-15236058 ]
ASF GitHub Bot commented on FLINK-3700: --------------------------------------- Github user ZackPierce commented on a diff in the pull request: https://github.com/apache/flink/pull/1853#discussion_r59289246 --- Diff: flink-core/src/main/java/org/apache/flink/util/Preconditions.java --- @@ -0,0 +1,213 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ + +// ---------------------------------------------------------------------------- +// This class is largely adapted from "com.google.common.base.Preconditions", +// which is part of the "Guava" library. +// +// Because of frequent issues with dependency conflicts, this class was +// added to the Flink code base to reduce dependency on Guava. +// ---------------------------------------------------------------------------- + +package org.apache.flink.util; + +import org.apache.flink.annotation.Internal; + +import javax.annotation.Nullable; + +/** + * A collection of static utility methods to validate input. + * + * <p>This class is modelled after Google Guava's Preconditions class, and partly takes code + * from that class. We add this code to the Flink code base in order to reduce external + * dependencies. + */ +@Internal +public final class Preconditions { + + // ------------------------------------------------------------------------ + // Null checks + // ------------------------------------------------------------------------ + + /** + * Ensures that the given object reference is not null. + * Upon violation, a {@code NullPointerException} with no message is thrown. + * + * @param reference The object reference + * @return The object reference itself (generically typed). + * + * @throws NullPointerException Thrown, if the passed reference was null. + */ + public static <T> T checkNotNull(T reference) { --- End diff -- For what it is worth, `Objects.requireNonNull` has overloads with the same signature (as this and the next method down), and is [present in the JDK since 1.7](https://docs.oracle.com/javase/7/docs/api/java/util/Objects.html#requireNonNull(T)). Using `requireNonNull` instead may help reduce the burden of semi-standard code that Flink reimplements. > Replace Guava Preconditions class with Flink Preconditions > ---------------------------------------------------------- > > Key: FLINK-3700 > URL: https://issues.apache.org/jira/browse/FLINK-3700 > Project: Flink > Issue Type: Improvement > Components: Core > Affects Versions: 1.0.0 > Reporter: Stephan Ewen > Assignee: Stephan Ewen > > In order to reduce the dependency on Guava (which has cause us quite a bit of > pain in the past with its version conflicts), I suggest to add a Flink > {{Preconditions}} class. -- This message was sent by Atlassian JIRA (v6.3.4#6332)