All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.jsonparser.util.ValidationUtil Maven / Gradle / Ivy

Go to download

The library performs an operation on JSON and returns CSV data in the following output formats: String, File, and Writer.

There is a newer version: 1.1
Show newest version
package com.github.jsonparser.util;

import com.github.jsonparser.exception.JsonParsingException;

import java.util.logging.Logger;

/**
 * Useful utilities to validate dependencies
 *
 * @author Ram Alapure
 * @version 1.0
 * @since 17/02/2020
 */
public class ValidationUtil {

    public static final Logger log = Logger.getLogger(ValidationUtil.class.getName());

    private ValidationUtil() {
    }

    /**
     * 

* Asserts that the specified parameter value is not null and if it * is, throws an JsonParsingException with the specified error * message. *

* * @param object Object to assert on * @param fieldName Field name to display in exception message if null * @throws JsonParsingException */ public static void rejectNull(T object, String fieldName) throws JsonParsingException { if (object == null || (object instanceof String && object.toString().trim().length() == 0)) { String message = String.format("%s cannot be null or empty.", fieldName); log.severe(message); throw new JsonParsingException(message); } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy