flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From StephanEwen <...@git.apache.org>
Subject [GitHub] flink pull request: [FLINK-3700] [core] Add 'Preconditions' utilit...
Date Wed, 13 Apr 2016 09:30:20 GMT
Github user StephanEwen commented on a diff in the pull request:

    https://github.com/apache/flink/pull/1853#discussion_r59518788
  
    --- 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 --
    
    True, I have been using that quite a bit. There are, however, a few signatures missing
(like message with placeholders and var-arg parameters) as well as separate functions like
`checkArgument` and `checkState`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message