Skip to content

Commit

Permalink
BVAL-512 Provide a way to include sources from the API in the spec
Browse files Browse the repository at this point in the history
  • Loading branch information
gsmet authored and gunnarmorling committed Aug 26, 2016
1 parent 3757391 commit e7114af
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 109 deletions.
35 changes: 31 additions & 4 deletions build.xml
@@ -1,8 +1,10 @@
<project name="Documentation" default="all.doc" xmlns:asciidoctor="antlib:org.asciidoctor.ant">
<property name="bv.version" value="2.0.0-SNAPSHOT" />
<property name="pdf.name" value="bean-validation-specification.pdf"/>
<property name="spec.styles.dir" value="${basedir}/styles"/>
<property name="document.basedir" value="${basedir}"/>
<property name="asciidoctor-version" value="1.5.3" />
<property name="validation-api-source-dir" value="target/validation-api/src/" />

<!-- Needed for the quick preview only -->
<property name="browser" location="/usr/bin/google-chrome"/>
Expand Down Expand Up @@ -42,12 +44,35 @@
<target name="java-build-dir-exists">
<mkdir dir="target/asciidocextensions" />
</target>
<target name="validation-api-dir-exists">
<delete dir="${validation-api-source-dir}/javax/" />
<mkdir dir="${validation-api-source-dir}" />
</target>

<!-- we update the dependency every time we build as it might have changed on disk -->
<target name="detect-validation-api-in-m2">
<available file="${user.home}/.m2/repository/javax/validation/validation-api/${bv.version}/validation-api-${bv.version}-sources.jar" property="validation-api-in-m2"></available>
</target>
<target name="unzip-validation-api-from-repo" depends="validation-api-dir-exists, detect-validation-api-in-m2" unless="validation-api-in-m2">
<get src="http://repo.maven.apache.org/maven2/javax/validation/validation-api/${bv.version}/validation-api-${bv.version}-sources.jar"
dest="target/validation-api/"
skipexisting="true"/>
<unzip src="target/validation-api/validation-api-${bv.version}-sources.jar" dest="${validation-api-source-dir}"></unzip>
</target>
<target name="unzip-validation-api-from-m2" depends="validation-api-dir-exists, detect-validation-api-in-m2" if="validation-api-in-m2">
<unzip src="${user.home}/.m2/repository/javax/validation/validation-api/${bv.version}/validation-api-${bv.version}-sources.jar" dest="${validation-api-source-dir}"></unzip>
</target>
<target name="have-validation-api" depends="unzip-validation-api-from-repo,unzip-validation-api-from-m2">
</target>

<target name="have-asciidoctor" depends="lib-dir-exists">
<get src="http://repo1.maven.org/maven2/org/asciidoctor/asciidoctor-ant/${asciidoctor-version}/asciidoctor-ant-${asciidoctor-version}.jar"
<get src="http://repo.maven.apache.org/maven2/org/asciidoctor/asciidoctor-ant/${asciidoctor-version}/asciidoctor-ant-${asciidoctor-version}.jar"
dest="lib/asciidoctor-ant-${asciidoctor-version}.jar"
skipexisting="true"/>
</target>

<target name="have-dependencies" depends="have-asciidoctor, have-validation-api">
</target>

<macrodef name="renderer">
<attribute name="outputdirectory" />
Expand All @@ -63,19 +88,21 @@
<blockProcessor blockName="tck-testable" className="org.beanvalidation.asciidocextensions.CustomRoleBlockProcessor" />
<blockProcessor blockName="tck-not-testable" className="org.beanvalidation.asciidocextensions.CustomRoleBlockProcessor" />
<blockProcessor blockName="tck-ignore" className="org.beanvalidation.asciidocextensions.CustomRoleBlockProcessor" />
<attribute key="tabsize" value="4" />
<attribute key="validation-api-source-dir" value="../${validation-api-source-dir}" />
</asciidoctor:convert>
</sequential>
</macrodef>

<target name="render-html" depends="clean-htmloutput, have-asciidoctor, html-output-dir-exists, compile-asciidoc-extensions">
<target name="render-html" depends="clean-htmloutput, have-dependencies, html-output-dir-exists, compile-asciidoc-extensions">
<renderer outputdirectory="target/html" backend="html" />
</target>

<target name="render-docbook" depends="clean-docbookoutput, have-asciidoctor, docbook-output-dir-exists, compile-asciidoc-extensions">
<target name="render-docbook" depends="clean-docbookoutput, have-dependencies, docbook-output-dir-exists, compile-asciidoc-extensions">
<renderer outputdirectory="target/docbook" backend="docbook" />
</target>

<target name="render-pdf" depends="clean-pdfoutput, have-asciidoctor, pdf-output-dir-exists, compile-asciidoc-extensions">
<target name="render-pdf" depends="clean-pdfoutput, have-dependencies, pdf-output-dir-exists, compile-asciidoc-extensions">
<renderer outputdirectory="target/pdf" backend="pdf" />
</target>

Expand Down
107 changes: 2 additions & 105 deletions sources/validation-api.asciidoc
Expand Up @@ -20,112 +20,9 @@ A [classname]`Validator` instance is able to validate instances of beans and the
.Validator interface
====
[source, JAVA]
[source, JAVA, indent=0]
----
/**
* Validates bean instances. Implementations of this interface must be thread-safe.
*
* @author Emmanuel Bernard
* @author Hardy Ferentschik
* @author Gunnar Morling
*/
public interface Validator {
/**
* Validates all constraints on {@code object}.
*
* @param object object to validate
* @param groups the group or list of groups targeted for validation (defaults to
* {@link Default})
* @return constraint violations or an empty set if none
* @throws IllegalArgumentException if object is {@code null}
* or if {@code null} is passed to the varargs groups
* @throws ValidationException if a non recoverable error happens
* during the validation process
*/
<T> Set<ConstraintViolation<T>> validate(T object, Class<?>... groups);
/**
* Validates all constraints placed on the property of {@code object}
* named {@code propertyName}.
*
* @param object object to validate
* @param propertyName property to validate (i.e. field and getter constraints)
* @param groups the group or list of groups targeted for validation (defaults to
* {@link Default})
* @return constraint violations or an empty set if none
* @throws IllegalArgumentException if {@code object} is {@code null},
* if {@code propertyName} is {@code null}, empty or not a valid object property
* or if {@code null} is passed to the varargs groups
* @throws ValidationException if a non recoverable error happens
* during the validation process
*/
<T> Set<ConstraintViolation<T>> validateProperty(T object,
String propertyName,
Class<?>... groups);
/**
* Validates all constraints placed on the property named {@code propertyName}
* of the class {@code beanType} would the property value be {@code value}.
* <p/>
* {@link ConstraintViolation} objects return {@code null} for
* {@link ConstraintViolation#getRootBean()} and {@link ConstraintViolation#getLeafBean()}.
*
* @param beanType the bean type
* @param propertyName property to validate
* @param value property value to validate
* @param groups the group or list of groups targeted for validation (defaults to
* {@link Default}).
* @return constraint violations or an empty set if none
* @throws IllegalArgumentException if {@code beanType} is {@code null},
* if {@code propertyName} is {@code null}, empty or not a valid object property
* or if {@code null} is passed to the varargs groups
* @throws ValidationException if a non recoverable error happens
* during the validation process
*/
<T> Set<ConstraintViolation<T>> validateValue(Class<T> beanType,
String propertyName,
Object value,
Class<?>... groups);
/**
* Returns the descriptor object describing bean constraints.
* <p/>
* The returned object (and associated objects including
* {@link ConstraintDescriptor}s) are immutable.
*
* @param clazz class or interface type evaluated
* @return the bean descriptor for the specified class
* @throws IllegalArgumentException if clazz is {@code null}
* @throws ValidationException if a non recoverable error happens
* during the metadata discovery or if some
* constraints are invalid.
*/
BeanDescriptor getConstraintsForClass(Class<?> clazz);
/**
* Returns an instance of the specified type allowing access to
* provider-specific APIs.
* <p/>
* If the Bean Validation provider implementation does not support
* the specified class, {@link ValidationException} is thrown.
*
* @param type the class of the object to be returned
* @return an instance of the specified class
* @throws ValidationException if the provider does not support the call
*/
<T> T unwrap(Class<T> type);
/**
* Returns the contract for validating parameters and return values of methods
* and constructors.
*
* @return contract for method and constructor validation
*
* @since 1.1
*/
ExecutableValidator forExecutables();
}
include::{validation-api-source-dir}javax/validation/Validator.java[lines=25..-1]
----
====
Expand Down

0 comments on commit e7114af

Please sign in to comment.