com.alibaba.excel.util

类 Validate


  • public class Validate
    extends Object
    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.
    作者:
    Apache Software Foundation (ASF)
    • 构造器概要

      构造器  
      构造器和说明
      Validate() 
    • 方法概要

      所有方法  静态方法  具体方法 
      限定符和类型 方法和说明
      static void isTrue(boolean expression)
      Validate that the argument condition is true; otherwise throwing an exception.
      static void isTrue(boolean expression, String message, double value)
      Validate that the argument condition is true; otherwise throwing an exception with the specified message.
      static void isTrue(boolean expression, String message, long value)
      Validate that the argument condition is true; otherwise throwing an exception with the specified message.
      static void isTrue(boolean expression, String message, Object... values)
      Validate that the argument condition is true; otherwise throwing an exception with the specified message.
      static <T> T notNull(T object)
      Validate that the specified argument is not null; otherwise throwing an exception.
      static <T> T notNull(T object, String message, Object... values)
      Validate that the specified argument is not null; otherwise throwing an exception with the specified message.
    • 构造器详细资料

      • Validate

        public Validate()
    • 方法详细资料

      • isTrue

        public static void isTrue(boolean expression,
                                  String message,
                                  long value)

        Validate that the argument condition is true; otherwise throwing an exception with the specified message. This method is useful when validating according to an arbitrary boolean expression, such as validating a primitive number or using your own custom validation expression.

        Validate.isTrue(i > 0.0, "The value must be greater than zero: %d", i);

        For performance reasons, the long value is passed as a separate parameter and appended to the exception message only in the case of an error.

        参数:
        expression - the boolean expression to check
        message - the String.format(String, Object...) exception message if invalid, not null
        value - the value to append to the message when invalid
        抛出:
        IllegalArgumentException - if expression is false
        另请参阅:
        isTrue(boolean), isTrue(boolean, String, double), isTrue(boolean, String, Object...)
      • isTrue

        public static void isTrue(boolean expression,
                                  String message,
                                  double value)

        Validate that the argument condition is true; otherwise throwing an exception with the specified message. This method is useful when validating according to an arbitrary boolean expression, such as validating a primitive number or using your own custom validation expression.

        Validate.isTrue(d > 0.0, "The value must be greater than zero: %s", d);

        For performance reasons, the double value is passed as a separate parameter and appended to the exception message only in the case of an error.

        参数:
        expression - the boolean expression to check
        message - the String.format(String, Object...) exception message if invalid, not null
        value - the value to append to the message when invalid
        抛出:
        IllegalArgumentException - if expression is false
        另请参阅:
        isTrue(boolean), isTrue(boolean, String, long), isTrue(boolean, String, Object...)
      • isTrue

        public static void isTrue(boolean expression,
                                  String message,
                                  Object... values)

        Validate that the argument condition is true; otherwise throwing an exception with the specified message. This method is useful when validating according to an arbitrary boolean expression, such as validating a primitive number or using your own custom validation expression.

         Validate.isTrue(i >= min && i <= max, "The value must be between %d and %d", min, max);
         Validate.isTrue(myObject.isOk(), "The object is not okay");
        参数:
        expression - the boolean expression to check
        message - the String.format(String, Object...) exception message if invalid, not null
        values - the optional values for the formatted exception message, null array not recommended
        抛出:
        IllegalArgumentException - if expression is false
        另请参阅:
        isTrue(boolean), isTrue(boolean, String, long), isTrue(boolean, String, double)
      • isTrue

        public static void isTrue(boolean expression)

        Validate that the argument condition is true; otherwise throwing an exception. This method is useful when validating according to an arbitrary boolean expression, such as validating a primitive number or using your own custom validation expression.

         Validate.isTrue(i > 0);
         Validate.isTrue(myObject.isOk());

        The message of the exception is "The validated expression is false".

        参数:
        expression - the boolean expression to check
        抛出:
        IllegalArgumentException - if expression is false
        另请参阅:
        isTrue(boolean, String, long), isTrue(boolean, String, double), isTrue(boolean, String, Object...)
      • notNull

        public static <T> T notNull(T object)

        Validate that the specified argument is not null; otherwise throwing an exception.

        Validate.notNull(myObject, "The object must not be null");

        The message of the exception is "The validated object is null".

        类型参数:
        T - the object type
        参数:
        object - the object to check
        返回:
        the validated object (never null for method chaining)
        抛出:
        NullPointerException - if the object is null
        另请参阅:
        notNull(Object, String, Object...)
      • notNull

        public static <T> T notNull(T object,
                                    String message,
                                    Object... values)

        Validate that the specified argument is not null; otherwise throwing an exception with the specified message.

        Validate.notNull(myObject, "The object must not be null");
        类型参数:
        T - the object type
        参数:
        object - the object to check
        message - the String.format(String, Object...) exception message if invalid, not null
        values - the optional values for the formatted exception message
        返回:
        the validated object (never null for method chaining)
        抛出:
        NullPointerException - if the object is null
        另请参阅:
        notNull(Object)

Copyright © 2018–2021 Alibaba Group. All rights reserved.