* @param definition definition
* @throws SqlResourceException if definition is invalid
*/
public static void validate(final SqlResourceDefinition definition) throws SqlResourceException {
if (definition.getQuery() == null) {
throw new SqlResourceException("Definition requires one query element");
} else if (definition.getMetadata() == null) {
throw new SqlResourceException("Definition requires one metadata element");
} else if (definition.getMetadata().getDatabase() == null
|| definition.getMetadata().getDatabase().getDefault() == null
|| definition.getMetadata().getDatabase().getDefault().length() == 0) {
throw new SqlResourceException("Definition requires one database element with default name");
} else if (getTable(definition, TableRole.Parent) == null) {
throw new SqlResourceException("Definition requires one table element with role Parent");
} else if (getTableList(definition, TableRole.Parent).size() > 1) {
throw new SqlResourceException("Definition requires one table element with role Parent");
} else if (getTableList(definition, TableRole.Child).size() > 1) {
throw new SqlResourceException("Definition requires one table element with role Child");
} else if (getTableList(definition, TableRole.Join).size() > 1) {
throw new SqlResourceException("Definition requires one table element with role Join");
}
}