Class Validator
java.lang.Object
de.iip_ecosphere.platform.services.spring.descriptor.Validator
A simple validator for deployment descriptors.
- Author:
- Holger Eichelberger, SSE
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static interfaceA validation function, to point generically to the private validation functions defined by this class. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate StringappendContext(String msg, String msgContext) Appends themsgContexttomsgfor output.private StringappendToContext(String context, String text) Appendstexttocontextconsidering thatcontextmay be empty or null.private booleanassertCondition(boolean condition, String msg, String msgContext) Asserts a condition.private booleanassertFieldNotNull(Object object, String field, String msgContext) Asserts thatobjectin a field is not null.private booleanassertJavaIdentifier(String name, String field, String msgContext) Asserts thatnamein a field is not null, not empty and a Java identifier.private <O> booleanassertList(List<O> list, boolean fieldNotNull, String field, String msgContext, Validator.ValidatorFunction<O> func) Asserts a list of objects that can be validated.private booleanAsserts that the given string list is either empty or strings are not empty.private booleanassertStringNotEmpty(String string, String field, String msgContext) Asserts thatstringis not empty, in particular not null.private booleanprivate booleanassertVersion(Object object, String field, String msgContext) Asserts thatobjectin a field is a version.voidclear()Clears this instance for re-use.Returns all messages as string.booleanReturns whether there are validation (error) messages.messages()Returns the validation messages.Turns the giventypesinto a map, mapping the type name to its type descriptor.voidValidates the given artifact (and contained descriptor elements).voidValidates the given endpoint (and contained descriptor elements).private voidValidates the given endpoint (and contained descriptor elements).voidvalidate(ProcessSpec process) Validates the given process (and contained descriptor elements).private voidvalidate(ProcessSpec process, String msgContext) Validates the given process (and contained descriptor elements).voidValidates the given relation (and contained descriptor elements).private voidValidates the given relation (and contained descriptor elements).voidValidates the given service (and contained descriptor elements).private voidValidates the given service (and contained descriptor elements).private voidValidates the given typed data (and contained descriptor elements).
-
Field Details
-
messages
-
serviceIds
-
-
Constructor Details
-
Validator
public Validator()
-
-
Method Details
-
hasMessages
public boolean hasMessages()Returns whether there are validation (error) messages.- Returns:
truefor messages,falsefor no messages/everything is ok
-
getMessages
Returns all messages as string.- Returns:
- all messages
-
messages
Returns the validation messages.- Returns:
- the individual messages
-
clear
public void clear()Clears this instance for re-use. -
validate
Validates the given artifact (and contained descriptor elements).- Parameters:
artifact- the artifact to validate
-
validate
Validates the given service (and contained descriptor elements).- Parameters:
service- the service to validatetypes- the declared types
-
validate
Validates the given service (and contained descriptor elements).- Parameters:
service- the service to validatetypes- the declared typesmsgContext- nested context information for location of unnamed elements in validation messages
-
toMap
Turns the giventypesinto a map, mapping the type name to its type descriptor.- Parameters:
types- the types to map- Returns:
- the mapped types
-
validate
Validates the given relation (and contained descriptor elements).- Parameters:
relation- the relation to validatetypes- the declared types
-
validate
Validates the given typed data (and contained descriptor elements).- Parameters:
typed- the typed data to validatetypes- the declared typesmsgContext- nested context information for location of unnamed elements in validation messages
-
validate
Validates the given relation (and contained descriptor elements).- Parameters:
relation- the relation to validatetypes- the declared typesmsgContext- nested context information for location of unnamed elements in validation messages
-
validate
Validates the given process (and contained descriptor elements).- Parameters:
process- the process to validate
-
validate
Validates the given process (and contained descriptor elements).- Parameters:
process- the process to validatemsgContext- nested context information for location of unnamed elements in validation messages
-
appendToContext
Appendstexttocontextconsidering thatcontextmay be empty or null.- Parameters:
context- the context to append, may be empty or nulltext- the text to append- Returns:
- the appended context information
-
validate
Validates the given endpoint (and contained descriptor elements).- Parameters:
endpoint- the endpoint to validate
-
validate
Validates the given endpoint (and contained descriptor elements).- Parameters:
endpoint- the endpoint to validatemsgContext- nested context information for location of unnamed elements in validation messages
-
assertType
- Parameters:
type- the type name to checktypes- the declared typesfield- the field the string is taken from for composing an error messagemsgContext- the context of the message/validate element for better location by the caller, ignored if empty or null- Returns:
trueif successful,falseif failed
-
assertJavaIdentifier
Asserts thatnamein a field is not null, not empty and a Java identifier.- Parameters:
name- the name to checkfield- the field the string is taken from for composing an error messagemsgContext- the context of the message/validate element for better location by the caller, ignored if empty or null- Returns:
trueif successful,falseif failed
-
assertFieldNotNull
Asserts thatobjectin a field is not null.- Parameters:
object- the object to checkfield- the field the string is taken from for composing an error messagemsgContext- the context of the message/validate element for better location by the caller, ignored if empty or null- Returns:
trueif successful,falseif failed
-
assertVersion
Asserts thatobjectin a field is a version.- Parameters:
object- the object to checkfield- the field the string is taken from for composing an error messagemsgContext- the context of the message/validate element for better location by the caller, ignored if empty or null- Returns:
trueif successful,falseif failed
-
assertList
private <O> boolean assertList(List<O> list, boolean fieldNotNull, String field, String msgContext, Validator.ValidatorFunction<O> func) Asserts a list of objects that can be validated.- Type Parameters:
O- the type of objects- Parameters:
list- the list of objects to be assertedfieldNotNull- iftrue, applyassertFieldNotNull(Object, String, String)tolistand return its result, else return alwaystruefield- the field the string is taken from for composing an error messagemsgContext- the context of the message/validate element for better location by the caller, ignored if empty or nullfunc- iflistas object/field is considered to be ok, applyfuncto each element with respective iterative context set- Returns:
trueif successful,falseif failed
-
assertStringList
Asserts that the given string list is either empty or strings are not empty.- Parameters:
list- the command line argument listfield- the field the string is taken from for composing an error messageentry- the symbolic name of an entry for composing an error messagemsgContext- the context of the message/validate element for better location by the caller, ignored if empty or null- Returns:
trueif successful,falseif failed
-
assertStringNotEmpty
Asserts thatstringis not empty, in particular not null.- Parameters:
string- the string to checkfield- the field the string is taken from for composing an error messagemsgContext- the context of the message/validate element for better location by the caller, ignored if empty or null- Returns:
trueif successful,falseif failed
-
assertCondition
Asserts a condition.- Parameters:
condition- the evaluated conditionmsg- the message ifconditiondoes not hold. A missing trailing "." is added.msgContext- the context of the message/validate element for better location by the caller, ignored if empty or null- Returns:
trueif successful,falseif failed
-
appendContext
Appends themsgContexttomsgfor output.- Parameters:
msg- the messagemsgContext- the message context- Returns:
- msg with appende context
-