MyAsserts.java 1.85 KB
Newer Older
1 2
package pwc.taxtech.atms.common.util;

3
import pwc.taxtech.atms.exception.ApiException;
4 5
import pwc.taxtech.atms.exception.FormulaException;

6 7
import java.util.Collection;

8 9 10 11
public class MyAsserts {
    public static void assertNotNull(Object obj, FormulaException exception) {
        if (obj == null) throw exception;
    }
12 13 14 15 16 17 18 19 20

    public static void assertNotNull(Object obj, ApiException exception) {
        if (obj == null) throw exception;
    }

    public static void assertTrue(boolean obj, ApiException exception) {
        if (!obj) throw exception;
    }

21 22 23 24
    public static void  assertNull(Object obj,ApiException exception){
        if(obj!=null)throw exception;
    }

25 26 27 28 29 30 31 32
    public static void assertFalse(boolean obj, ApiException exception) {
        if (obj) throw exception;
    }

    public static void assertNotEmpty(String obj, ApiException exception) {
        if (obj == null || obj.isEmpty()) throw exception;
    }

33 34 35 36
    public static void assertEmpty(String obj, ApiException exception) {
        if (obj != null && !obj.isEmpty()) throw exception;
    }

37 38 39 40
    public static void assertNotEmpty(String obj, FormulaException exception) {
        if (obj == null || obj.isEmpty()) throw exception;
    }

41 42 43 44
    public static void assertNotEmpty(Collection obj, FormulaException exception) {
        if (obj == null || obj.isEmpty()) throw exception;
    }

45 46 47
    public static void assertNotEmpty(Collection obj, ApiException exception) {
        if (obj == null || obj.isEmpty()) throw exception;
    }
48 49 50 51

    public static void assertEmpty(Collection obj, ApiException exception) {
        if (obj != null && !obj.isEmpty()) throw exception;
    }
52 53 54 55 56 57 58 59

    public static <T,S> void assertEq(T t,S s,ApiException exception){
        if(s != t) throw exception;
    }

    public static <T,S> void assertNotEq(T t,S s,ApiException exception){
        if(s == t) throw exception;
    }
60
}