Keyple Util C++ Library 2.0.0
Reference Terminal Reader API for C++
Public Member Functions | Static Public Member Functions | List of all members
keyple::core::util::Assert Class Referencefinal

#include <KeypleAssert.h>

Public Member Functions

template<typename T >
AssertnotNull (const std::shared_ptr< T > obj, const std::string &name)
 
AssertnotEmpty (const std::string &obj, const std::string &name)
 
template<typename T >
AssertnotEmpty (const std::vector< T > &obj, const std::string &name)
 
AssertnotEmpty (const std::vector< uint8_t > &obj, const std::string &name)
 
AssertisTrue (const bool condition, const std::string &name)
 
AssertgreaterOrEqual (const size_t number, const size_t minValue, const std::string &name)
 
AssertisEqual (const size_t number, const size_t value, const std::string &name)
 
AssertisInRange (const size_t number, const size_t minValue, const size_t maxValue, const std::string &name)
 
AssertisHexString (const std::string &hex, const std::string &name)
 

Static Public Member Functions

static AssertgetInstance ()
 

Detailed Description

Exposes useful methods for testing method call parameters and raising a IllegalArgumentException unchecked exception.

Since
2.0.0

Definition at line 35 of file KeypleAssert.h.

Member Function Documentation

◆ getInstance()

Assert & keyple::core::util::Assert::getInstance ( )
static

Gets the unique instance.

Returns
the instance

Definition at line 36 of file KeypleAssert.cpp.

◆ greaterOrEqual()

Assert & keyple::core::util::Assert::greaterOrEqual ( const size_t  number,
const size_t  minValue,
const std::string &  name 
)

Assert that an integer is not null and is greater than or equal to minValue.

Parameters
numberthe number to check
minValuethe min accepted value
namethe object name
Returns
the current instance
Exceptions
IllegalArgumentExceptionif number is null or has a value less than minValue.
Since
2.0.0

Definition at line 71 of file KeypleAssert.cpp.

◆ isEqual()

Assert & keyple::core::util::Assert::isEqual ( const size_t  number,
const size_t  value,
const std::string &  name 
)

Assert that an integer is equal to value.

Parameters
numberthe number to check
valuethe expected value
namethe object name
Returns
the current instance
Exceptions
IllegalArgumentExceptionif number is null or has a value less than minValue.
Since
2.0.0

Definition at line 86 of file KeypleAssert.cpp.

◆ isHexString()

Assert & keyple::core::util::Assert::isHexString ( const std::string &  hex,
const std::string &  name 
)

Assert that a string has a valid hexadecimal format.

Parameters
hexThe string to check.
nameThe object name.
Returns
The current instance.
Exceptions
IllegalArgumentExceptionIf the provided string is null, empty or has not a valid hexadecimal format.
Since
2.1.0

Definition at line 127 of file KeypleAssert.cpp.

◆ isInRange()

Assert & keyple::core::util::Assert::isInRange ( const size_t  number,
const size_t  minValue,
const size_t  maxValue,
const std::string &  name 
)

Assert that an integer is not null and is in the range minValue, maxValue.

Parameters
numberthe number to check
minValuethe min accepted value
maxValuethe max accepted value
namethe object name
Returns
the current instance
Exceptions
IllegalArgumentExceptionif number is null or is out of range.
Since
2.0.0

Definition at line 101 of file KeypleAssert.cpp.

◆ isTrue()

Assert & keyple::core::util::Assert::isTrue ( const bool  condition,
const std::string &  name 
)

Assert that a condition is true.

Parameters
conditionthe condition to check
namethe object name
Returns
the current instance
Exceptions
IllegalArgumentExceptionif condition is null or false
Since
2.0.0

Definition at line 62 of file KeypleAssert.cpp.

◆ notEmpty() [1/3]

Assert & keyple::core::util::Assert::notEmpty ( const std::string &  obj,
const std::string &  name 
)

Assert that the input string is not null and not empty.

Parameters
objthe object to check
namethe object name
Returns
the current instance
Exceptions
IllegalArgumentExceptionif object is null or empty
Since
2.0.0

Definition at line 43 of file KeypleAssert.cpp.

◆ notEmpty() [2/3]

template<typename T >
Assert & keyple::core::util::Assert::notEmpty ( const std::vector< T > &  obj,
const std::string &  name 
)
inline

Assert that a collection of objects is not null and not empty.

Parameters
objthe object to check
namethe object name
Returns
the current instance
Exceptions
IllegalArgumentExceptionif object is null or empty
Since
2.0.0

Definition at line 84 of file KeypleAssert.h.

◆ notEmpty() [3/3]

Assert & keyple::core::util::Assert::notEmpty ( const std::vector< uint8_t > &  obj,
const std::string &  name 
)

Assert that a byte array is not null and not empty.

Parameters
objthe object to check
namethe object name
Returns
the current instance
Exceptions
IllegalArgumentExceptionif object is null or empty
Since
2.0.0

Definition at line 53 of file KeypleAssert.cpp.

◆ notNull()

template<typename T >
Assert & keyple::core::util::Assert::notNull ( const std::shared_ptr< T >  obj,
const std::string &  name 
)
inline

Assert that the input object is not null.

Parameters
objthe object to check
namethe object name
Returns
the current instance
Exceptions
IllegalArgumentExceptionif object is null
Since
2.0

Definition at line 54 of file KeypleAssert.h.


The documentation for this class was generated from the following files: