Java Assert Not Null assertFieldNotNull(Object fieldValue, String fieldName)

Here you can find the source of assertFieldNotNull(Object fieldValue, String fieldName)

Description

Throws an IllegalArgumentException if the specified field is null.

License

Apache License

Parameter

Parameter Description
fieldValue The object to check.
fieldName The name of the field.

Exception

Parameter Description
IllegalArgumentException an exception

Declaration

public static void assertFieldNotNull(Object fieldValue, String fieldName) throws IllegalArgumentException 

Method Source Code

//package com.java2s;
// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *

public class Main {
    /**//  ww  w . j a v a2 s . c  o  m
     * Throws an {@link IllegalArgumentException} if the specified field is <jk>null</jk>.
     *
     * @param fieldValue The object to check.
     * @param fieldName The name of the field.
     * @throws IllegalArgumentException
     */
    public static void assertFieldNotNull(Object fieldValue, String fieldName) throws IllegalArgumentException {
        if (fieldValue == null)
            throw new IllegalArgumentException("Field '" + fieldName + "' cannot be null.");
    }
}

Related

  1. assertArgNotNull(final String argName, final Object argValue)
  2. assertArgNotNull(T obj, String name)
  3. assertArgumentNotNull(T argument, String argumentName)
  4. assertElementNotNull(Object element, Class elementClass)
  5. assertFormatResultNotNull(Object r)
  6. assertInstanceOfNotNull(Object obj, Class expClass)
  7. assertNotNull(final Object o, final String message)
  8. assertNotNull(final Object obj, final String msg)