Skip to content

Commit

Permalink
Add support for specifying whether simple (default) or full type name…
Browse files Browse the repository at this point in the history
…s will be output.
  • Loading branch information
Robert Zwerus committed Apr 14, 2015
1 parent c9fc45c commit 6f964e7
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ client start or on-demand)
- list of classes in those packages to exclude
- list of fields to exclude
- list of custom annotation classes to include in JSON
- whether to output simple or full type names
- the output file name
- Servlet offers built-in [CORS](http://en.wikipedia.org/wiki/Cross-origin_resource_sharing) support

## Use
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"excludedFields": ["com.github.valdr.demo.model.Person#ignoredField"],
"customAnnotationClasses": ["org.hibernate.validator.constraints.CreditCardNumber"],
"corsAllowOriginPattern": "*",
"outputFullTypeName": false,
"outputFile": "${project.build.directory}/${project.build.finalName}/constraints.json"
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ public String parse() {
ClassConstraints classValidationRules = new AnnotatedClass(clazz, options.getExcludedFields(),
allRelevantAnnotationClasses).extractValidationRules();
if (classValidationRules.size() > 0) {
classNameToValidationRulesMap.put(clazz.getSimpleName(), classValidationRules);
String name = options.getOutputFullTypeName() ? clazz.getName() : clazz.getSimpleName();
classNameToValidationRulesMap.put(name, classValidationRules);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@ public final class Options {
*/
private String corsAllowOriginPattern = StringUtils.EMPTY;

/**
* Whether the output type name should be the simple name of a type (default) or the full type name (i.e., including
* the package name).
*
* Mandatory: no
* Use: CLI/Servlet
*/
private Boolean outputFullTypeName = Boolean.FALSE;

/**
* File to which the validation meta-model (JSON) is written. Missing folders are created automatically. If omitted
* the output is sent to system out.
Expand Down

0 comments on commit 6f964e7

Please sign in to comment.