Class Checker
- All Implemented Interfaces:
InterfaceChecker<AbstractChecker<Object,
Checker>, Object>
Main entry point for object validation and type checking.
The Checker class provides a fluent API for validating and inspecting objects of various types. It supports type checks, collection checks, file and URI checks, number and matrix checks, and more. Specialized checkers are returned for specific types, enabling further type-specific validation.
Example usage:
Checker.check(myList).isList(String.class).isNotEmpty(); Checker.check(myFile).isFile().exists();Checker is the main class for validating and inspecting objects of any type. It extends AbstractChecker and provides methods to check for type, structure, and content, returning specialized checkers for further validation when appropriate.
-
Field Summary
Fields inherited from class util.AbstractChecker
backObject, exceptionTracker, name, object, saveErrors, stop
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Checker
Creates a Checker for the given object with a default name.static Checker
Creates a Checker for the given object and name.CheckerArray
<?> isArray()
Checks if the object is an array and returns a CheckerArray for further validation.<T> CheckerArray
<T> Checks if the object is an array of the given class and returns a CheckerArray for further validation.Checks if the object is a BigDecimal and returns a CheckerBigDecimal for further validation.Checks if the object is a BigInteger and returns a CheckerBigInteger for further validation.Checks if the object is a Collection.isColor()
Checks if the object is a Color and returns a CheckerColor for further validation.Checks if the object is a Currency and returns a CheckerCurrency for further validation.isDouble()
Checks if the object is a Double and returns a CheckerDouble for further validation.isFile()
Checks if the object is a File and returns a CheckerFile for further validation.isFloat()
Checks if the object is a Float and returns a CheckerFloat for further validation.<N,
E extends Number>
CheckerGraph<N, E> isGraph
(Collection<N> nodes, Collection<Graph.Edge<N, E>> edges) Creates a CheckerGraph for the given nodes and edges (undirected by default).<N,
E extends Number>
CheckerGraph<N, E> isGraph
(Collection<N> nodes, Collection<Graph.Edge<N, E>> edges, boolean directed) Creates a CheckerGraph for the given nodes, edges, and directionality.<N,
E extends Number>
CheckerGraph<N, E> isGraph
(Collection<Graph.Edge<N, E>> edges) Creates a CheckerGraph for the given edges (undirected by default).<N,
E extends Number>
CheckerGraph<N, E> isGraph
(Collection<Graph.Edge<N, E>> edges, boolean directed) Creates a CheckerGraph for the given edges and directionality.<T> Checker
isInstance
(Class<T> clazz) Checks if the object is an instance of the given class.Checks if the object is an Integer and returns a CheckerInteger for further validation.isJson()
Checks if the object is a File and returns a CheckerJson for JSON file validation.CheckerList
<?> isList()
Checks if the object is a List and returns a CheckerList for further validation.<T> CheckerList
<T> Checks if the object is a List whose elements are all instances of the given class.isLong()
Checks if the object is a Long and returns a CheckerLong for further validation.CheckerMap
<?, ?> isMap()
Checks if the object is a Map and returns a CheckerMap for further validation.<K,
V> CheckerMap <K, V> Checks if the object is a Map whose keys and values are instances of the given classes.isMatrix()
Checks if the object is a matrix (2D array) and returns a CheckerMatrix for further validation.<T extends Number>
CheckerMatrix<T> Checks if the object is a matrix (2D array) of the given class and returns a CheckerMatrix for further validation.isNumber()
Checks if the object is a Number.CheckerSet
<?> isSet()
Checks if the object is a Set and returns a CheckerSet for further validation.<T> CheckerSet
<T> Checks if the object is a Set whose elements are all instances of the given class.isString()
Checks if the object is a String and returns a CheckerString for further validation.<T> CheckerTree
<T> isTree
(T rootValue) Creates a CheckerTree for the given root value.<T> CheckerTree
<T> Creates a CheckerTree for the given root value and children map.isURI()
Checks if the object is a URI and returns a CheckerURI for further validation.protected Checker
self()
Returns this Checker instance (for fluent API).Methods inherited from class util.AbstractChecker
checkProperty, checkProperty, checkProperty, end, getMethod, getObject, getProperty, hasErrors, hasNotErrors, is, is, isEqual, isNonNull, isNot, isNot, isNull, notSaveErrors, saveErrors, show, showNotThrownException, showThrownException, stop
-
Constructor Details
-
Checker
-
-
Method Details
-
self
Returns this Checker instance (for fluent API).- Specified by:
self
in classAbstractChecker<Object,
Checker> - Returns:
- this Checker
-
check
-
check
-
isInstance
-
isCollection
-
isGraph
public <N,E extends Number> CheckerGraph<N,E> isGraph(Collection<Graph.Edge<N, E>> edges, boolean directed) Creates a CheckerGraph for the given edges and directionality.- Type Parameters:
N
- node typeE
- edge weight type (extends Number)- Parameters:
edges
- the collection of edgesdirected
- true if the graph is directed- Returns:
- a CheckerGraph instance
-
isGraph
Creates a CheckerGraph for the given edges (undirected by default).- Type Parameters:
N
- node typeE
- edge weight type (extends Number)- Parameters:
edges
- the collection of edges- Returns:
- a CheckerGraph instance
-
isGraph
public <N,E extends Number> CheckerGraph<N,E> isGraph(Collection<N> nodes, Collection<Graph.Edge<N, E>> edges) Creates a CheckerGraph for the given nodes and edges (undirected by default).- Type Parameters:
N
- node typeE
- edge weight type (extends Number)- Parameters:
nodes
- the collection of nodesedges
- the collection of edges- Returns:
- a CheckerGraph instance
-
isGraph
public <N,E extends Number> CheckerGraph<N,E> isGraph(Collection<N> nodes, Collection<Graph.Edge<N, E>> edges, boolean directed) Creates a CheckerGraph for the given nodes, edges, and directionality.- Type Parameters:
N
- node typeE
- edge weight type (extends Number)- Parameters:
nodes
- the collection of nodesedges
- the collection of edgesdirected
- true if the graph is directed- Returns:
- a CheckerGraph instance
-
isList
Checks if the object is a List and returns a CheckerList for further validation.- Returns:
- a CheckerList instance
-
isList
Checks if the object is a List whose elements are all instances of the given class.- Type Parameters:
T
- the element type- Parameters:
clazz
- the class of the list elements- Returns:
- a CheckerList instance
-
isMap
Checks if the object is a Map and returns a CheckerMap for further validation.- Returns:
- a CheckerMap instance
-
isMap
Checks if the object is a Map whose keys and values are instances of the given classes.- Type Parameters:
K
- key typeV
- value type- Parameters:
clazzKey
- the class of the map keysclazzValue
- the class of the map values- Returns:
- a CheckerMap instance
-
isSet
Checks if the object is a Set and returns a CheckerSet for further validation.- Returns:
- a CheckerSet instance
-
isSet
Checks if the object is a Set whose elements are all instances of the given class.- Type Parameters:
T
- the element type- Parameters:
clazz
- the class of the set elements- Returns:
- a CheckerSet instance
-
isTree
Creates a CheckerTree for the given root value and children map.- Type Parameters:
T
- node type- Parameters:
rootValue
- the root node valuechildrenMap
- the map of children for each node- Returns:
- a CheckerTree instance
-
isTree
Creates a CheckerTree for the given root value.- Type Parameters:
T
- node type- Parameters:
rootValue
- the root node value- Returns:
- a CheckerTree instance
-
isFile
Checks if the object is a File and returns a CheckerFile for further validation.- Returns:
- a CheckerFile instance
-
isJson
Checks if the object is a File and returns a CheckerJson for JSON file validation.- Returns:
- a CheckerJson instance
- Throws:
IOException
- if file reading fails
-
isURI
Checks if the object is a URI and returns a CheckerURI for further validation.- Returns:
- a CheckerURI instance
- Throws:
IOException
- if URI reading fails
-
isNumber
-
isBigInteger
Checks if the object is a BigInteger and returns a CheckerBigInteger for further validation.- Returns:
- a CheckerBigInteger instance
-
isBigDecimal
Checks if the object is a BigDecimal and returns a CheckerBigDecimal for further validation.- Returns:
- a CheckerBigDecimal instance
-
isInteger
Checks if the object is an Integer and returns a CheckerInteger for further validation.- Returns:
- a CheckerInteger instance
-
isLong
Checks if the object is a Long and returns a CheckerLong for further validation.- Returns:
- a CheckerLong instance
-
isFloat
Checks if the object is a Float and returns a CheckerFloat for further validation.- Returns:
- a CheckerFloat instance
-
isDouble
Checks if the object is a Double and returns a CheckerDouble for further validation.- Returns:
- a CheckerDouble instance
-
isArray
Checks if the object is an array and returns a CheckerArray for further validation.- Returns:
- a CheckerArray instance
-
isArray
Checks if the object is an array of the given class and returns a CheckerArray for further validation.- Type Parameters:
T
- the element type- Parameters:
clazz
- the class of the array elements- Returns:
- a CheckerArray instance
-
isMatrix
Checks if the object is a matrix (2D array) and returns a CheckerMatrix for further validation.- Returns:
- a CheckerMatrix instance
-
isMatrix
Checks if the object is a matrix (2D array) of the given class and returns a CheckerMatrix for further validation.- Type Parameters:
T
- the element type (extends Number)- Parameters:
clazz
- the class of the matrix elements- Returns:
- a CheckerMatrix instance
-
isColor
Checks if the object is a Color and returns a CheckerColor for further validation.- Returns:
- a CheckerColor instance
-
isCurrency
Checks if the object is a Currency and returns a CheckerCurrency for further validation.- Returns:
- a CheckerCurrency instance
-
isString
Checks if the object is a String and returns a CheckerString for further validation.- Returns:
- a CheckerString instance
-