Here you can find the source of assertIsPositive(int num, String fieldName)
Parameter | Description |
---|---|
num | Number to validate |
fieldName | Field name to display in exception message if not positive. |
public static int assertIsPositive(int num, String fieldName)
//package com.java2s; //License from project: Amazon Software License public class Main { /**//from w w w.jav a 2s . co m * Asserts that the given number is positive (non-negative and non-zero). * * @param num Number to validate * @param fieldName Field name to display in exception message if not * positive. * @return Number if positive. */ public static int assertIsPositive(int num, String fieldName) { if (num <= 0) { throw new IllegalArgumentException(String.format("%s must be positive", fieldName)); } return num; } }