au.gov.nehta.vendorlibrary.clinicalpackage.util
Class Validation

java.lang.Object
  extended by au.gov.nehta.vendorlibrary.clinicalpackage.util.Validation

public final class Validation
extends java.lang.Object

Utility class for validation of a package and its contents.


Method Summary
static java.util.Map<java.lang.String,java.util.List<java.lang.String>> checkFileNameOnlyUri(java.lang.String name, java.lang.String uri)
          Confirms a URI only contains a filename, with no directories or additional path elements.
static java.util.Map<java.lang.String,java.util.List<java.lang.String>> checkMatches(java.lang.String name, java.lang.String actual, java.lang.String expected)
          Confirms a supplied string matches the expected string.
static java.util.Map<java.lang.String,java.util.List<java.lang.String>> checkNotNull(java.lang.String name, java.lang.Object value)
          Confirms an object is not null.
static java.util.Map<java.lang.String,java.util.List<java.lang.String>> checkNotNullNorBlank(java.lang.String name, java.lang.String value)
          Confirms a string is not null or blank.
static java.util.Map<java.lang.String,java.util.List<java.lang.String>> checkNotNullNorEmpty(java.lang.String name, java.util.Collection collection)
          Confirms a Collection is not null nor empty null.
static boolean isNotNull(java.lang.Object value)
          Checks if an object is not null.
static boolean isNull(java.lang.Object value)
          Checks if an object is null.
static boolean isNullOrBlank(java.lang.String value)
          Checks if a string is null or blank.
static boolean isNullOrEmpty(java.util.Collection collection)
          Checks if a collection is null or empty.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

checkNotNullNorBlank

public static java.util.Map<java.lang.String,java.util.List<java.lang.String>> checkNotNullNorBlank(java.lang.String name,
                                                                                                    java.lang.String value)
Confirms a string is not null or blank.

Parameters:
name - Name of the variable to be checked.
value - String to be checked.
Returns:
the validation failures (type Map) encountered or an empty map.

checkNotNull

public static java.util.Map<java.lang.String,java.util.List<java.lang.String>> checkNotNull(java.lang.String name,
                                                                                            java.lang.Object value)
Confirms an object is not null.

Parameters:
name - Name of the variable to be checked.
value - Object to be checked.
Returns:
the validation failures (type Map) encountered or an empty map.

checkNotNullNorEmpty

public static java.util.Map<java.lang.String,java.util.List<java.lang.String>> checkNotNullNorEmpty(java.lang.String name,
                                                                                                    java.util.Collection collection)
Confirms a Collection is not null nor empty null.

Parameters:
name - Name of the variable to be checked.
collection - Collection to be checked.
Returns:
the validation failures (type Map) encountered or an empty map.

checkFileNameOnlyUri

public static java.util.Map<java.lang.String,java.util.List<java.lang.String>> checkFileNameOnlyUri(java.lang.String name,
                                                                                                    java.lang.String uri)
Confirms a URI only contains a filename, with no directories or additional path elements.

Parameters:
name - Name to be checked.
uri - URI to be checked.
Returns:
the validation failures (type Map) encountered or an empty map.

checkMatches

public static java.util.Map<java.lang.String,java.util.List<java.lang.String>> checkMatches(java.lang.String name,
                                                                                            java.lang.String actual,
                                                                                            java.lang.String expected)
Confirms a supplied string matches the expected string.

Parameters:
name - Name of the actual variable to be checked.
actual - Supplied String to compare to the expected value.
expected - Expected String value.
Returns:
the validation failures (type Map) encountered or an empty map.

isNullOrEmpty

public static boolean isNullOrEmpty(java.util.Collection collection)
Checks if a collection is null or empty.

Parameters:
collection - Collection to be checked.
Returns:
true if the collection is null or empty (ie. size == 0); otherwise false.

isNullOrBlank

public static boolean isNullOrBlank(java.lang.String value)
Checks if a string is null or blank.

This process includes trimming Strings for leadeing and trailing whitespace to confirm whether or not they are blank.

Parameters:
value - String to be checked.
Returns:
true if the String is null, empty/blank; otherwise false.

isNull

public static boolean isNull(java.lang.Object value)
Checks if an object is null.

Parameters:
value - Object to be checked.
Returns:
true if the object is null; otherwise false.

isNotNull

public static boolean isNotNull(java.lang.Object value)
Checks if an object is not null.

Parameters:
value - Object to be checked.
Returns:
true if the object is not null; otherwise false.