pax_global_header 0000666 0000000 0000000 00000000064 12364444513 0014520 g ustar 00root root 0000000 0000000 52 comment=49102a88eaa370ecb72c113ecac5d8733ebcab34
hibernate-validator-4.2.1.Final/ 0000775 0000000 0000000 00000000000 12364444513 0016500 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/.gitignore 0000664 0000000 0000000 00000001070 12364444513 0020466 0 ustar 00root root 0000000 0000000 # Typically *NIX text editors, by default, append '~' to files on saving to make backups
*~
# Gradle work directory
.gradle
buildSrc/.gradle
# Build output directories
/target
*/target
/build
*/build
/bin
*/bin
# Test output directories
test-output
*/test-output
# IntelliJ specific files/directories
/out
.idea
*.ipr
*.iws
*.iml
atlassian-ide-plugin.xml
# Eclipse specific files/directories
.classpath
.project
.settings
.factorypath
# NetBeans specific files/directories
.nbattrs
# Sublime
*.sublime-project
*.sublime-workspace
# Miscellaneous
*.log
.clover
hibernate-validator-4.2.1.Final/changelog.txt 0000664 0000000 0000000 00000071020 12364444513 0021170 0 ustar 00root root 0000000 0000000 Hibernate Validator Changelog
==========================
4.2.1.Final (25.07.2014)
------------------------
** Task
* [HV-912] - Improve integration with Java's security manager
4.2.0.Final (20.06.2011)
----------------------
** Improvement
* [HV-315] - Create package-level JavaDoc for the AP
* [HV-485] - Determine an order for the constraint mapping fluent API
* [HV-486] - Remove getMethod() from MethodConstraintViolation
* [HV-490] - Create @SafeHtml annotation
* [HV-493] - Add support for Brazilian Portuguese for ValidationMessages
** New Feature
* [HV-372] - Add section to method-level validation to the HV reference guide
** Task
* [HV-489] - Upgrade dependency to BV TCK to 1.0.5.GA
* [HV-494] - upgrade to hibernate-jpa-2.0-api-1.0.1.Final
* [HV-497] - Create aggregated javadocs for the distribution and deployment on docs server
4.2.0.CR1 (09.06.2011)
----------------------
** Bug
* [HV-406] - URL Validator not effective
* [HV-437] - Improve the javadocs of the URL constraints
* [HV-447] - Create documentation for boolean composition of composing constraints
* [HV-452] - Incorrect Paths when using fluent API to add constraints to a context
* [HV-458] - Wrong behaviour determining default group constraints in conjunction with @GroupSequence
* [HV-459] - Run TCK against AS 7
* [HV-466] - Avoid repeated validation of constraints in certain type hierarchies
* [HV-468] - Determine whether a property is indexed based on the runtime not static type
* [HV-470] - resolvedMessages in ResourceBundleMessageInterpolator needs to be synchronized
** Improvement
* [HV-407] - Update "Presentation layer validation" section
* [HV-417] - Add section on public API and it's changes to the reference guide
* [HV-434] - ValidatorImpl#shouldFailFast() and ValidationContext#shouldFailFast() seem redundant
* [HV-442] - Make clear in the documentation which types are supported for built-in constraints
* [HV-446] - The annotation processor should allow constraint annotations at non-getter methods
* [HV-449] - Remove interface check in BeanMetaDataImpl#newGroupSequenceProviderInstance()
* [HV-453] - Add an example of default group sequence provider configuration with the programmatic API
* [HV-454] - Fix a mistake in the reference guide about custom properties supported by Hibernate Validator
* [HV-461] - Refactor TestUtil class
* [HV-475] - Add required and public packages to the OSGi manifest
* [HV-488] - Rename MethodDescriptor#getParameterConstraints() method
** New Feature
* [HV-436] - The annotation processor should check @GroupSequenceProvider
** Patch
* [HV-483] - ValidationMessages translation to Spanish
** Task
* [HV-400] - Align the configuration of the archetype plugin with the configuration in search
* [HV-431] - Extend programmatic API to allow the definition of method level constraints
* [HV-464] - Remove obsolete type parameter from ParameterMetaConstraint
* [HV-471] - Group has to be an interface - Documentation or code bug
* [HV-474] - Get Hibernate Validator a proper changelog file
* [HV-487] - Settle on an approach for instantiating constraint definitions
4.2.0.Beta2 (09.02.2011)
------------------------
** Bug
* [HV-376] - validateValue() and validateProperty() are too restrictive regarding processable property names
* [HV-381] - Provide a fail fast switch to stop processing constraints on first failure
* [HV-414] - Assembly plugin fails with maven 3.0.1
* [HV-418] - The annotation processor shouldn't report @Past/@Future given at Joda types as errors
* [HV-421] - Reconsider behavior of parameter validation for inheritance hierarchies
* [HV-422] - slf4j version in hibernate-validator
* [HV-426] - Wrong name in version logging message
* [HV-428] - Java 1.6 specific method used in programmatic validation API
* [HV-429] - validateValue and validateProperty using wrong default group sequence
* [HV-430] - XML configuration does not allow configuration of public fields in superclass
* [HV-433] - Cascaded validation on superclass fields does not work if only @Valid is used
* [HV-444] - Default group sequence defined with programmatic API is not used if the configured class doesn't define programmatic constraints
** Improvement
* [HV-415] - Rename validateParameters to validateAllParameters
* [HV-419] - Update the dependency to slf4j-api to 1.6.x
* [HV-424] - Validators for Joda types should be specified for ReadableInstant/ReadablePartial
** New Feature
* [HV-94] - Support dynamic default group sequence definition
* [HV-371] - Support method-level constraints in meta-data API
** Task
* [HV-420] - Deprecate legacy validator
* [HV-440] - Extend programmatic API to allow the definition of default group sequence provider
4.2.0.Beta1 (13.01.2011)
------------------------
** Sub-task
* [HV-367] - Evaluate @Valid annotation given at parameters
* [HV-368] - Evaluate @Valid annotation given at return values
* [HV-369] - Evaluate constraint annotations given at parameters
* [HV-370] - Evaluate constraint annotations given at return values
** Bug
* [HV-350] - Inherited Bean validates non-default constraints as default
* [HV-352] - In some cexceptional cases the original stacktrace is not preserved
* [HV-355] - RangeDef's min() and max() are just wrong
* [HV-362] - Including Annotation Processor in Eclipse results in java.lang.OutOfMemoryError: Java heap space
* [HV-363] - HV uses Thread's context class loader to load internal implementation classes
* [HV-374] - NoSuchMethodError on Persistence.getPersistenceUtil() on WebLogic 10.3.3 (11g)
* [HV-379] - Remove obsolete dependency exlusion from tck-runner pom
* [HV-382] - "java.lang.NoSuchMethodError: java.lang.String.isEmpty" in ScriptAssertValidator.java
* [HV-384] - Performence problem when using programatic constrain declaration
* [HV-385] - Typo in German validation messages
* [HV-387] - org.hibernate.validator.cfg.defs.GenericConstraintDef should (probably) not extend the raw type ConstraintDef
* [HV-391] - Review assertions of @Past and @Future tests
* [HV-395] - Align Path.Node implementation with the Bean Validation specification
* [HV-396] - Build for hibernate-validator module fails using Maven 3 due to problem with the maven-shade-plugin
* [HV-398] - Build of Hibernate Validator Quickstart failed with another default locale than en
* [HV-402] - Make sure that Validator still works on JDK 5 due to ValueMessageInterpolator
* [HV-403] - Create a ValueMessageInterpolator based on java.text.Format instead of the scripting engine
* [HV-405] - Hibernate validator doesn't work well on JDK5
* [HV-408] - Validator throws wrongly an exception for constraints placed on non-getter methods
** Improvement
* [HV-346] - Improve some of the default debug/info messages
* [HV-353] - Support inheritance for group validation
* [HV-359] - chinese message template
* [HV-365] - It is very hard to find the HV annotation processor
* [HV-366] - The documentation refers to http://repository.jboss.com/maven2: this should be fixed to point to the new maven settings
* [HV-410] - Clarify the license on both the website and the reference documentation
* [HV-412] - Move GenericConstraintDef into org.hibernate.validator.cfg
** New Feature
* [HV-299] - Annotation processor should check constraint annotation type declarations
* [HV-307] - Support @Past/@Future annotations at types from the Joda Time API
* [HV-347] - Create method level validation
* [HV-357] - Create a chapter for the reference guide describing the meta-data API
* [HV-358] - Create a pluggable MessageInterpolator which can interploate ${value}
* [HV-390] - Boolean composition of constraints
* [HV-401] - Ensure that the default validation provider is Hibernate Validator in LazyValidatorFactory
** Task
* [HV-327] - Update TCK runner dependecies to not depend on the JBoss deprecated repo
* [HV-348] - Add note to JPA integration section about access type when using lazy loaded OneToOne and ManyToOne associations
* [HV-349] - Hungarian translation for ValidationMessages.properties
* [HV-351] - Translate hv document into chinese
* [HV-375] - Update jboss-testharness and bv tck dependecies
* [HV-378] - Cleanup the pom
* [HV-383] - Update VCS information in pom
* [HV-386] - Move readme.txt into top level directory
* [HV-392] - Update entity-manager tests dependecy to 3.6.0.Final
* [HV-393] - Version class should get the version injected via the maven-injection-plugin
* [HV-394] - Change log level from info to debug in DefaultTraversableResolver
* [HV-413] - Activate chinese transalation, update po and pot files and make sure that the translation gets included in the dist bundle
4.1.0.Final (21.06.2010)
------------------------
** Bug
* [HV-335] - @Max, @Min, @DecimalMax and @DecimalMin can give wrong results
* [HV-339] - ^ not allowed in Email
* [HV-343] - Package type in the documentation example
** Improvement
* [HV-338] - Move the discovery of constraint types into the constructor of ConstraintTree
* [HV-340] - When checking for composing constraints ignore annotations like @Target, @Documented, ...
* [HV-341] - Reduce the amounf of Annotation.annotationType() calls since reflection calls are expensive
* [HV-342] - Reduce the amout of calls to ConstraintHelper.isMultiValueConstraint
* [HV-344] - Add example for configuring hibernate validator through Spring session factory bean
** Task
* [HV-334] - Stop hibernate-validator-legacy to be deployed in the maven repo
* [HV-336] - Remove deprecated constructor in ResourceBundleMessageInterpolator
* [HV-337] - Update documentation regarding the effects of @Length during DDL generation
4.1.0.CR1 (14.06.2010)
----------------------
** Bug
* [HV-332] - Investigate the usage of CachingResourceBundleLocator in ResourceBundleMessageInterpolator
* [HV-333] - Verify that MessageInterpolatorContext.getValidatedValue returns the right value
** Task
* [HV-331] - Investigate use of field/method.setAccessible( true )
4.1.0.Beta2 (02.06.2010)
------------------------
** Bug
* [HV-281] - validation of a persisted map
* [HV-293] - Annotation processor fails in Eclipse when evaluating custom constraints not defined in the current project
* [HV-305] - JPATraversableResolver tries to access properties that do not exist
* [HV-306] - Falling back to system´s default locale if chosen locale was EN
* [HV-309] - POM file's content-type is text/plain
* [HV-312] - Close all input streams opened by HV
* [HV-319] - Example in online documention reference javax.validation.ConstraintPayload instead of javax.validation.Payload
* [HV-321] - javax.persistence.PersistenceException when trying to validate an object graphs with a class-level constraint annotation. In addition to the error report HV-266
* [HV-323] - URL Validator needs to pass on empty Strings
* [HV-324] - Default annotation not executing when group selector activated
* [HV-326] - Verify that for caching user objects during the validation process we use a IdentityHashMap or IdentityHashSet
* [HV-328] - Configuration.addMapping( null ) should throw IllegalArgumentException
* [HV-329] - Update quickstart section and remove reference to archetype catalog
** Improvement
* [HV-156] - Exploring properties and cascade is unnecessary if TraversableResolver returns false
* [HV-298] - Add a section on using the annotation processor to the HV reference guide
* [HV-302] - JAXB shouldn't be required when not using XML configuration
* [HV-310] - Define, which parts of HV constitute its public API
* [HV-313] - Extract messaging related stuff from ConstraintAnnotationVisitor
* [HV-314] - Add @List annotations to the HV-specific constraints
* [HV-316] - Extract constraint checking from ConstraintAnnotationVisitor into separate check classes
* [HV-322] - Establish a processor option "verbose"
** New Feature
* [HV-230] - Database Connective or @Unique
* [HV-274] - Write a programmatic mapping API for constraint declarations
* [HV-292] - Provide a constraint annotation @ScriptAssert
** Patch
* [HV-151] - The mongolian validation message translation patch.
** Task
* [HV-311] - Update pom to use the new distributationManagement information
* [HV-317] - Rename Global- and LocalExecutionContext
* [HV-325] - Align javadoc styles with the Core javadoc styles
* [HV-330] - Add a new constructor to ResourceBundleMessageInterpolator which enable/disables internal message caching
4.1.0.Beta1 (24.03.2010)
------------------------
** Bug
* [HV-246] - BeanValidationEventListener has a bug (technically a problem with hibernate-annotations 3.5.0beta1... but I couldn't find that project)
* [HV-261] - Invalid license info
* [HV-266] - NullPointerException when trying to validate an object with a class-level constraint annotation.
* [HV-272] - jaxb dependencies should be dependencies with scope 'provided' instead of profile dependencies
* [HV-275] - Update french message template for @Email
* [HV-279] - Validator docbook files still reference GPL
* [HV-288] - The validator doesn't validate correctly groups composing a group sequence
* [HV-290] - Check the right copyright header is used in documenation
* [HV-291] - ConstraintViolation not serializable for composed constraints
* [HV-294] - Annotation processor should raise an error when @Valid is given at wrong places
* [HV-297] - Custom error messages built via ConstraintValidatorContext get ignored when constraint uses @ReportAsSingleViolation
* [HV-300] - Relocation from com.googlecode.jtype to org.hibernate.validator.jtype didn't catch all references
** Improvement
* [HV-251] - ResourceMessageInterpolater - allow create with map of user resource bundles
* [HV-267] - Enhance distribution jar to make it OSGi bundle
* [HV-278] - ValidationMessages_de.properties spelling: "erwartet" instead of "erwarted"
* [HV-287] - French translation is not complete
** New Feature
* [HV-229] - @Url needs to be added
* [HV-238] - Introduce a ResourceBundleLocatorStrategy interface which allows the ResourceBundleMessageInterpolator to delegate the loading of the resource bundle
* [HV-269] - Create an annotation processor validating constraint and property matching
* [HV-301] - Add a trim property to @NotEmpty please
** Patch
* [HV-227] - hibernate validator message for turkish locale
* [HV-284] - Documentation fixes for hibernate-core integration
* [HV-286] - NoSuchMethodError on Persistence.getPersistenceUtil() when one follows the README file
** Task
* [HV-141] - Use commons-annotations to apply the configuration specified in XML
* [HV-254] - Add section about ConstraintValidatorContext to documentation
* [HV-273] - Upgrade jtype and jpa2 dependency
* [HV-276] - Make sure that all used maven plugins specify their version explicitly
* [HV-282] - Create CreditCardValidator
* [HV-283] - Remove the legacy module from the main aggregator
* [HV-289] - Add requirements section to online manual about usage of Validator in JDK 5 and 6
4.0.2.GA (06.11.2009)
---------------------
** Bug
* [HV-263] - NullPointerException when no constraint in xml
* [HV-265] - Constraints not loaded consistently for inherited classes
* [HV-268] - Wrong message templates for @Email and @Range
4.0.1.GA (28.10.2009)
---------------------
** Bug
* [HV-250] - No validator could be found for type: T
* [HV-252] - HV with XML config tells me "Invalid property path." even though I know there is such a property.
* [HV-255] - Improve error handling for validateValue and validateProperty
* [HV-257] - ReflectionHelper.getValue fails to retrieve values from methods defined on a parent interface
* [HV-258] - The documentation for HV contains a invalid reference in section 2.1.3 class level constraints
* [HV-262] - Using interface in xml configuration does not work
** Improvement
* [HV-253] - Fluent API to add path nodes is not flexible enough
** Task
* [HV-259] - Add a payload example to the documentation
4.0.0.GA (08.10.2009)
---------------------
** Sub-task
* [HV-217] - ValidatorResolutionTest#testResolutionOfMultipleSizeValidators uses generics in the constraintValidator resolution
* [HV-218] - Validator implementation resolution is based on the returned value (at runtime) instead of the returned type
* [HV-222] - MessageInterpolationTest#testFallbackToDefaultLocale
* [HV-223] - BeanDescriptorTest#testGetConstraintsForNullProperty should be mapped
* [HV-224] - ConstraintValidatorContextTest#testDisableDefaultErrorWithoutAddingCustomError should raise a ValidationException
* [HV-225] - Tests in GroupSequenceIsolationTest and NestedConstraintCompositionTest need to be mapped or moved to the HV test suite
* [HV-244] - Cache the type to ConstraintValidator class computation per constraint declaration
** Bug
* [HV-134] - Built-in constraint parameter validation
* [HV-180] - Failure when compiling Hibernate Validator
* [HV-199] - Various TCK issues
* [HV-213] - Should we mark ConstraintViolation as Serializable?
* [HV-231] - Add default messages for DecimalMin and DecimalMax to resource bundle
* [HV-234] - make sure int[] is converted in Integer[] when needed by a constraintValidator call
* [HV-249] - findConstraints() .unorderedAndMatchingGroups in ElementDescriptor honors default sequence overriding
** Improvement
* [HV-129] - ResourceBundleMessageInterpolatorTest should not test ResourceBundleMessageInterpolato but rather the Bean Validation provider default bundle
* [HV-132] - Support hasBoolean format
* [HV-235] - More useful exception error messages
* [HV-236] - Spring/Hibernate integration, and maven suggestions
* [HV-239] - Rename ValidatorConfiguration to HibernateValidatorConfiguration and move from o.h.v.engine to o.h.v package
* [HV-240] - Replace Red Hat Middleware LLC to Red Hat, Inc. and/or its affiliates
* [HV-242] - Cache ConstraintValidator instances per ValidatorFactory and not per ConstraintTree
* [HV-245] - Make ConstraintViolation + Path implementations Serializable
** Task
* [HV-220] - Complete documentation
* [HV-221] - Create a JPAValidateListener equivalent in the new hibernate validator
* [HV-232] - Modify the BeanValidationEventListener in the annotation project to be configurable via the hibernate config file
* [HV-233] - Make sure jtype implements the following rules
* [HV-237] - Add a toString implementation to ConstraintViolationImpl
* [HV-241] - Add @Email and @Range constraints
* [HV-247] - Implement latest changes to meta data API in ri
4.0.0.CR1 (27.08.2009)
----------------------
** Sub-task
* [HV-200] - ValidationProviderResolverTest#testValidationExceptionIsThrownInCaseValidatorFactoryCreationFails => enable=false?
* [HV-201] - BootstrapTest#testServiceFileExists shouldn't we test for the actual provider passing the TCK ie get the right name?
* [HV-202] - BootstrapTest#testCustomMessageInterpolatorViaConfiguration is not testing via configuration but via validator context (ie like testCustomMessageInterpolatorViaValidatorContext)
* [HV-203] - MappingStreamHandlingTest#testMappingStreamGetsClosed and testMappingStreamGetsClosedInExceptionalCondition are wrong and a failure for HV
* [HV-206] - CustomConstraintValidatorTest#testNonInterpolatedMessageParameterIsUsed assumes English locale, needs fix before commented line reactivation
** Bug
* [HV-183] - Composite constraints have to honour the payload parameter as well
* [HV-191] - JPA 2 Dependency
* [HV-208] - Wrong Path in ConstraintViolation
* [HV-209] - Correctly handle configured in xml
* [HV-210] - XML constraint declaration with missing mandatory elements throws IllegalArgumentException insteadof ValidationException
* [HV-212] - Group sequence resolution has to take sequence order of composing groups (via inheritance or other group sequence) into account
* [HV-214] - Constraints from interfaces and superclasses are not inherited when XML descriptors are used
* [HV-216] - Add the payload parameter to the xml configuration
** Improvement
* [HV-185] - Change package name in codebase from org.hibernate.validation to org.hibernate.validator
* [HV-189] - ResourceBundleMessageInterpolator should cache the interpolation results for step 1-3 of the interpolation algorithm
** New Feature
* [HV-91] - Make sure Validator is thread-safe in the RI
* [HV-176] - Return the list of matching ConstraintDescriptor for a given set of groups
** Task
* [HV-99] - Write unit tests for bootstrapping
* [HV-140] - Review all unchecked warnings
* [HV-188] - Cleanup ElementDescriptorImpl after we depend on bv api post CR3
* [HV-211] - Class name refactoring
* [HV-215] - Rename ConstraintPayload to Payload
4.0.0.Beta3 (12.08.2009)
------------------------
** Bug
* [HV-124] - Hundreds of raw type use across the codebase
* [HV-186] - ResourceBundleMessageInterpolator has to allow all characters as message parameter
* [HV-187] - An exception occuring during a cal to the TraversableResolver has to be wrapped in a ValidationException
* [HV-190] - The Path implementation has to be matched with the specification
* [HV-192] - DigitsValidatorForNumber should strip trailing zeros
* [HV-193] - @OverridesAttribute.index starts at 0, not 1
* [HV-194] - Loading XML resources leads to NPE if the context classloader is not set
* [HV-196] - validateValue incorrectly reports java.lang.IllegalArgumentException on non constrained properties
* [HV-198] - Wrong constraint violation path when adding subnode error to subnode
** Improvement
* [HV-171] - Hibernate Validator must specify how to run in environments that use a SecurityManager
* [HV-195] - Be permissive to heading '/' in mapping file names
** New Feature
* [HV-197] - Implement a LazyValidatorFactory
4.0.0.Beta2 (20.07.2009)
------------------------
** Bug
* [HV-79] - The test suite assumes Hibernate Validator as the BV provider
* [HV-146] - ConstraintValidator impls cannot inherit from a super class implementing ConstraintValidator
* [HV-149] - ReflectionHelper.containsMethod ignores "is" methods
* [HV-150] - TraversableResolver pathToTraversableObject incorrectly includes traversableProperty
* [HV-153] - ConstraintValidators created out of CVF should be cached to minimize initialization overhead
* [HV-154] - isTraversable is called with a root bean class null when validateValue is used
* [HV-157] - properties are cascaded despite TraversableResolver answering no
* [HV-158] - ClassCastException in org.hibernate.validation.constraints.FutureValidatorForDate.initialize
* [HV-159] - NullPointerException in ValidatorFactoryImpl, if XML config file doesn't contain at least one constraint and one cascade configuration
* [HV-162] - XML based configuration should be tolerant to line breaks and white spaces where appropriate
* [HV-164] - Add test for default group sequence isolation
* [HV-165] - Hibernate Validator does not validate groups in class level annotations.
* [HV-169] - Make sure Validator is concurrent safe
* [HV-170] - Refactor the group sequence expansion and take the default sequence expansion of the validated entity into considertation
* [HV-172] - Static fields and methods annotated with constraints should be ignored
* [HV-173] - @Valid on an array type does not properly validate the elements of the array
* [HV-174] - When using Matcher.appendReplacement all \ and $ characters must be escaped
* [HV-175] - @Valid should be polymorphic
* [HV-181] - Refactor ConstraintDescriptorImpl
* [HV-182] - Error when using composite constraints (wrong messages and stack traces)
* [HV-184] - ResourceBundlerMessageInterpolator fails to meet the spec in some issues
** Improvement
* [HV-155] - Use a TraversableResolver caching results within a call stack to reduce overhead
* [HV-166] - Move constraints validator impl into org.hibernate.validation.constraints.impl
* [HV-167] - Rewrite @NotEmpty as a composition of @NotNull, @Size(min=1) @ReportAsSingleViolation
** New Feature
* [HV-89] - Implement XML mapping
* [HV-97] - Support XML Configuration and merge of configuration metadata
* [HV-131] - Support @DecimalMin / @DecimalMax
* [HV-160] - Make use of the TraversableResolver contract spliting reachability and cascadability
* [HV-163] - Add [] to non-indexed iterable in paths
** Task
* [HV-101] - Write unit tests for constraint composition
* [HV-107] - Implement a Hibernate Core specifc implementation of TraversableResolver
* [HV-109] - Implement test for bootstrapping with multiple providers
* [HV-127] - Implement test for the different types of Size validators
* [HV-133] - Create test baseclass to allow test to run w and w/o xml configuration
* [HV-147] - Invetigate problem with maven release plugin
* [HV-148] - Make sure that context as well as current class loader are used when trying to load xml configuration files
* [HV-168] - Add validators for DecimalMin and DecimalMax
* [HV-177] - Integrate the new Path model
* [HV-178] - Add check for payload parameter
4.0.0.Beta1 (27.04.2009)
------------------------
** Bug
* [HV-139] - BeanMetaDataCache and ConstraintValidatorDefinitionsCache should not be static
** New Feature
* [HV-144] - Add support for ConstraintViolation.getRootBeanClass
** Task
* [HV-110] - Implement parser for validation.xml
* [HV-111] - Bootstrap HV using validation.xml
* [HV-112] - Map constraints using XML
* [HV-137] - Create a Hibernate Validator maven archetype
* [HV-142] - Extract the xml parsing code from ValidatorFactoryImpl and delegate the parsing to a seperate class
4.0.0.Alpha3 (20.03.2009)
-------------------------
** Bug
* [HV-78] - ValidatorImpl.expandGroupName() does not seem to expand recursively, this goes against the spec
* [HV-80] - Group sequence sequences can contain group sequence names
* [HV-83] - Object graph traversed too many times
* [HV-85] - Group sequence expansion and validation execution should be decoupled
* [HV-117] - BuiltinConstraints doesn't contain @Digits
* [HV-118] - BuiltinConstraints doesn't contain @Past
* [HV-120] - ConstraintDescriptor.getGroups() returns Default.class if no group is declared on the constraint
* [HV-123] - Wrong elementType in MetaConstraint constructor
** Improvement
* [HV-103] - Default error message for Min/Max constraints doesn't reflect constraint specification and implementation
** New Feature
* [HV-92] - Implement sequences on group interfaces and group inheritance
* [HV-121] - @Pattern support
* [HV-122] - Add byte support for numeric constraints (digits, max etc)
** Task
* [HV-106] - Integrate TraversableResolver into reference implementation
* [HV-108] - Verify correct polymorphic behaviour for validation
* [HV-113] - Redefining the Default group for a class
* [HV-114] - Implement error report customization via ConstraintValidatorContext
4.0.0.Alpha2 (03.03.2009)
-------------------------
** Bug
* [HV-78] - ValidatorImpl.expandGroupName() does not seem to expand recursively, this goes against the spec
* [HV-80] - Group sequence sequences can contain group sequence names
* [HV-83] - Object graph traversed too many times
* [HV-85] - Group sequence expansion and validation execution should be decoupled
* [HV-117] - BuiltinConstraints doesn't contain @Digits
* [HV-118] - BuiltinConstraints doesn't contain @Past
* [HV-120] - ConstraintDescriptor.getGroups() returns Default.class if no group is declared on the constraint
* [HV-123] - Wrong elementType in MetaConstraint constructor
** Improvement
* [HV-103] - Default error message for Min/Max constraints doesn't reflect constraint specification and implementation
** New Feature
* [HV-92] - Implement sequences on group interfaces and group inheritance
* [HV-121] - @Pattern support
* [HV-122] - Add byte support for numeric constraints (digits, max etc)
** Task
* [HV-106] - Integrate TraversableResolver into reference implementation
* [HV-108] - Verify correct polymorphic behaviour for validation
* [HV-113] - Redefining the Default group for a class
* [HV-114] - Implement error report customization via ConstraintValidatorContext
hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/ 0000775 0000000 0000000 00000000000 12364444513 0026611 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/pom.xml 0000664 0000000 0000000 00000005375 12364444513 0030140 0 ustar 00root root 0000000 0000000
4.0.0hibernate-validator-parentorg.hibernate4.2.1.Final../pom.xmlorg.hibernatehibernate-validator-annotation-processorHibernate Validator Annotation Processororg.apache.maven.pluginsmaven-compiler-plugin-proc:noneorg.apache.maven.pluginsmaven-source-pluginorg.apache.maven.pluginsmaven-javadoc-plugin
http://java.sun.com/j2se/1.6.0/docs/api/
http://docs.jboss.org/hibernate/stable/beanvalidation/api/
Hibernate Validator Annotation Processor PackagesHibernate Validator Annotation Processor ${project.version}Hibernate Validator Annotation Processor ${project.version}attach-javadocsdeployjarorg.hibernatehibernate-validatororg.testngtestngtestjoda-timejoda-timetest
hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/ 0000775 0000000 0000000 00000000000 12364444513 0027400 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/main/ 0000775 0000000 0000000 00000000000 12364444513 0030324 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/main/java/ 0000775 0000000 0000000 00000000000 12364444513 0031245 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/main/java/org/ 0000775 0000000 0000000 00000000000 12364444513 0032034 5 ustar 00root root 0000000 0000000 0000775 0000000 0000000 00000000000 12364444513 0033716 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/main/java/org/hibernate 0000775 0000000 0000000 00000000000 12364444513 0035703 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator 0000775 0000000 0000000 00000000000 12364444513 0036303 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap ConstraintAnnotationVisitor.java 0000664 0000000 0000000 00000015540 12364444513 0044712 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap;
import java.util.List;
import java.util.Set;
import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.TypeElement;
import javax.lang.model.element.VariableElement;
import javax.lang.model.util.ElementKindVisitor6;
import javax.tools.Diagnostic.Kind;
import org.hibernate.validator.ap.checks.ConstraintCheckError;
import org.hibernate.validator.ap.checks.ConstraintCheckFactory;
import org.hibernate.validator.ap.checks.ConstraintChecks;
import org.hibernate.validator.ap.util.AnnotationApiHelper;
import org.hibernate.validator.ap.util.Configuration;
import org.hibernate.validator.ap.util.ConstraintHelper;
import org.hibernate.validator.ap.util.MessagerAdapter;
/**
* An {@link javax.lang.model.element.ElementVisitor} that visits annotated elements (type declarations,
* methods and fields) and applies different {@link org.hibernate.validator.ap.checks.ConstraintCheck}s to them.
* Each {@link ConstraintCheckError} occurred will be reported using the
* {@link javax.annotation.processing.Messager} API.
*
* @author Gunnar Morling.
*/
final class ConstraintAnnotationVisitor extends ElementKindVisitor6> {
private final MessagerAdapter messager;
private final ConstraintCheckFactory constraintCheckFactory;
private final boolean verbose;
public ConstraintAnnotationVisitor(
ProcessingEnvironment processingEnvironment, MessagerAdapter messager, Configuration configuration) {
this.messager = messager;
this.verbose = configuration.isVerbose();
AnnotationApiHelper annotationApiHelper = new AnnotationApiHelper(
processingEnvironment.getElementUtils(), processingEnvironment.getTypeUtils()
);
ConstraintHelper constraintHelper = new ConstraintHelper(
processingEnvironment.getElementUtils(), processingEnvironment.getTypeUtils(), annotationApiHelper
);
constraintCheckFactory = new ConstraintCheckFactory(
processingEnvironment.getTypeUtils(),
constraintHelper,
annotationApiHelper,
configuration.methodConstraintsSupported()
);
}
/**
*
* Checks whether the given annotations are correctly specified at the given
* method. The following checks are performed:
*
*
*
* Constraint annotations may only be given at non-static, JavaBeans getter
* methods which's return type is supported by the constraints.
*
* The @Valid annotation may only be given at non-static,
* non-primitive JavaBeans getter methods.
*
*/
@Override
public Void visitExecutableAsMethod(ExecutableElement method,
List mirrors) {
checkConstraints( method, mirrors );
return null;
}
/**
*
* Checks whether the given annotations are correctly specified at the given
* field. The following checks are performed:
*
*
*
* Constraint annotations may only be given at non-static fields which's
* type is supported by the constraints.
*
* The @Valid annotation may only be given at non-static,
* non-primitive fields.
*
*/
@Override
public Void visitVariableAsField(VariableElement annotatedField, List mirrors) {
checkConstraints( annotatedField, mirrors );
return null;
}
/**
*
* Checks whether the given annotations are correctly specified at the given
* annotation type declaration. The following checks are performed:
*
*
*
* The only annotation types allowed to be annotated with other constraint
* annotations are composed constraint annotation type declarations.
*
*/
@Override
public Void visitTypeAsAnnotationType(TypeElement annotationType,
List mirrors) {
checkConstraints( annotationType, mirrors );
return null;
}
/**
*
* Checks whether the given annotations are correctly specified at the given
* class type declaration. The following checks are performed:
*
*
*
* Constraint annotations may at types supported by the constraints.
*
*
*/
@Override
public Void visitTypeAsClass(TypeElement e, List p) {
checkConstraints( e, p );
return null;
}
/**
*
* Checks whether the given annotations are correctly specified at the given
* enum type declaration. The following checks are performed:
*
*
*
* Constraint annotations may at types supported by the constraints.
*
*
*/
@Override
public Void visitTypeAsEnum(TypeElement e, List p) {
checkConstraints( e, p );
return null;
}
/**
*
* Checks whether the given annotations are correctly specified at the given
* interface type declaration. The following checks are performed:
*
*
*
* Constraint annotations may at types supported by the constraints.
*
*
*/
@Override
public Void visitTypeAsInterface(TypeElement e, List p) {
checkConstraints( e, p );
return null;
}
/**
* Retrieves the checks required for the given element and annotations,
* executes them and reports all occurred errors.
*
* @param annotatedElement The element to check.
* @param mirrors The annotations to check.
*/
private void checkConstraints(Element annotatedElement, List mirrors) {
for ( AnnotationMirror oneAnnotationMirror : mirrors ) {
try {
ConstraintChecks constraintChecks = constraintCheckFactory.getConstraintChecks(
annotatedElement, oneAnnotationMirror
);
Set errors = constraintChecks.execute( annotatedElement, oneAnnotationMirror );
messager.reportErrors( errors );
}
//HV-293: if single constraints can't be properly checked, report this and
//proceed with next constraints
catch ( Exception e ) {
if ( verbose ) {
messager.getDelegate()
.printMessage( Kind.NOTE, e.getMessage(), annotatedElement, oneAnnotationMirror );
}
}
}
}
}
ConstraintValidationProcessor.java 0000664 0000000 0000000 00000011111 12364444513 0045200 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap;
import java.util.List;
import java.util.Set;
import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.ProcessingEnvironment;
import javax.annotation.processing.RoundEnvironment;
import javax.annotation.processing.SupportedAnnotationTypes;
import javax.annotation.processing.SupportedOptions;
import javax.annotation.processing.SupportedSourceVersion;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
import javax.lang.model.element.ElementVisitor;
import javax.lang.model.element.TypeElement;
import org.hibernate.validator.ap.util.AnnotationApiHelper;
import org.hibernate.validator.ap.util.Configuration;
import org.hibernate.validator.ap.util.MessagerAdapter;
/**
* An annotation processor for checking Bean Validation constraints.
* The processor supports the following options:
*
*
diagnosticKind: the severity with which any occurred
* problems shall be reported. Must be given in form of the string
* representation of a value from {@link javax.tools.Diagnostic.Kind}, e.g.
* "diagnosticKind=WARNING". Default is Kind.ERROR.
*
verbose: whether a verbose output shall be created or not.
* Must be given as String parsable by {@link Boolean#parseBoolean}. Default is
* false.
*
methodConstraintsSupported: Whether constraints at other
* methods than JavaBeans getter methods may be annotated with constraints or
* not. Must be given as String parsable by {@link Boolean#parseBoolean}. Can be
* set to false in order to allow only getter based property
* constraints but not method level constraints as supported by Hibernate
* Validator. Default is true.
*
* @author Hardy Ferentschik
* @author Gunnar Morling
*/
@SupportedAnnotationTypes("*")
@SupportedSourceVersion(SourceVersion.RELEASE_6)
@SupportedOptions( {
Configuration.DIAGNOSTIC_KIND_PROCESSOR_OPTION,
Configuration.VERBOSE_PROCESSOR_OPTION,
Configuration.METHOD_CONSTRAINTS_SUPPORTED_PROCESSOR_OPTION
})
public class ConstraintValidationProcessor extends AbstractProcessor {
/**
* Whether this processor claims all processed annotations exclusively or not.
*/
private static final boolean ANNOTATIONS_CLAIMED_EXCLUSIVELY = false;
/**
* The messager to be used for error reports.
*/
private MessagerAdapter messager;
/**
* Provides access to this processor's configuration options.
*/
private Configuration configuration;
@Override
public synchronized void init(ProcessingEnvironment processingEnv) {
super.init( processingEnv );
configuration = new Configuration( processingEnv.getOptions(), processingEnv.getMessager() );
messager = new MessagerAdapter( processingEnv.getMessager(), configuration.getDiagnosticKind() );
}
@Override
public boolean process(
final Set extends TypeElement> annotations,
final RoundEnvironment roundEnvironment) {
AnnotationApiHelper typeHelper = new AnnotationApiHelper(
processingEnv.getElementUtils(), processingEnv.getTypeUtils()
);
ElementVisitor> visitor = new ConstraintAnnotationVisitor(
processingEnv, messager, configuration
);
for ( TypeElement oneAnnotation : annotations ) {
Set extends Element> elementsWithConstraintAnnotation =
roundEnvironment.getElementsAnnotatedWith( oneAnnotation );
for ( Element oneAnnotatedElement : elementsWithConstraintAnnotation ) {
List mirrorsOfCurrentAnnotation =
typeHelper.filterByType( oneAnnotatedElement.getAnnotationMirrors(), oneAnnotation.asType() );
oneAnnotatedElement.accept( visitor, mirrorsOfCurrentAnnotation );
}
}
return ANNOTATIONS_CLAIMED_EXCLUSIVELY;
}
}
0000775 0000000 0000000 00000000000 12364444513 0037543 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/checks AbstractConstraintCheck.java 0000664 0000000 0000000 00000004312 12364444513 0045154 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/checks /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.checks;
import java.util.Collections;
import java.util.Set;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.TypeElement;
import javax.lang.model.element.VariableElement;
/**
*
* Abstract base class for {@link ConstraintCheck} implementations. Concrete
* checks should only override those check methods applicable for their
* supported element types.
*
*
* For instance would a check ensuring that constraint annotations are only
* given at non-static fields or methods only override checkField()
* and checkMethod().
*
*
* All check methods not overridden will return an empty list.
*
*
* @author Gunnar Morling
*/
public class AbstractConstraintCheck implements ConstraintCheck {
public Set checkField(VariableElement element, AnnotationMirror annotation) {
return Collections.emptySet();
}
public Set checkMethod(ExecutableElement element, AnnotationMirror annotation) {
return Collections.emptySet();
}
public Set checkAnnotationType(TypeElement element,
AnnotationMirror annotation) {
return Collections.emptySet();
}
public Set checkNonAnnotationType(
TypeElement element, AnnotationMirror annotation) {
return Collections.emptySet();
}
}
AnnotationTypeCheck.java 0000664 0000000 0000000 00000003603 12364444513 0044322 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/checks /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.checks;
import java.util.Collections;
import java.util.Set;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.TypeElement;
import org.hibernate.validator.ap.util.CollectionHelper;
import org.hibernate.validator.ap.util.ConstraintHelper;
/**
* Checks, that only constraint annotation types are annotated with other
* constraint annotations ("constraint composition"), but not non-constraint
* annotations.
*
* @author Gunnar Morling
*/
public class AnnotationTypeCheck extends AbstractConstraintCheck {
private final ConstraintHelper constraintHelper;
public AnnotationTypeCheck(ConstraintHelper constraintHelper) {
this.constraintHelper = constraintHelper;
}
@Override
public Set checkAnnotationType(TypeElement element,
AnnotationMirror annotation) {
if ( !constraintHelper.isConstraintAnnotation( element ) ) {
return CollectionHelper.asSet(
new ConstraintCheckError(
element, annotation, "ONLY_CONSTRAINT_ANNOTATIONS_MAY_BE_ANNOTATED"
)
);
}
return Collections.emptySet();
}
}
AnnotationTypeMemberCheck.java 0000664 0000000 0000000 00000023765 12364444513 0045465 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/checks /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.checks;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.AnnotationValue;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.TypeElement;
import javax.lang.model.type.ArrayType;
import javax.lang.model.type.DeclaredType;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.type.WildcardType;
import javax.lang.model.util.SimpleAnnotationValueVisitor6;
import javax.lang.model.util.TypeKindVisitor6;
import javax.lang.model.util.Types;
import javax.validation.Payload;
import org.hibernate.validator.ap.util.AnnotationApiHelper;
import org.hibernate.validator.ap.util.CollectionHelper;
import static javax.lang.model.util.ElementFilter.methodsIn;
/**
* Checks, that each constraint annotation type declares the members message(), groups() and payload() as
* defined by the BV spec.
*
* @author Gunnar Morling
*/
public class AnnotationTypeMemberCheck extends AbstractConstraintCheck {
private final AnnotationApiHelper annotationApiHelper;
private final Types typeUtils;
public AnnotationTypeMemberCheck(AnnotationApiHelper annotationApiHelper, Types typeUtils) {
this.annotationApiHelper = annotationApiHelper;
this.typeUtils = typeUtils;
}
@Override
public Set checkAnnotationType(TypeElement element, AnnotationMirror annotation) {
Set theValue = CollectionHelper.newHashSet();
theValue.addAll( checkMessageAttribute( element ) );
theValue.addAll( checkGroupsAttribute( element ) );
theValue.addAll( checkPayloadAttribute( element ) );
return theValue;
}
/**
* Checks that the given type element
*
*
*
has a method with name "message",
*
the return type of this method is {@link String}.
*
*
* @param element The element of interest.
*
* @return A possibly non-empty set of constraint check errors, never null.
*/
private Set checkMessageAttribute(TypeElement element) {
ExecutableElement messageMethod = getMethod( element, "message" );
if ( messageMethod == null ) {
return CollectionHelper.asSet(
new ConstraintCheckError( element, null, "CONSTRAINT_TYPE_MUST_DECLARE_MESSAGE_MEMBER" )
);
}
if ( !typeUtils.isSameType(
annotationApiHelper.getMirrorForType( String.class ), messageMethod.getReturnType()
) ) {
return CollectionHelper.asSet(
new ConstraintCheckError( messageMethod, null, "RETURN_TYPE_MUST_BE_STRING" )
);
}
return Collections.emptySet();
}
/**
* Checks that the given type element
*
*
*
has a method with name "groups",
*
the return type of this method is Class<?>[],
*
the default value of this method is {}.
*
*
* @param element The element of interest.
*
* @return A possibly non-empty set of constraint check errors, never null.
*/
private Set checkGroupsAttribute(TypeElement element) {
ExecutableElement groupsMethod = getMethod( element, "groups" );
if ( groupsMethod == null ) {
return CollectionHelper.asSet(
new ConstraintCheckError( element, null, "CONSTRAINT_TYPE_MUST_DECLARE_GROUPS_MEMBER" )
);
}
DeclaredType type = getComponentTypeOfArrayReturnType( groupsMethod );
if ( type == null ) {
return CollectionHelper.asSet(
new ConstraintCheckError( groupsMethod, null, "RETURN_TYPE_MUST_BE_CLASS_ARRAY" )
);
}
boolean typeHasNameClass = type.asElement().getSimpleName().contentEquals( "Class" );
boolean typeHasExactlyOneTypeArgument = type.getTypeArguments().size() == 1;
boolean typeArgumentIsUnboundWildcard = validateWildcardBounds( type.getTypeArguments().get( 0 ), null, null );
if ( !( typeHasNameClass && typeHasExactlyOneTypeArgument && typeArgumentIsUnboundWildcard ) ) {
return CollectionHelper.asSet(
new ConstraintCheckError( groupsMethod, null, "RETURN_TYPE_MUST_BE_CLASS_ARRAY" )
);
}
if ( !isEmptyArray( groupsMethod.getDefaultValue() ) ) {
return CollectionHelper.asSet(
new ConstraintCheckError( groupsMethod, null, "DEFAULT_VALUE_MUST_BE_EMPTY_ARRAY" )
);
}
return Collections.emptySet();
}
/**
* Checks that the given type element
*
*
*
has a method with name "payload",
*
the return type of this method is Class<? extends Payload>[],
*
the default value of this method is {}.
*
*
* @param element The element of interest.
*
* @return A possibly non-empty set of constraint check errors, never null.
*/
private Set checkPayloadAttribute(TypeElement element) {
ExecutableElement payloadMethod = getMethod( element, "payload" );
if ( payloadMethod == null ) {
return CollectionHelper.asSet(
new ConstraintCheckError( element, null, "CONSTRAINT_TYPE_MUST_DECLARE_PAYLOAD_MEMBER" )
);
}
DeclaredType type = getComponentTypeOfArrayReturnType( payloadMethod );
if ( type == null ) {
return CollectionHelper.asSet(
new ConstraintCheckError( payloadMethod, null, "PAYLOAD_RETURN_TYPE_MUST_BE_CLASS_ARRAY" )
);
}
boolean typeHasNameClass = type.asElement().getSimpleName().contentEquals( "Class" );
boolean typeHasExactlyOneTypeArgument = type.getTypeArguments().size() == 1;
boolean typeArgumentIsWildcardWithPayloadExtendsBound = validateWildcardBounds(
type.getTypeArguments().get( 0 ), annotationApiHelper.getMirrorForType( Payload.class ), null
);
if ( !( typeHasNameClass && typeHasExactlyOneTypeArgument && typeArgumentIsWildcardWithPayloadExtendsBound ) ) {
return CollectionHelper.asSet(
new ConstraintCheckError( payloadMethod, null, "PAYLOAD_RETURN_TYPE_MUST_BE_CLASS_ARRAY" )
);
}
if ( !isEmptyArray( payloadMethod.getDefaultValue() ) ) {
return CollectionHelper.asSet(
new ConstraintCheckError( payloadMethod, null, "PAYLOAD_DEFAULT_VALUE_MUST_BE_EMPTY_ARRAY" )
);
}
return Collections.emptySet();
}
/**
* Returns the method of the given type with the given name.
*
* @param element The type of interest.
* @param name The name of the method which should be returned.
*
* @return The method of the given type with the given name or null if no such method exists.
*/
private ExecutableElement getMethod(TypeElement element, String name) {
for ( ExecutableElement oneMethod : methodsIn( element.getEnclosedElements() ) ) {
if ( oneMethod.getSimpleName().contentEquals( name ) ) {
return oneMethod;
}
}
return null;
}
/**
* Returns the component type of the array-typed return value of the given method.
*
* @param method The method of interest.
*
* @return The component type of the array-typed return value of the given method or null,
* if the given method has no array-typed return value.
*/
private DeclaredType getComponentTypeOfArrayReturnType(ExecutableElement method) {
return method.getReturnType().accept(
new TypeKindVisitor6() {
@Override
public DeclaredType visitArray(ArrayType t, Void p) {
return t.getComponentType().accept(
new TypeKindVisitor6() {
@Override
public DeclaredType visitDeclared(DeclaredType t, Void p) {
return t;
}
}, null
);
}
}, null
);
}
/**
* Returns true, if the given type mirror is a wildcard type with the given extends and super bounds, false otherwise.
*
* @param type The type to check.
* @param expectedExtendsBound A mirror representing the expected extends bound.
* @param expectedSuperBound A mirror representing the expected super bound.
*
* @return True, if the given type mirror is a wildcard type with the given extends and super bounds, false otherwise.
*/
private boolean validateWildcardBounds(TypeMirror type, final TypeMirror expectedExtendsBound, final TypeMirror expectedSuperBound) {
Boolean theValue = type.accept(
new TypeKindVisitor6() {
@Override
public Boolean visitWildcard(WildcardType t, Void p) {
boolean extendsBoundMatches = ( t.getExtendsBound() == null ? expectedExtendsBound == null : expectedExtendsBound != null && typeUtils
.isSameType( t.getExtendsBound(), expectedExtendsBound ) );
boolean superBoundMatches = ( t.getSuperBound() == null ? expectedSuperBound == null : expectedSuperBound != null && typeUtils
.isSameType( t.getSuperBound(), expectedSuperBound ) );
return extendsBoundMatches && superBoundMatches;
}
}, null
);
return Boolean.TRUE.equals( theValue );
}
/**
* Checks whether the given annotation value is an empty array or not.
*
* @param annotationValue The annotation value of interest.
*
* @return True, if the given annotation value is an empty array, false otherwise.
*/
private boolean isEmptyArray(AnnotationValue annotationValue) {
return annotationValue != null && Boolean.TRUE.equals(
annotationValue.accept(
new SimpleAnnotationValueVisitor6() {
@Override
public Boolean visitArray(List extends AnnotationValue> values, Void p) {
return values.size() == 0;
}
}, null
)
);
}
}
ConstraintCheck.java 0000664 0000000 0000000 00000007253 12364444513 0043477 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/checks /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.checks;
import java.util.Set;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.TypeElement;
import javax.lang.model.element.VariableElement;
/**
*
* Implementations represent checks, which determine whether a given constraint
* annotation is allowed at a given element.
*
*
* Implementations should be derived from {@link AbstractConstraintCheck} in
* order to implement only those check methods applicable for the element kinds
* supported by the check.
*
*
* @author Gunnar Morling
*/
public interface ConstraintCheck {
/**
* Checks, whether the given annotation is allowed at the given field.
*
* @param element An annotated field.
* @param annotation An annotation at that field.
*
* @return A set with errors, that describe, why the given annotation is
* not allowed at the given element. In case no errors occur (the
* given annotation is allowed at the given element), an empty set
* must be returned.
*/
Set checkField(VariableElement element,
AnnotationMirror annotation);
/**
* Checks, whether the given annotation is allowed at the given method.
*
* @param element An annotated method.
* @param annotation An annotation at that method.
*
* @return A set with errors, that describe, why the given annotation is
* not allowed at the given element. In case no errors occur (the
* given annotation is allowed at the given element), an empty set
* must be returned.
*/
Set checkMethod(ExecutableElement element,
AnnotationMirror annotation);
/**
* Checks, whether the given annotation is allowed at the given annotation
* type declaration.
*
* @param element An annotated annotation type declaration.
* @param annotation An annotation at that annotation type.
*
* @return A set with errors, that describe, why the given annotation is
* not allowed at the given element. In case no errors occur (the
* given annotation is allowed at the given element), an empty set
* must be returned.
*/
Set checkAnnotationType(TypeElement element,
AnnotationMirror annotation);
/**
* Checks, whether the given annotation is allowed at the given type
* declaration (class, interface, enum).
*
* @param element An annotated type declaration.
* @param annotation An annotation at that type.
*
* @return A set with errors, that describe, why the given annotation is
* not allowed at the given element. In case no errors occur (the
* given annotation is allowed at the given element), an empty set
* must be returned.
*/
Set checkNonAnnotationType(TypeElement element,
AnnotationMirror annotation);
}
ConstraintCheckError.java 0000664 0000000 0000000 00000007744 12364444513 0044516 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/checks /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.checks;
import java.util.Arrays;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
/**
* The result of the execution of a {@link ConstraintCheck}. Comprises
* information about the location at which the error occurred and a message
* describing the occurred error.
*
* @author Gunnar Morling
*/
public class ConstraintCheckError {
private final Element element;
private final AnnotationMirror annotationMirror;
private final String messageKey;
private final Object[] messageParameters;
/**
* Creates a new ConstraintCheckError.
*
* @param element The element at which the error occurred.
* @param annotationMirror The annotation that causes the error.
* @param messageKey A key for retrieving an error message template from the bundle
*
* org.hibernate.validator.ap.ValidationProcessorMessages.
* @param messageParameters An array with values to put into the error message template
* using {@link java.text.MessageFormat}. The number of elements must match
* the number of place holders in the message template.
*/
public ConstraintCheckError(Element element,
AnnotationMirror annotationMirror, String messageKey, Object... messageParameters) {
this.element = element;
this.annotationMirror = annotationMirror;
this.messageKey = messageKey;
this.messageParameters = messageParameters;
}
public Element getElement() {
return element;
}
public AnnotationMirror getAnnotationMirror() {
return annotationMirror;
}
public String getMessageKey() {
return messageKey;
}
public Object[] getMessageParameters() {
return messageParameters;
}
@Override
public String toString() {
return "ConstraintCheckError [annotationMirror=" + annotationMirror
+ ", element=" + element + ", messageKey=" + messageKey
+ ", messageParameters=" + Arrays.toString( messageParameters )
+ "]";
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime
* result
+ ( ( annotationMirror == null ) ? 0 : annotationMirror.hashCode() );
result = prime * result + ( ( element == null ) ? 0 : element.hashCode() );
result = prime * result
+ ( ( messageKey == null ) ? 0 : messageKey.hashCode() );
result = prime * result + Arrays.hashCode( messageParameters );
return result;
}
@Override
public boolean equals(Object obj) {
if ( this == obj ) {
return true;
}
if ( obj == null ) {
return false;
}
if ( getClass() != obj.getClass() ) {
return false;
}
ConstraintCheckError other = (ConstraintCheckError) obj;
if ( annotationMirror == null ) {
if ( other.annotationMirror != null ) {
return false;
}
}
else if ( !annotationMirror.equals( other.annotationMirror ) ) {
return false;
}
if ( element == null ) {
if ( other.element != null ) {
return false;
}
}
else if ( !element.equals( other.element ) ) {
return false;
}
if ( messageKey == null ) {
if ( other.messageKey != null ) {
return false;
}
}
else if ( !messageKey.equals( other.messageKey ) ) {
return false;
}
if ( !Arrays.equals( messageParameters, other.messageParameters ) ) {
return false;
}
return true;
}
}
ConstraintCheckFactory.java 0000664 0000000 0000000 00000014314 12364444513 0045023 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/checks /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.checks;
import java.util.Map;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
import javax.lang.model.util.Types;
import org.hibernate.validator.ap.util.AnnotationApiHelper;
import org.hibernate.validator.ap.util.CollectionHelper;
import org.hibernate.validator.ap.util.ConstraintHelper;
import org.hibernate.validator.ap.util.ConstraintHelper.AnnotationType;
/**
* A factory in charge of determining the {@link ConstraintCheck}s required for
* the validation of annotations at given elements.
*
* @author Gunnar Morling
*/
public class ConstraintCheckFactory {
/**
* Holds the checks to be executed for field elements.
*/
private final Map fieldChecks;
/**
* Holds the checks to be executed for method elements.
*/
private final Map methodChecks;
/**
* Holds the checks to be executed for annotation type declarations.
*/
private final Map annotationTypeChecks;
/**
* Holds the checks to be executed for class/interface/enum declarations.
*/
private final Map nonAnnotationTypeChecks;
private ConstraintHelper constraintHelper;
private final static SingleValuedChecks NULL_CHECKS = new SingleValuedChecks();
public ConstraintCheckFactory(Types typeUtils, ConstraintHelper constraintHelper, AnnotationApiHelper annotationApiHelper, boolean methodConstraintsSupported) {
this.constraintHelper = constraintHelper;
fieldChecks = CollectionHelper.newHashMap();
fieldChecks.put(
AnnotationType.CONSTRAINT_ANNOTATION,
new SingleValuedChecks( new StaticCheck(), new TypeCheck( constraintHelper ) )
);
fieldChecks.put(
AnnotationType.MULTI_VALUED_CONSTRAINT_ANNOTATION,
new MultiValuedChecks( constraintHelper, new StaticCheck(), new TypeCheck( constraintHelper ) )
);
fieldChecks.put(
AnnotationType.GRAPH_VALIDATION_ANNOTATION,
new SingleValuedChecks( new StaticCheck(), new PrimitiveCheck() )
);
fieldChecks.put( AnnotationType.NO_CONSTRAINT_ANNOTATION, NULL_CHECKS );
methodChecks = CollectionHelper.newHashMap();
methodChecks.put(
AnnotationType.CONSTRAINT_ANNOTATION,
new SingleValuedChecks( new GetterCheck(methodConstraintsSupported), new StaticCheck(), new TypeCheck( constraintHelper ) )
);
methodChecks.put(
AnnotationType.MULTI_VALUED_CONSTRAINT_ANNOTATION, new MultiValuedChecks(
constraintHelper, new GetterCheck(methodConstraintsSupported), new StaticCheck(), new TypeCheck( constraintHelper )
)
);
methodChecks.put(
AnnotationType.GRAPH_VALIDATION_ANNOTATION,
new SingleValuedChecks( new GetterCheck(methodConstraintsSupported), new StaticCheck(), new PrimitiveCheck() )
);
methodChecks.put( AnnotationType.NO_CONSTRAINT_ANNOTATION, NULL_CHECKS );
annotationTypeChecks = CollectionHelper.newHashMap();
annotationTypeChecks.put(
AnnotationType.CONSTRAINT_ANNOTATION,
new SingleValuedChecks( new AnnotationTypeCheck( constraintHelper ) )
);
annotationTypeChecks.put(
AnnotationType.MULTI_VALUED_CONSTRAINT_ANNOTATION,
new MultiValuedChecks( constraintHelper, new AnnotationTypeCheck( constraintHelper ) )
);
annotationTypeChecks.put(
AnnotationType.CONSTRAINT_META_ANNOTATION,
new SingleValuedChecks(
new RetentionPolicyCheck( annotationApiHelper ),
new TargetCheck( annotationApiHelper ),
new ConstraintValidatorCheck( constraintHelper, annotationApiHelper ),
new AnnotationTypeMemberCheck( annotationApiHelper, typeUtils )
)
);
annotationTypeChecks.put( AnnotationType.NO_CONSTRAINT_ANNOTATION, NULL_CHECKS );
nonAnnotationTypeChecks = CollectionHelper.newHashMap();
nonAnnotationTypeChecks.put(
AnnotationType.CONSTRAINT_ANNOTATION, new SingleValuedChecks( new TypeCheck( constraintHelper ) )
);
nonAnnotationTypeChecks.put(
AnnotationType.MULTI_VALUED_CONSTRAINT_ANNOTATION,
new MultiValuedChecks( constraintHelper, new TypeCheck( constraintHelper ) )
);
nonAnnotationTypeChecks.put( AnnotationType.NO_CONSTRAINT_ANNOTATION, NULL_CHECKS );
nonAnnotationTypeChecks.put(
AnnotationType.GROUP_SEQUENCE_PROVIDER_ANNOTATION,
new SingleValuedChecks( new GroupSequenceProviderCheck( annotationApiHelper, typeUtils ) )
);
}
/**
* Returns those checks that have to be performed to validate the given
* annotation at the given element. In case no checks have to be performed
* (e.g. because the given annotation is no constraint annotation) an empty
* {@link ConstraintChecks} instance will be returned. It's therefore always
* safe to operate on the returned object.
*
* @param annotatedElement An annotated element, e.g. a type declaration or a method.
* @param annotation An annotation.
*
* @return The checks to be performed to validate the given annotation at
* the given element.
*/
public ConstraintChecks getConstraintChecks(Element annotatedElement, AnnotationMirror annotation) {
AnnotationType annotationType = constraintHelper.getAnnotationType( annotation );
switch ( annotatedElement.getKind() ) {
case FIELD:
return fieldChecks.get( annotationType );
case METHOD:
return methodChecks.get( annotationType );
case ANNOTATION_TYPE:
return annotationTypeChecks.get( annotationType );
case CLASS:
case INTERFACE:
case ENUM:
return nonAnnotationTypeChecks.get( annotationType );
default:
return NULL_CHECKS;
}
}
}
ConstraintChecks.java 0000664 0000000 0000000 00000003027 12364444513 0043655 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/checks /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.checks;
import java.util.Set;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
/**
* Represents an ordered set of {@link ConstraintCheck}s with the ability
* to execute these checks against given elements and their annotations.
*
* @author Gunnar Morling
*/
public interface ConstraintChecks {
/**
* Executes the checks contained within this set against the given element
* and annotation.
*
* @param element An annotated element.
* @param annotation The annotation to check.
*
* @return A set with errors. Will be empty in case all checks passed
* successfully.
*/
Set execute(Element element,
AnnotationMirror annotation);
}
ConstraintValidatorCheck.java 0000664 0000000 0000000 00000004734 12364444513 0045346 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/checks /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.checks;
import java.util.Collections;
import java.util.Set;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.TypeElement;
import javax.validation.Constraint;
import org.hibernate.validator.ap.util.AnnotationApiHelper;
import org.hibernate.validator.ap.util.CollectionHelper;
import org.hibernate.validator.ap.util.ConstraintHelper;
/**
* Checks, that for each constraint annotation type, which is not a composed constraint,
* a validator implementation is specified using {@link Constraint} annotation.
*
* @author Gunnar Morling
*/
public class ConstraintValidatorCheck extends AbstractConstraintCheck {
private ConstraintHelper constraintHelper;
private final AnnotationApiHelper annotationApiHelper;
public ConstraintValidatorCheck(ConstraintHelper constraintHelper, AnnotationApiHelper annotationApiHelper) {
this.constraintHelper = constraintHelper;
this.annotationApiHelper = annotationApiHelper;
}
@Override
public Set checkAnnotationType(TypeElement element, AnnotationMirror annotation) {
AnnotationMirror constraintMirror = annotationApiHelper.getMirror(
element.getAnnotationMirrors(), Constraint.class
);
boolean atLeastOneValidatorGiven = !annotationApiHelper.getAnnotationArrayValue(
constraintMirror, "validatedBy"
).isEmpty();
if ( !( atLeastOneValidatorGiven || constraintHelper.isComposedConstraint( element ) ) ) {
return CollectionHelper.asSet(
new ConstraintCheckError(
element,
annotationApiHelper.getMirror( element.getAnnotationMirrors(), Constraint.class ),
"CONSTRAINT_TYPE_WITHOUT_VALIDATOR"
)
);
}
return Collections.emptySet();
}
}
GetterCheck.java 0000664 0000000 0000000 00000005013 12364444513 0042575 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/checks /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.checks;
import java.util.Collections;
import java.util.Set;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.type.TypeKind;
import org.hibernate.validator.ap.util.CollectionHelper;
/**
* Checks whether a given element is a valid getter method.
*
* @author Gunnar Morling
*/
public class GetterCheck extends AbstractConstraintCheck {
private final boolean methodConstraintsSupported;
public GetterCheck(boolean methodConstraintsSupported) {
this.methodConstraintsSupported = methodConstraintsSupported;
}
public Set checkMethod(ExecutableElement element,
AnnotationMirror annotation) {
if ( !methodConstraintsSupported && !isGetterMethod( element ) ) {
return CollectionHelper.asSet(
new ConstraintCheckError(
element, annotation, "ONLY_GETTERS_MAY_BE_ANNOTATED"
)
);
}
else if (!hasReturnValue(element)) {
return CollectionHelper.asSet(
new ConstraintCheckError(
element, annotation, "ONLY_NON_VOID_METHODS_MAY_BE_ANNOTATED"
)
);
}
return Collections.emptySet();
}
private boolean isGetterMethod(ExecutableElement method) {
return isJavaBeanGetterName( method.getSimpleName().toString() )
&& !hasParameters( method ) && hasReturnValue( method );
}
private boolean hasReturnValue(ExecutableElement method) {
return method.getReturnType().getKind() != TypeKind.VOID;
}
private boolean hasParameters(ExecutableElement method) {
return !method.getParameters().isEmpty();
}
private boolean isJavaBeanGetterName(String methodName) {
return methodName.startsWith( "is" ) || methodName.startsWith( "has" ) || methodName.startsWith( "get" );
}
}
GroupSequenceProviderCheck.java 0000664 0000000 0000000 00000017412 12364444513 0045651 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/checks /*
* JBoss, Home of Professional Open Source
* Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.checks;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.AnnotationValue;
import javax.lang.model.element.Element;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.Modifier;
import javax.lang.model.element.TypeElement;
import javax.lang.model.type.DeclaredType;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.ElementKindVisitor6;
import javax.lang.model.util.SimpleTypeVisitor6;
import javax.lang.model.util.Types;
import javax.validation.GroupSequence;
import org.hibernate.validator.ap.util.AnnotationApiHelper;
import org.hibernate.validator.ap.util.CollectionHelper;
import org.hibernate.validator.group.DefaultGroupSequenceProvider;
/**
* Checks that the {@link org.hibernate.validator.group.GroupSequenceProvider} annotation definition is valid.
*
* This check ensure that :
*
*
The annotation is not defined on an interface.
*
The annotation defines an implementation class of {@link DefaultGroupSequenceProvider}, not an interface or an abstract class.
*
The annotation defines a class with a public default constructor.
*
The annotation defines a default group sequence provider class for a (super-)type of the annotated class.
*
The class hosting the annotation is not already annotated with {@linkplain GroupSequence @GroupSequence}.
*
*
*
* @author Kevin Pollet - SERLI - (kevin.pollet@serli.com)
*/
public class GroupSequenceProviderCheck extends AbstractConstraintCheck {
private final Types typeUtils;
private final AnnotationApiHelper annotationApiHelper;
private final TypeMirror defaultGroupSequenceProviderType;
public GroupSequenceProviderCheck(AnnotationApiHelper annotationApiHelper, Types typeUtils) {
this.typeUtils = typeUtils;
this.annotationApiHelper = annotationApiHelper;
this.defaultGroupSequenceProviderType = annotationApiHelper.getMirrorForType( DefaultGroupSequenceProvider.class );
}
@Override
public Set checkNonAnnotationType(TypeElement element, AnnotationMirror annotation) {
Set errors = CollectionHelper.newHashSet();
errors.addAll( checkHostingElement( element, annotation ) );
errors.addAll( checkAnnotationValue( element, annotation ) );
return errors;
}
private Set checkHostingElement(TypeElement element, AnnotationMirror annotation) {
if ( !element.getKind().isClass() ) {
return CollectionHelper.asSet(
new ConstraintCheckError(
element, annotation, "GROUP_SEQUENCE_PROVIDER_ANNOTATION_MUST_BE_DEFINED_ON_A_CLASS"
)
);
}
//this error should be raised only if the GroupSequenceProvider annotations is on a class
if ( element.getAnnotation( GroupSequence.class ) != null ) {
return CollectionHelper.asSet(
new ConstraintCheckError(
element,
annotation,
"GROUP_SEQUENCE_PROVIDER_ANNOTATION_NOT_ALLOWED_ON_CLASS_WITH_GROUP_SEQUENCE_ANNOTATION"
)
);
}
return Collections.emptySet();
}
private Set checkAnnotationValue(TypeElement element, AnnotationMirror annotation) {
Set errors = CollectionHelper.newHashSet();
AnnotationValue value = annotationApiHelper.getAnnotationValue( annotation, "value" );
TypeMirror valueType = (TypeMirror) value.getValue();
TypeElement valueElement = (TypeElement) typeUtils.asElement( valueType );
if ( valueElement.getKind().isInterface() || valueElement.getModifiers().contains( Modifier.ABSTRACT ) ) {
errors.add(
new ConstraintCheckError(
element,
annotation,
"GROUP_SEQUENCE_PROVIDER_ANNOTATION_VALUE_MUST_BE_AN_IMPLEMENTATION_CLASS"
)
);
}
else {
//the TypeElement hosting the annotation is a concrete implementation of the DefaultGroupSequenceProvider
//interface. In that case, we need to check that it has a public default constructor.
if ( !hasPublicDefaultConstructor( valueElement ) ) {
errors.add(
new ConstraintCheckError(
element,
annotation,
"GROUP_SEQUENCE_PROVIDER_ANNOTATION_VALUE_CLASS_MUST_HAVE_DEFAULT_CONSTRUCTOR",
valueType
)
);
}
}
TypeMirror genericProviderType = retrieveGenericProviderType( valueType );
if ( !typeUtils.isSubtype( element.asType(), genericProviderType ) ) {
errors.add(
new ConstraintCheckError(
element,
annotation,
"GROUP_SEQUENCE_PROVIDER_ANNOTATION_VALUE_DEFINED_PROVIDER_CLASS_WITH_WRONG_TYPE",
genericProviderType,
element.asType()
)
);
}
return errors;
}
/**
* Checks that the given {@code TypeElement} has a public
* default constructor.
*
* @param element The {@code TypeElement} to check.
*
* @return True if the given {@code TypeElement} has a public default constructor, false otherwise
*/
private boolean hasPublicDefaultConstructor(TypeElement element) {
return element.accept(
new ElementKindVisitor6( Boolean.FALSE ) {
@Override
public Boolean visitTypeAsClass(TypeElement typeElement, Void aVoid) {
List extends Element> enclosedElements = typeElement.getEnclosedElements();
for ( Element enclosedElement : enclosedElements ) {
if ( enclosedElement.accept( this, aVoid ) ) {
return Boolean.TRUE;
}
}
return Boolean.FALSE;
}
@Override
public Boolean visitExecutableAsConstructor(ExecutableElement constructorElement, Void aVoid) {
if ( constructorElement.getModifiers().contains( Modifier.PUBLIC )
&& constructorElement.getParameters().isEmpty() ) {
return Boolean.TRUE;
}
return Boolean.FALSE;
}
}, null
);
}
/**
* Retrieves the default group sequence provider generic type defined by the given {@code TypeMirror}.
*
* @param typeMirror The {@code TypeMirror} instance.
*
* @return The generic type or {@code null} if the given type doesn't implement the {@link DefaultGroupSequenceProvider} interface.
*/
private TypeMirror retrieveGenericProviderType(TypeMirror typeMirror) {
return typeMirror.accept(
new SimpleTypeVisitor6() {
@Override
public TypeMirror visitDeclared(DeclaredType declaredType, Void aVoid) {
TypeMirror eraseType = typeUtils.erasure( declaredType );
if ( typeUtils.isSameType( eraseType, defaultGroupSequenceProviderType ) ) {
List extends TypeMirror> typeArguments = declaredType.getTypeArguments();
if ( !typeArguments.isEmpty() ) {
return typeArguments.get( 0 );
}
return null;
}
List extends TypeMirror> superTypes = typeUtils.directSupertypes( declaredType );
for ( TypeMirror superType : superTypes ) {
TypeMirror genericProviderType = superType.accept( this, aVoid );
if ( genericProviderType != null ) {
return genericProviderType;
}
}
return null;
}
}, null
);
}
}
MultiValuedChecks.java 0000664 0000000 0000000 00000004263 12364444513 0043767 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/checks /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.checks;
import java.util.Set;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
import org.hibernate.validator.ap.util.CollectionHelper;
import org.hibernate.validator.ap.util.ConstraintHelper;
/**
* A {@link ConstraintChecks} implementation, that executed the contained checks
* against all parts of given multi-valued annotations.
*
* @author Gunnar Morling
*/
public class MultiValuedChecks implements ConstraintChecks {
private final ConstraintHelper constraintHelper;
private final SingleValuedChecks delegate;
/**
* Creates a new MultiValuedChecks.
*
* @param constraintHelper Helper for handling multi-valued constraints.
* @param checks The checks to execute.
*/
public MultiValuedChecks(ConstraintHelper constraintHelper,
ConstraintCheck... checks) {
this.constraintHelper = constraintHelper;
this.delegate = new SingleValuedChecks( checks );
}
public Set execute(Element element,
AnnotationMirror annotation) {
Set theValue = CollectionHelper.newHashSet();
//execute the checks on each element of the multi-valued constraint
for ( AnnotationMirror onePartOfMultiValuedConstraint :
constraintHelper.getPartsOfMultiValuedConstraint( annotation ) ) {
theValue.addAll( delegate.execute( element, onePartOfMultiValuedConstraint ) );
}
return theValue;
}
}
PrimitiveCheck.java 0000664 0000000 0000000 00000004317 12364444513 0043321 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/checks /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.checks;
import java.util.Collections;
import java.util.Set;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.VariableElement;
import javax.lang.model.type.TypeMirror;
import org.hibernate.validator.ap.util.CollectionHelper;
/**
* Validates that the given element is not of a primitive type. Applies to
* fields and methods (the return type is evaluated).
*
* @author Gunnar Morling
*/
public class PrimitiveCheck extends AbstractConstraintCheck {
@Override
public Set checkField(VariableElement element,
AnnotationMirror annotation) {
return checkInternal( element, annotation, element.asType(), "ATVALID_NOT_ALLOWED_AT_PRIMITIVE_FIELD" );
}
@Override
public Set checkMethod(ExecutableElement element,
AnnotationMirror annotation) {
return checkInternal(
element, annotation, element.getReturnType(), "ATVALID_NOT_ALLOWED_AT_METHOD_RETURNING_PRIMITIVE_TYPE"
);
}
private Set checkInternal(Element element,
AnnotationMirror annotation, TypeMirror type, String messageKey) {
if ( type.getKind().isPrimitive() ) {
return CollectionHelper.asSet(
new ConstraintCheckError(
element, annotation, messageKey
)
);
}
return Collections.emptySet();
}
}
RetentionPolicyCheck.java 0000664 0000000 0000000 00000004333 12364444513 0044476 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/checks /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.checks;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Collections;
import java.util.Set;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.TypeElement;
import org.hibernate.validator.ap.util.AnnotationApiHelper;
import org.hibernate.validator.ap.util.CollectionHelper;
/**
* Checks, that {@link RetentionPolicy#RUNTIME} is declared for constraint annotation types.
*
* @author Gunnar Morling
*/
public class RetentionPolicyCheck extends AbstractConstraintCheck {
private final AnnotationApiHelper annotationApiHelper;
public RetentionPolicyCheck(AnnotationApiHelper annotationApiHelper) {
this.annotationApiHelper = annotationApiHelper;
}
@Override
public Set checkAnnotationType(TypeElement element, AnnotationMirror annotation) {
Retention retention = element.getAnnotation( Retention.class );
if ( retention == null ) {
return CollectionHelper.asSet(
new ConstraintCheckError( element, null, "CONSTRAINT_TYPE_WITH_MISSING_OR_WRONG_RETENTION" )
);
}
if ( !retention.value().equals( RetentionPolicy.RUNTIME ) ) {
return CollectionHelper.asSet(
new ConstraintCheckError(
element,
annotationApiHelper.getMirror( element.getAnnotationMirrors(), Retention.class ),
"CONSTRAINT_TYPE_WITH_MISSING_OR_WRONG_RETENTION"
)
);
}
return Collections.emptySet();
}
}
SingleValuedChecks.java 0000664 0000000 0000000 00000006017 12364444513 0044115 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/checks /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.checks;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
import javax.lang.model.element.ElementKind;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.TypeElement;
import javax.lang.model.element.VariableElement;
import org.hibernate.validator.ap.util.CollectionHelper;
/**
* A {@link ConstraintChecks} implementation that simply executes all
* contained checks against given elements and annotations.
*
* @author Gunnar Morling
*/
public class SingleValuedChecks implements ConstraintChecks {
//TODO GM: the "ordered set" character is currently ensured by adding
//each check only once in ConstraintCheckFactory. Should this be a real set?
private final List checks;
/**
* Creates a new SingleValuedChecks.
*
* @param checks The checks to execute.
*/
public SingleValuedChecks(ConstraintCheck... checks) {
if ( checks == null ) {
this.checks = Collections.emptyList();
}
else {
this.checks = Arrays.asList( checks );
}
}
public Set execute(Element element, AnnotationMirror annotation) {
Set theValue = CollectionHelper.newHashSet();
//for each check execute the check method appropriate for the kind of
//the given element
for ( ConstraintCheck oneCheck : checks ) {
if ( element.getKind() == ElementKind.FIELD ) {
theValue.addAll( oneCheck.checkField( ( VariableElement ) element, annotation ) );
}
else if ( element.getKind() == ElementKind.METHOD ) {
theValue.addAll( oneCheck.checkMethod( ( ExecutableElement ) element, annotation ) );
}
else if ( element.getKind() == ElementKind.ANNOTATION_TYPE ) {
theValue.addAll( oneCheck.checkAnnotationType( ( TypeElement ) element, annotation ) );
}
else if (
element.getKind() == ElementKind.CLASS ||
element.getKind() == ElementKind.INTERFACE ||
element.getKind() == ElementKind.ENUM ) {
theValue.addAll( oneCheck.checkNonAnnotationType( ( TypeElement ) element, annotation ) );
}
if ( !theValue.isEmpty() ) {
return theValue;
}
}
return theValue;
}
}
StaticCheck.java 0000664 0000000 0000000 00000004225 12364444513 0042576 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/checks /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.checks;
import java.util.Collections;
import java.util.Set;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.Modifier;
import javax.lang.model.element.VariableElement;
import org.hibernate.validator.ap.util.CollectionHelper;
/**
* Checks, that the given element is not a static element. Applies to fields
* and methods.
*
* @author Gunnar Morling
*/
public class StaticCheck extends AbstractConstraintCheck {
@Override
public Set checkField(VariableElement element, AnnotationMirror annotation) {
return checkInternal( element, annotation, "STATIC_FIELDS_MAY_NOT_BE_ANNOTATED" );
}
@Override
public Set checkMethod(ExecutableElement element, AnnotationMirror annotation) {
return checkInternal( element, annotation, "STATIC_METHODS_MAY_NOT_BE_ANNOTATED" );
}
private Set checkInternal(Element element,
AnnotationMirror annotation, String messageKey) {
if ( isStaticElement( element ) ) {
return CollectionHelper.asSet( new ConstraintCheckError( element, annotation, messageKey ) );
}
return Collections.emptySet();
}
private boolean isStaticElement(Element element) {
return element.getModifiers().contains( Modifier.STATIC );
}
}
TargetCheck.java 0000664 0000000 0000000 00000005676 12364444513 0042610 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/checks /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.checks;
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
import java.util.Collections;
import java.util.EnumSet;
import java.util.Set;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.TypeElement;
import org.hibernate.validator.ap.util.AnnotationApiHelper;
import org.hibernate.validator.ap.util.CollectionHelper;
import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
/**
* Checks, that at least one of the {@link ElementType}s FIELD, METHOD, TYPE or ANNOTATION_TYPE is specified
* using the {@link Target} meta-annotation for constraint annotation types.
*
* @author Gunnar Morling
*/
public class TargetCheck extends AbstractConstraintCheck {
private final AnnotationApiHelper annotationApiHelper;
/**
* Each constraint annotation type must be targeted at one of these element types at least.
*/
private final EnumSet supportedTypes = EnumSet.of( FIELD, METHOD, TYPE, ANNOTATION_TYPE );
public TargetCheck(AnnotationApiHelper annotationApiHelper) {
this.annotationApiHelper = annotationApiHelper;
}
@Override
public Set checkAnnotationType(TypeElement element, AnnotationMirror annotation) {
Target target = element.getAnnotation( Target.class );
//no target given allows the annotation to be declared at any type
if ( target == null ) {
return Collections.emptySet();
}
if ( !containsAtLeastOneSupportedElementType( target ) ) {
return CollectionHelper.asSet(
new ConstraintCheckError(
element,
annotationApiHelper.getMirror( element.getAnnotationMirrors(), Target.class ),
"CONSTRAINT_TYPE_WITH_WRONG_TARGET"
)
);
}
return Collections.emptySet();
}
private boolean containsAtLeastOneSupportedElementType(Target target) {
ElementType[] elementTypes = target.value();
for ( ElementType oneElementType : elementTypes ) {
if ( supportedTypes.contains( oneElementType ) ) {
return true;
}
}
return false;
}
}
TypeCheck.java 0000664 0000000 0000000 00000005576 12364444513 0042302 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/checks /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.checks;
import java.util.Collections;
import java.util.Set;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.TypeElement;
import javax.lang.model.element.VariableElement;
import javax.lang.model.type.TypeMirror;
import org.hibernate.validator.ap.util.CollectionHelper;
import org.hibernate.validator.ap.util.ConstraintHelper;
import org.hibernate.validator.ap.util.ConstraintHelper.ConstraintCheckResult;
/**
* Checks, that constraint annotations are only specified at elements
* of a type supported by the constraints. Applies to fields, methods and
* non-annotation type declarations.
*
* @author Gunnar Morling
*/
public class TypeCheck extends AbstractConstraintCheck {
private ConstraintHelper constraintHelper;
public TypeCheck(ConstraintHelper constraintHelper) {
this.constraintHelper = constraintHelper;
}
@Override
public Set checkField(VariableElement element,
AnnotationMirror annotation) {
return checkInternal( element, annotation, element.asType(), "NOT_SUPPORTED_TYPE" );
}
@Override
public Set checkMethod(ExecutableElement element,
AnnotationMirror annotation) {
return checkInternal( element, annotation, element.getReturnType(), "NOT_SUPPORTED_RETURN_TYPE" );
}
@Override
public Set checkNonAnnotationType(
TypeElement element, AnnotationMirror annotation) {
return checkInternal( element, annotation, element.asType(), "NOT_SUPPORTED_TYPE" );
}
private Set checkInternal(Element element,
AnnotationMirror annotation, TypeMirror type, String messageKey) {
if ( constraintHelper.checkConstraint(
annotation.getAnnotationType(), type
) != ConstraintCheckResult.ALLOWED ) {
return CollectionHelper.asSet(
new ConstraintCheckError(
element, annotation, messageKey,
annotation.getAnnotationType().asElement().getSimpleName()
)
);
}
return Collections.emptySet();
}
}
package.html 0000664 0000000 0000000 00000002567 12364444513 0042036 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/checks
This package contains check implementations used by the annotation processor to verify
constraint declarations.
These checks are registered in the ConstraintValidatorFactory responsible to return
the corresponding check in function of the processed element and annotation. This factory is
especially used by the annotation processor implementation to get the checks corresponding to
an annotated element.
This package contains the main class of Hibernate Validator annotation processor.
The annotation processor implementation named ConstraintValidationProcessor
delegates constraint verifications to the implemented checks.
0000775 0000000 0000000 00000000000 12364444513 0037260 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/util AnnotationApiHelper.java 0000664 0000000 0000000 00000022414 12364444513 0044032 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/util /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.util;
import java.lang.annotation.Annotation;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.AnnotationValue;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.TypeElement;
import javax.lang.model.type.DeclaredType;
import javax.lang.model.type.TypeKind;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.Elements;
import javax.lang.model.util.SimpleAnnotationValueVisitor6;
import javax.lang.model.util.Types;
/**
* A helper class providing some useful methods to work with types
* from the JSR-269-API.
*
* @author Gunnar Morling
*/
public class AnnotationApiHelper {
private Elements elementUtils;
private Types typeUtils;
private final Map, TypeMirror> primitiveMirrors;
public AnnotationApiHelper(Elements elementUtils, Types typeUtils) {
this.elementUtils = elementUtils;
this.typeUtils = typeUtils;
Map, TypeMirror> tempPrimitiveMirrors = CollectionHelper.newHashMap();
tempPrimitiveMirrors.put( Boolean.TYPE, typeUtils.getPrimitiveType( TypeKind.BOOLEAN ) );
tempPrimitiveMirrors.put( Character.TYPE, typeUtils.getPrimitiveType( TypeKind.CHAR ) );
tempPrimitiveMirrors.put( Byte.TYPE, typeUtils.getPrimitiveType( TypeKind.BYTE ) );
tempPrimitiveMirrors.put( Short.TYPE, typeUtils.getPrimitiveType( TypeKind.SHORT ) );
tempPrimitiveMirrors.put( Integer.TYPE, typeUtils.getPrimitiveType( TypeKind.INT ) );
tempPrimitiveMirrors.put( Long.TYPE, typeUtils.getPrimitiveType( TypeKind.LONG ) );
tempPrimitiveMirrors.put( Float.TYPE, typeUtils.getPrimitiveType( TypeKind.FLOAT ) );
tempPrimitiveMirrors.put( Double.TYPE, typeUtils.getPrimitiveType( TypeKind.DOUBLE ) );
primitiveMirrors = Collections.unmodifiableMap( tempPrimitiveMirrors );
}
/**
* Returns a list containing those annotation mirrors from the input list,
* which are of type annotationType. The input collection
* remains untouched.
*
* @param annotationMirrors A list of annotation mirrors.
* @param annotationType The type to be compared against.
*
* @return A list with those annotation mirrors from the input list, which
* are of type annotationType. May be empty but never
* null.
*/
public List filterByType(List extends AnnotationMirror> annotationMirrors, TypeMirror annotationType) {
List theValue = CollectionHelper.newArrayList();
if ( annotationMirrors == null || annotationType == null ) {
return theValue;
}
for ( AnnotationMirror oneAnnotationMirror : annotationMirrors ) {
if ( typeUtils.isSameType( oneAnnotationMirror.getAnnotationType(), annotationType ) ) {
theValue.add( oneAnnotationMirror );
}
}
return theValue;
}
/**
* Returns that mirror from the given list of annotation mirrors that
* represents the annotation type specified by the given class.
*
* @param annotationMirrors A list of annotation mirrors.
* @param annotationClazz The class of the annotation of interest.
*
* @return The mirror from the given list that represents the specified
* annotation or null, if the given list doesn't contain such a
* mirror.
*/
public AnnotationMirror getMirror(List extends AnnotationMirror> annotationMirrors, Class extends Annotation> annotationClazz) {
if ( annotationMirrors == null || annotationClazz == null ) {
return null;
}
TypeMirror mirrorForAnnotation = elementUtils.getTypeElement(
annotationClazz.getCanonicalName()
).asType();
for ( AnnotationMirror oneAnnotationMirror : annotationMirrors ) {
if ( typeUtils.isSameType(
oneAnnotationMirror.getAnnotationType(),
mirrorForAnnotation
) ) {
return oneAnnotationMirror;
}
}
return null;
}
/**
* Returns a TypeMirror for the given class.
*
* @param clazz The class of interest.
*
* @return A TypeMirror for the given class.
*/
public TypeMirror getMirrorForType(Class> clazz) {
if ( clazz.isArray() ) {
return typeUtils.getArrayType( getMirrorForNonArrayType( clazz.getComponentType() ) );
}
else {
return getMirrorForNonArrayType( clazz );
}
}
private TypeMirror getMirrorForNonArrayType(Class> clazz) {
TypeMirror theValue = null;
if ( clazz.isPrimitive() ) {
theValue = primitiveMirrors.get( clazz );
}
else {
theValue = getDeclaredTypeByName( clazz.getCanonicalName() );
}
if ( theValue != null ) {
return theValue;
}
else {
throw new AssertionError( "Couldn't find a type mirror for class " + clazz );
}
}
/**
* Returns the {@link DeclaredType} for the given class name.
*
* @param className A fully qualified class name, e.g. "java.lang.String".
*
* @return A {@link DeclaredType} representing the type with the given name,
* or null, if no such type exists.
*/
public DeclaredType getDeclaredTypeByName(String className) {
TypeElement typeElement = elementUtils.getTypeElement( className );
return typeElement != null ? typeUtils.getDeclaredType( typeElement ) : null;
}
/**
* Returns the annotation value of the given annotation mirror with the
* given name.
*
* @param annotationMirror An annotation mirror.
* @param name The name of the annotation value of interest.
*
* @return The annotation value with the given name or null, if one of the
* input values is null or if no value with the given name exists
* within the given annotation mirror.
*/
public AnnotationValue getAnnotationValue(AnnotationMirror annotationMirror, String name) {
if ( annotationMirror == null || name == null ) {
return null;
}
Map extends ExecutableElement, ? extends AnnotationValue> elementValues = annotationMirror.getElementValues();
for ( Entry extends ExecutableElement, ? extends AnnotationValue> oneElementValue : elementValues.entrySet() ) {
if ( oneElementValue.getKey().getSimpleName().contentEquals( name ) ) {
return oneElementValue.getValue();
}
}
return null;
}
/**
* Returns the given annotation mirror's array-typed annotation value with
* the given name.
*
* @param annotationMirror An annotation mirror.
* @param name The name of the annotation value of interest.
*
* @return The annotation value with the given name or an empty list, if no
* such value exists within the given annotation mirror or such a
* value exists but is not an array-typed one.
*/
public List extends AnnotationValue> getAnnotationArrayValue(AnnotationMirror annotationMirror, String name) {
AnnotationValue annotationValue = getAnnotationValue( annotationMirror, name );
if ( annotationValue == null ) {
return Collections.emptyList();
}
List extends AnnotationValue> theValue = annotationValue.accept(
new SimpleAnnotationValueVisitor6, Void>() {
@Override
public List extends AnnotationValue> visitArray(List extends AnnotationValue> values, Void p) {
return values;
}
}, null
);
return theValue != null ? theValue : Collections
.emptyList();
}
/**
*
* Returns a set containing the "lowest" type per hierarchy contained in the
* input set. The following examples shall demonstrate the behavior.
*
*
*
* Input: String; Output: String
*
* Input: Object, String; Output:
* String
*
* Input: Object, Collection, List;
* Output: List
*
* Input: Collection, Set, List;
* Output: List, Set
*
*
* @param types A set of type mirrors.
*
* @return A set with the lowest types per hierarchy or null, if the input
* set was null.
*/
public Set keepLowestTypePerHierarchy(Set types) {
if ( types == null ) {
return null;
}
Set theValue = CollectionHelper.newHashSet();
for ( TypeMirror typeMirror1 : types ) {
boolean foundSubType = false;
for ( TypeMirror typeMirror2 : types ) {
if ( !typeUtils.isSameType( typeMirror2, typeMirror1 ) && typeUtils.isAssignable(
typeMirror2, typeMirror1
) ) {
foundSubType = true;
continue;
}
}
if ( !foundSubType ) {
theValue.add( typeMirror1 );
}
}
return theValue;
}
}
CollectionHelper.java 0000664 0000000 0000000 00000002611 12364444513 0043356 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/util /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.util;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
/**
* Provides some methods for simplified collection instantiation.
*
* @author Gunnar Morling
*/
public class CollectionHelper {
public static HashMap newHashMap() {
return new HashMap();
}
public static HashSet newHashSet() {
return new HashSet();
}
public static ArrayList newArrayList() {
return new ArrayList();
}
public static Set asSet(T... ts) {
return new HashSet( Arrays.asList( ts ) );
}
}
Configuration.java 0000664 0000000 0000000 00000010766 12364444513 0042744 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/util /*
* JBoss, Home of Professional Open Source
* Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.util;
import java.text.MessageFormat;
import java.util.Map;
import javax.annotation.processing.Messager;
import javax.tools.Diagnostic.Kind;
/**
* Provides access to the processor options supported by the Hibernate Validator
* annotation processor.
*
* @author Gunnar Morling
*/
public class Configuration {
/**
* The name of the processor option for setting the diagnostic kind to be
* used when reporting errors during annotation processing.
*/
public final static String DIAGNOSTIC_KIND_PROCESSOR_OPTION = "diagnosticKind";
/**
* The name of the processor option for activating verbose message reporting.
*/
public final static String VERBOSE_PROCESSOR_OPTION = "verbose";
/**
* The name of the processor option for allowing constraints at methods
* other than getter methods.
*/
public final static String METHOD_CONSTRAINTS_SUPPORTED_PROCESSOR_OPTION = "methodConstraintsSupported";
/**
* The diagnostic kind to be used if no or an invalid kind is given as processor option.
*/
public final static Kind DEFAULT_DIAGNOSTIC_KIND = Kind.ERROR;
private final Kind diagnosticKind;
private final boolean verbose;
private final boolean methodConstraintsSupported;
public Configuration(Map options, Messager messager) {
this.diagnosticKind = getDiagnosticKindOption( options, messager );
this.verbose = getVerboseOption( options, messager );
this.methodConstraintsSupported = getMethodConstraintsSupportedOption( options );
}
/**
* Returns the diagnosticKind to be used when reporting failing constraint checks.
*/
public Kind getDiagnosticKind() {
return diagnosticKind;
}
/**
* Whether logging information shall be put out in a verbose way or not.
*/
public boolean isVerbose() {
return verbose;
}
/**
* Whether method constraints are allowed at any method (true) or only
* getter methods (false).
*/
public boolean methodConstraintsSupported() {
return methodConstraintsSupported;
}
/**
* Retrieves the diagnostic kind to be used for error messages. If given in
* processor options, it will be taken from there, otherwise the default
* value {@link Kind#ERROR} will be returned.
*/
private Kind getDiagnosticKindOption(Map options, Messager messager) {
String diagnosticKindFromOptions = options.get( DIAGNOSTIC_KIND_PROCESSOR_OPTION );
if ( diagnosticKindFromOptions != null ) {
try {
return Kind.valueOf( diagnosticKindFromOptions );
}
catch ( IllegalArgumentException e ) {
messager.printMessage(
Kind.WARNING, MessageFormat.format(
"The given value {0} is no valid diagnostic kind. {1} will be used.",
diagnosticKindFromOptions,
DEFAULT_DIAGNOSTIC_KIND
)
);
}
}
return DEFAULT_DIAGNOSTIC_KIND;
}
/**
* Retrieves the value for the "verbose" property from the options.
*/
private boolean getVerboseOption(Map options, Messager messager) {
boolean theValue = Boolean.parseBoolean( options.get( VERBOSE_PROCESSOR_OPTION ) );
if ( theValue ) {
messager.printMessage(
Kind.NOTE, MessageFormat.format(
"Verbose reporting is activated. Some processing information will be displayed using diagnostic kind {0}.",
Kind.NOTE
)
);
}
return theValue;
}
/**
* Retrieves the value for the "methodConstraintsSupported" property from the options.
*/
private boolean getMethodConstraintsSupportedOption(Map options) {
String methodConstraintsSupported = options.get( METHOD_CONSTRAINTS_SUPPORTED_PROCESSOR_OPTION );
//allow method constraints by default
if ( methodConstraintsSupported == null ) {
return true;
}
return Boolean.parseBoolean( methodConstraintsSupported );
}
}
ConstraintHelper.java 0000664 0000000 0000000 00000060102 12364444513 0043406 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/util /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.util;
import java.lang.annotation.Annotation;
import java.util.Calendar;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.AnnotationValue;
import javax.lang.model.element.Element;
import javax.lang.model.element.Name;
import javax.lang.model.element.TypeElement;
import javax.lang.model.type.DeclaredType;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.Elements;
import javax.lang.model.util.SimpleAnnotationValueVisitor6;
import javax.lang.model.util.TypeKindVisitor6;
import javax.lang.model.util.Types;
import javax.validation.Constraint;
import javax.validation.ConstraintValidator;
import javax.validation.Valid;
import javax.validation.constraints.AssertFalse;
import javax.validation.constraints.AssertTrue;
import javax.validation.constraints.DecimalMax;
import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.Digits;
import javax.validation.constraints.Future;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import javax.validation.constraints.Past;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import org.hibernate.validator.group.GroupSequenceProvider;
/**
* Helper class that deals with all constraint-related stuff, such as
* determining whether a given annotation represents a constraint annotation or
* whether a given annotation is allowed to be declared at a given element.
*
* @author Gunnar Morling
* @author Kevin Pollet - SERLI - (kevin.pollet@serli.com)
*/
public class ConstraintHelper {
/**
* Possible results of a constraint check as returned by
* {@link ConstraintHelper#checkConstraint(DeclaredType, TypeMirror)}.
*
* @author Gunnar Morling
*/
public enum ConstraintCheckResult {
/**
* The checked constraint is allowed at the evaluated type.
*/
ALLOWED,
/**
* The checked constraint is not allowed at the evaluated type.
*/
DISALLOWED,
/**
* Multiple validators were found, that could validate the checked
* constrained at the evaluated type.
*/
MULTIPLE_VALIDATORS_FOUND
}
/**
* The type of an annotation with respect to the BV API.
*
* @author Gunnar Morling
* @author Kevin Pollet - SERLI - (kevin.pollet@serli.com)
*/
public enum AnnotationType {
/**
* Given annotation is a constraint annotation (e.g. @Min).
*/
CONSTRAINT_ANNOTATION,
/**
* Given annotation is a multi-valued annotation (e.g.
*
* @List({
* @Min(10),
* @Min(value=20, groups= Special.class})
* })
* .
*/
MULTI_VALUED_CONSTRAINT_ANNOTATION,
/**
* Given annotation is the @Valid annotation.
*/
GRAPH_VALIDATION_ANNOTATION,
/**
* Given annotation is the @Constraint meta-annotation.
*/
CONSTRAINT_META_ANNOTATION,
/**
* Given annotation is the @GroupSequenceProvider annotation.
*/
GROUP_SEQUENCE_PROVIDER_ANNOTATION,
/**
* Given annotation is not related to the BV API (e.g. @Resource).
*/
NO_CONSTRAINT_ANNOTATION
}
/**
* The name of the package containing JSR 303 standard annotations
* ("javax.validation.constraints").
*/
private final Name CONSTRAINT_ANNOTATION_PACKAGE_NAME;
/**
* Contains the supported types for the built-in constraints. Keyed by
* constraint annotation type names, each value is a set with the allowed
* types for the mapped constraint.
*/
private Map> builtInConstraints;
private Elements elementUtils;
private Types typeUtils;
private AnnotationApiHelper annotationApiHelper;
public ConstraintHelper(Elements elementUtils, Types typeUtils, AnnotationApiHelper annotationApiHelper) {
this.elementUtils = elementUtils;
this.typeUtils = typeUtils;
this.annotationApiHelper = annotationApiHelper;
CONSTRAINT_ANNOTATION_PACKAGE_NAME = elementUtils.getName( Size.class.getPackage().getName() );
builtInConstraints = CollectionHelper.newHashMap();
registerAllowedTypesForBuiltInConstraint(
AssertFalse.class, CollectionHelper.>asSet( Boolean.class )
);
registerAllowedTypesForBuiltInConstraint( AssertTrue.class, CollectionHelper.>asSet( Boolean.class ) );
registerAllowedTypesForBuiltInConstraint(
DecimalMax.class, CollectionHelper.>asSet( Number.class, String.class )
);
registerAllowedTypesForBuiltInConstraint(
DecimalMin.class, CollectionHelper.>asSet( Number.class, String.class )
);
registerAllowedTypesForBuiltInConstraint(
Digits.class, CollectionHelper.>asSet( Number.class, String.class )
);
registerAllowedTypesForBuiltInConstraint(
Future.class, CollectionHelper.>asSet( Calendar.class, Date.class )
);
registerAllowedTypesForBuiltInConstraintByNames(
Future.class,
CollectionHelper.asSet( "org.joda.time.ReadablePartial", "org.joda.time.ReadableInstant" )
);
registerAllowedTypesForBuiltInConstraint(
Max.class, CollectionHelper.>asSet( Number.class, String.class )
);
registerAllowedTypesForBuiltInConstraint(
Min.class, CollectionHelper.>asSet( Number.class, String.class )
);
registerAllowedTypesForBuiltInConstraint( NotNull.class, CollectionHelper.>asSet( Object.class ) );
registerAllowedTypesForBuiltInConstraint( Null.class, CollectionHelper.>asSet( Object.class ) );
registerAllowedTypesForBuiltInConstraint(
Past.class, CollectionHelper.>asSet( Calendar.class, Date.class )
);
registerAllowedTypesForBuiltInConstraintByNames(
Past.class,
CollectionHelper.asSet( "org.joda.time.ReadablePartial", "org.joda.time.ReadableInstant" )
);
registerAllowedTypesForBuiltInConstraint( Pattern.class, CollectionHelper.>asSet( String.class ) );
registerAllowedTypesForBuiltInConstraint(
Size.class, CollectionHelper.>asSet(
Object[].class,
boolean[].class,
byte[].class,
char[].class,
double[].class,
float[].class,
int[].class,
long[].class,
short[].class,
Collection.class,
Map.class,
String.class
)
);
}
/**
* Checks, whether the given type element represents a constraint annotation
* or not. That's the case, if the given element is annotated with the
* {@link Constraint} meta-annotation (which is only allowed at annotation
* declarations).
*
* @param element The element of interest.
*
* @return True, if the given element is a constraint annotation type, false
* otherwise.
*/
public boolean isConstraintAnnotation(Element element) {
return element.getAnnotation( Constraint.class ) != null;
}
/**
* Returns the {@link AnnotationType} of the given annotation.
*
* @param annotationMirror The annotation mirror of interest.
*
* @return The given mirror's annotation type.
*/
public AnnotationType getAnnotationType(AnnotationMirror annotationMirror) {
if ( isConstraintAnnotation( annotationMirror ) ) {
return AnnotationType.CONSTRAINT_ANNOTATION;
}
else if ( isMultiValuedConstraint( annotationMirror ) ) {
return AnnotationType.MULTI_VALUED_CONSTRAINT_ANNOTATION;
}
else if ( isGraphValidationAnnotation( annotationMirror ) ) {
return AnnotationType.GRAPH_VALIDATION_ANNOTATION;
}
else if ( isConstraintMetaAnnotation( annotationMirror ) ) {
return AnnotationType.CONSTRAINT_META_ANNOTATION;
}
else if ( isGroupSequenceProviderAnnotation( annotationMirror ) ) {
return AnnotationType.GROUP_SEQUENCE_PROVIDER_ANNOTATION;
}
else {
return AnnotationType.NO_CONSTRAINT_ANNOTATION;
}
}
/**
* Returns a list with the constraint annotations contained in the given
* array-valued annotation mirror.
*
* @param annotationMirror An array-valued annotation mirror (meaning it has an
* array-typed attribute with name "value").
*
* @return A list with the constraint annotations part of the given
* multi-valued constraint annotation. Will return an empty list if
* the given annotation is no multi-valued annotation or if no
* constraint annotations are contained within the given
* array-valued annotation.
*/
public List getPartsOfMultiValuedConstraint(
AnnotationMirror annotationMirror) {
final List theValue = CollectionHelper.newArrayList();
for ( AnnotationValue oneValuePart : annotationApiHelper
.getAnnotationArrayValue( annotationMirror, "value" ) ) {
oneValuePart.accept(
new SimpleAnnotationValueVisitor6() {
@Override
public Void visitAnnotation(AnnotationMirror a, Void p) {
if ( isConstraintAnnotation(
a.getAnnotationType()
.asElement()
) ) {
theValue.add( a );
}
return null;
}
}, null
);
}
return theValue;
}
/**
* Checks whether the given annotation type (which must be a
* constraint annotation type) may be specified at elements of the specified
* type.
*
* @param constraintAnnotationType A constraint annotation type.
* @param typeOfAnnotatedElement A type which with an element is annotated.
*
* @return Whether the given constraint annotation may be specified at
* elements of the given type.
*/
public ConstraintCheckResult checkConstraint(
DeclaredType constraintAnnotationType,
TypeMirror typeOfAnnotatedElement) {
return isBuiltInConstraint( constraintAnnotationType ) ? checkBuiltInConstraint(
constraintAnnotationType, typeOfAnnotatedElement
)
: checkCustomConstraint(
constraintAnnotationType,
typeOfAnnotatedElement
);
}
/**
* Checks, whether the given type element represents a composed constraint or not.
*
* @param element The type element of interest. Must not be null.
*
* @return True if the given element represents a composed constraint, false otherwise.
*/
public boolean isComposedConstraint(TypeElement element) {
return Boolean.TRUE.equals(
element.asType().accept(
new TypeKindVisitor6() {
@Override
public Boolean visitDeclared(DeclaredType constraintValidatorImplementation, Void p) {
return !getComposingConstraints( constraintValidatorImplementation ).isEmpty();
}
}, null
)
);
}
// ==================================
// private API below
// ==================================
/**
* Checks, whether the given annotation mirror represents a constraint
* annotation or not. That's the case, if the given mirror is annotated with
* the {@link Constraint} meta-annotation (which is only allowed at
* annotation declarations).
*
* @param annotationMirror The annotation mirror of interest.
*
* @return True, if the given mirror represents a constraint annotation
* type, false otherwise.
*/
private boolean isConstraintAnnotation(AnnotationMirror annotationMirror) {
return isConstraintAnnotation(
annotationMirror.getAnnotationType()
.asElement()
);
}
/**
* Checks, whether the given annotation mirror represents the {@link javax.validation.Constraint}
* meta-annotation or not.
*
* @param annotationMirror The annotation mirror of interest.
*
* @return True, if the given mirror represents the @Constraint meta-annotation
* type, false otherwise.
*/
private boolean isConstraintMetaAnnotation(AnnotationMirror annotationMirror) {
return annotationMirror.getAnnotationType().asElement().getSimpleName().contentEquals( "Constraint" );
}
/**
* Checks, whether the given annotation mirror represents a multi-valued
* constraint such as {@link javax.validation.constraints.Pattern.List}.
* That is the case if the annotation has an array-typed attribute with name
* "value", that exclusively contains constraint annotations.
*
* @param annotationMirror The annotation mirror of interest.
*
* @return True, if the given mirror represents a multi-valued constraint,
* false otherwise.
*/
private boolean isMultiValuedConstraint(AnnotationMirror annotationMirror) {
List extends AnnotationValue> annotationArrayValue = annotationApiHelper.getAnnotationArrayValue(
annotationMirror, "value"
);
// a multi-valued constraint must have at least one value
if ( annotationArrayValue.isEmpty() ) {
return false;
}
for ( AnnotationValue oneAnnotationValue : annotationArrayValue ) {
Boolean isConstraintAnnotation = oneAnnotationValue.accept(
new SimpleAnnotationValueVisitor6() {
@Override
public Boolean visitAnnotation(
AnnotationMirror a, Void p) {
return isConstraintAnnotation( a.getAnnotationType().asElement() );
}
}, null
);
//TODO GM: have all parts of the array to be constraint annotations?
if ( Boolean.TRUE != isConstraintAnnotation ) {
return false;
}
}
return true;
}
/**
* Checks, whether the given mirror represents the {@link Valid} annotation.
*
* @param annotationMirror The annotation mirror of interest.
*
* @return True, if the given mirror represents the @Valid annotation, false
* otherwise.
*/
private boolean isGraphValidationAnnotation(
AnnotationMirror annotationMirror) {
return typeUtils.isSameType(
annotationMirror.getAnnotationType(),
annotationApiHelper.getMirrorForType( Valid.class )
);
}
/**
* Checks, whether the given mirror represents the {@link GroupSequenceProvider} annotation.
*
* @param annotationMirror The annotation mirror of interest.
*
* @return True, if the given mirror represents the @GroupSequenceProvider annotation, false
* otherwise.
*/
private boolean isGroupSequenceProviderAnnotation(
AnnotationMirror annotationMirror) {
return typeUtils.isSameType(
annotationMirror.getAnnotationType(),
annotationApiHelper.getMirrorForType( GroupSequenceProvider.class )
);
}
private ConstraintCheckResult checkBuiltInConstraint(DeclaredType builtInAnnotationType, TypeMirror typeOfAnnotatedElement) {
Set allowedTypes = getAllowedTypesForBuiltInConstraint( builtInAnnotationType );
for ( TypeMirror oneAllowedType : allowedTypes ) {
if ( typeUtils.isAssignable( typeOfAnnotatedElement, oneAllowedType ) ) {
return ConstraintCheckResult.ALLOWED;
}
}
return ConstraintCheckResult.DISALLOWED;
}
private Set getAllowedTypesForBuiltInConstraint(DeclaredType builtInAnnotationType) {
Set theValue = builtInConstraints.get( builtInAnnotationType.asElement().getSimpleName() );
if ( theValue == null ) {
theValue = Collections.emptySet();
}
return theValue;
}
/**
* Returns a set containing all those types, at which the specified custom
* constraint-annotation is allowed.
*
* @param customAnnotationType A custom constraint type.
* @param typeOfAnnotatedElement The type of the annotated element
*
* @return A set with all types supported by the given constraint. May be
* empty in case of constraint composition, if there is no common
* type supported by all composing constraints.
*/
private ConstraintCheckResult checkCustomConstraint(DeclaredType customAnnotationType, TypeMirror typeOfAnnotatedElement) {
Set composingConstraints = getComposingConstraints( customAnnotationType );
boolean isComposedConstraint = !composingConstraints.isEmpty();
for ( AnnotationMirror oneComposingConstraint : composingConstraints ) {
ConstraintCheckResult annotationCheckResult = checkConstraint(
oneComposingConstraint.getAnnotationType(), typeOfAnnotatedElement
);
if ( annotationCheckResult != ConstraintCheckResult.ALLOWED ) {
return annotationCheckResult;
}
}
Set theValue = getSupportedTypes(
customAnnotationType,
typeOfAnnotatedElement
);
if ( theValue.size() > 1 ) {
return ConstraintCheckResult.MULTIPLE_VALIDATORS_FOUND;
}
else if ( theValue.size() == 1 || isComposedConstraint ) {
return ConstraintCheckResult.ALLOWED;
}
else {
return ConstraintCheckResult.DISALLOWED;
}
}
/**
*
Returns a set with those types supported by the constraint validators
* specified in the @Constraint meta-annotation of the given constraint
* annotation type to which the specified type can be assigned.
*
* If multiple types from the same inheritance hierarchy (e.g. Collection
* and Set) are supported by the validators, only the "lowest" one (e.g.
* Set) will be part of the result.
*
*
* @param constraintAnnotationType A constraint annotation type.
* @param type A type.
*
* @return A set with the supported types.
*/
private Set getSupportedTypes(
DeclaredType constraintAnnotationType, TypeMirror type) {
Set theValue = CollectionHelper.newHashSet();
//the Constraint meta-annotation at the type declaration, e.g. "@Constraint(validatedBy = CheckCaseValidator.class)"
AnnotationMirror constraintMetaAnnotation = getConstraintMetaAnnotation( constraintAnnotationType );
//the validator classes, e.g. [CheckCaseValidator.class]
List extends AnnotationValue> validatorClassReferences = getValidatorClassesFromConstraintMetaAnnotation(
constraintMetaAnnotation
);
for ( AnnotationValue oneValidatorClassReference : validatorClassReferences ) {
TypeMirror supportedType = getSupportedType( oneValidatorClassReference );
if ( typeUtils.isAssignable( type, supportedType ) ) {
theValue.add( supportedType );
}
}
return annotationApiHelper.keepLowestTypePerHierarchy( theValue );
}
private TypeMirror getSupportedType(AnnotationValue oneValidatorClassReference) {
TypeMirror validatorType = oneValidatorClassReference.accept(
new SimpleAnnotationValueVisitor6() {
@Override
public TypeMirror visitType(TypeMirror t, Void p) {
return t;
}
}, null
);
// contains the bindings of the type parameters from the implemented
// ConstraintValidator interface, e.g. "ConstraintValidator"
TypeMirror constraintValidatorImplementation = getConstraintValidatorSuperType( validatorType );
return constraintValidatorImplementation.accept(
new TypeKindVisitor6() {
@Override
public TypeMirror visitDeclared(DeclaredType constraintValidatorImplementation, Void p) {
// 2nd type parameter contains the data type supported by current validator class, e.g. "String"
return constraintValidatorImplementation.getTypeArguments().get( 1 );
}
}, null
);
}
private TypeMirror getConstraintValidatorSuperType(TypeMirror type) {
List extends TypeMirror> superTypes = typeUtils.directSupertypes( type );
List nextSuperTypes = CollectionHelper.newArrayList();
//follow the type hierarchy upwards, until we have found the ConstraintValidator IF
while ( !superTypes.isEmpty() ) {
for ( TypeMirror oneSuperType : superTypes ) {
if ( typeUtils.asElement( oneSuperType ).getSimpleName()
.contentEquals( ConstraintValidator.class.getSimpleName() ) ) {
return oneSuperType;
}
nextSuperTypes.addAll( typeUtils.directSupertypes( oneSuperType ) );
}
superTypes = nextSuperTypes;
nextSuperTypes = CollectionHelper.newArrayList();
}
//HV-293: Actually this should never happen, as we can have only ConstraintValidator implementations
//here. The Eclipse JSR 269 implementation unfortunately doesn't always create the type hierarchy
//properly though.
//TODO GM: create and report an isolated test case
throw new IllegalStateException( "Expected type " + type + " to implement javax.validation.ConstraintValidator, but it doesn't." );
}
/**
* Retrieves the {@link Constraint} meta-annotation from the given
* constraint annotation.
*
* @param annotationType A constraint type.
*
* @return The Constraint meta-annotation.
*
* @throws IllegalArgumentException If the given constraint annotation type isn't annotated with
* the {@link Constraint} meta-annotation.
*/
private AnnotationMirror getConstraintMetaAnnotation(DeclaredType annotationType) {
List extends AnnotationMirror> annotationMirrors = annotationType.asElement().getAnnotationMirrors();
AnnotationMirror constraintMetaAnnotation = annotationApiHelper.getMirror(
annotationMirrors, Constraint.class
);
if ( constraintMetaAnnotation == null ) {
throw new IllegalArgumentException( "Given type " + annotationType + " isn't a constraint annotation type." );
}
return constraintMetaAnnotation;
}
private List extends AnnotationValue> getValidatorClassesFromConstraintMetaAnnotation(AnnotationMirror constraintMetaAnnotation) {
AnnotationValue validatedBy = annotationApiHelper.getAnnotationValue( constraintMetaAnnotation, "validatedBy" );
return validatedBy.accept(
new SimpleAnnotationValueVisitor6, Void>() {
@Override
public List extends AnnotationValue> visitArray(List extends AnnotationValue> values, Void p) {
return values;
}
}, null
);
}
private void registerAllowedTypesForBuiltInConstraint(Class extends Annotation> annotation, Set> allowedTypes) {
Set allowedTypesForConstraint = getAllowedTypesForBuiltInConstraint( annotation );
for ( Class> oneAllowedType : allowedTypes ) {
allowedTypesForConstraint.add( annotationApiHelper.getMirrorForType( oneAllowedType ) );
}
}
private void registerAllowedTypesForBuiltInConstraintByNames(Class extends Annotation> annotation, Set allowedTypes) {
Set allowedTypesForConstraint = getAllowedTypesForBuiltInConstraint( annotation );
for ( String oneAllowedType : allowedTypes ) {
allowedTypesForConstraint.add( annotationApiHelper.getDeclaredTypeByName( oneAllowedType ) );
}
}
private Set getAllowedTypesForBuiltInConstraint(Class extends Annotation> annotation) {
Name key = elementUtils.getName( annotation.getSimpleName() );
Set allowedTypes = builtInConstraints.get( key );
// create a mapping for the given annotation type if required
if ( allowedTypes == null ) {
allowedTypes = CollectionHelper.newHashSet();
builtInConstraints.put( key, allowedTypes );
}
return allowedTypes;
}
/**
* Checks, whether the given constraint annotation type is a built-in
* constraint annotation (which is the case, if it is declared in the
* package javax.validation.constraints).
*
* @param constraintAnnotationType The type to check.
*
* @return True, if the given type is a built-in constraint annotation type,
* false otherwise.
*/
private boolean isBuiltInConstraint(DeclaredType constraintAnnotationType) {
return
CONSTRAINT_ANNOTATION_PACKAGE_NAME.equals(
elementUtils.getPackageOf( constraintAnnotationType.asElement() ).getQualifiedName()
);
}
private Set getComposingConstraints(DeclaredType constraintAnnotationType) {
Set theValue = CollectionHelper.newHashSet();
List extends AnnotationMirror> annotationMirrors = constraintAnnotationType.asElement()
.getAnnotationMirrors();
for ( AnnotationMirror oneAnnotationMirror : annotationMirrors ) {
if ( isConstraintAnnotation( oneAnnotationMirror.getAnnotationType().asElement() ) ) {
theValue.add( oneAnnotationMirror );
}
}
return theValue;
}
}
MessagerAdapter.java 0000664 0000000 0000000 00000005575 12364444513 0043206 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/util /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.util;
import java.text.MessageFormat;
import java.util.ResourceBundle;
import java.util.Set;
import javax.annotation.processing.Messager;
import javax.tools.Diagnostic.Kind;
import org.hibernate.validator.ap.checks.ConstraintCheckError;
/**
* Wrapper around {@link Messager}, which adds the ability to format error messages using {@link MessageFormat}.
*
* @author Gunnar Morling
*/
public class MessagerAdapter {
/**
* Contains the texts to be displayed.
*/
private final ResourceBundle errorMessages;
private final Messager messager;
/**
* The kind of diagnostic to be used when reporting any problems.
*/
private Kind diagnosticKind;
/**
* Creates a new MessagerAdapter.
*
* @param messager The underlying messager.
* @param diagnosticKind The kind with which messages shall be reported.
*/
public MessagerAdapter(Messager messager, Kind diagnosticKind) {
this.messager = messager;
this.diagnosticKind = diagnosticKind;
errorMessages = ResourceBundle.getBundle( "org.hibernate.validator.ap.ValidationProcessorMessages" );
}
/**
* Returns the messager used by this adapter.
*
* @return The underlying messager.
*/
public Messager getDelegate() {
return messager;
}
/**
* Reports the given errors against the underlying {@link Messager} using
* the specified {@link Kind}.
*
* @param errors A set with errors to report. May be empty but must not be
* null.
*/
public void reportErrors(Set errors) {
for ( ConstraintCheckError oneError : errors ) {
reportError( oneError );
}
}
/**
* Reports the given error. Message parameters will be put into the template
* retrieved from the resource bundle if applicable.
*
* @param error The error to report.
*/
private void reportError(ConstraintCheckError error) {
String message = errorMessages.getString( error.getMessageKey() );
if ( error.getMessageParameters() != null ) {
message = MessageFormat.format( message, error.getMessageParameters() );
}
messager.printMessage(
diagnosticKind, message, error.getElement(), error.getAnnotationMirror()
);
}
}
package.html 0000664 0000000 0000000 00000001770 12364444513 0041546 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/main/java/org/hibernate/validator/ap/util
This package contains helper classes.
hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/main/resources/ 0000775 0000000 0000000 00000000000 12364444513 0032336 5 ustar 00root root 0000000 0000000 0000775 0000000 0000000 00000000000 12364444513 0033417 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/main/resources/META-INF 0000775 0000000 0000000 00000000000 12364444513 0035242 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/main/resources/META-INF/services javax.annotation.processing.Processor 0000664 0000000 0000000 00000000070 12364444513 0044575 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/main/resources/META-INF/services org.hibernate.validator.ap.ConstraintValidationProcessor hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/main/resources/org/ 0000775 0000000 0000000 00000000000 12364444513 0033125 5 ustar 00root root 0000000 0000000 0000775 0000000 0000000 00000000000 12364444513 0035007 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/main/resources/org/hibernate 0000775 0000000 0000000 00000000000 12364444513 0036774 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/main/resources/org/hibernate/validator 0000775 0000000 0000000 00000000000 12364444513 0037374 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/main/resources/org/hibernate/validator/ap ValidationProcessorMessages.properties 0000664 0000000 0000000 00000006614 12364444513 0047203 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/main/resources/org/hibernate/validator/ap # Contains error messages to be used by the ConstraintValidationProcessor.
ONLY_GETTERS_MAY_BE_ANNOTATED=Constraint annotations must not be specified at methods, which are no valid JavaBeans getter methods.
NOT_SUPPORTED_TYPE=The annotation @{0} is disallowed for this data type.
NOT_SUPPORTED_RETURN_TYPE=The annotation @{0} is disallowed for the return type of this method.
ONLY_CONSTRAINT_ANNOTATIONS_MAY_BE_ANNOTATED=Constraint annotations must not be specified at annotation types, which are no constraint annotation types themselves.
STATIC_METHODS_MAY_NOT_BE_ANNOTATED=Only non-static methods may be annotated with constraint annotations.
STATIC_FIELDS_MAY_NOT_BE_ANNOTATED=Only non-static fields may be annotated with constraint annotations.
INVALID_DIAGNOSTIC_KIND_GIVEN=The given value {0} is no valid diagnostic kind. Kind.ERROR will be used.
ATVALID_NOT_ALLOWED_AT_PRIMITIVE_FIELD=Fields of a primitive type must not annotated with @Valid.
ATVALID_NOT_ALLOWED_AT_METHOD_RETURNING_PRIMITIVE_TYPE=Methods returning a primitive type must not annotated with @Valid.
CONSTRAINT_TYPE_WITH_MISSING_OR_WRONG_RETENTION=Constraint annotation types must be annotated with @Retention(RUNTIME).
CONSTRAINT_TYPE_WITH_WRONG_TARGET=Constraint annotation types must have at least one of the element types FIELD, METHOD, TYPE or ANNOTATION_TYPE as target.
CONSTRAINT_TYPE_WITHOUT_VALIDATOR=For non-composed constraints a validator implementation must be specified using @Constraint#validatedBy().
CONSTRAINT_TYPE_MUST_DECLARE_MESSAGE_MEMBER=Constraint annotation types must declare a member 'String message()'.
RETURN_TYPE_MUST_BE_STRING=Return type of constraint annotation type member 'message()' must be 'String'.
CONSTRAINT_TYPE_MUST_DECLARE_GROUPS_MEMBER=Constraint annotation types must declare a member 'Class>[] groups() default {}'.
RETURN_TYPE_MUST_BE_CLASS_ARRAY=Return type of constraint annotation type member 'groups()' must be 'Class>[]'.
DEFAULT_VALUE_MUST_BE_EMPTY_ARRAY=Default value of the 'groups()' member must be an empty array.
CONSTRAINT_TYPE_MUST_DECLARE_PAYLOAD_MEMBER=Constraint annotation types must declare a member 'Class extends Payload>[] payload() default {}'.
PAYLOAD_RETURN_TYPE_MUST_BE_CLASS_ARRAY=Return type of constraint annotation type member 'payload()' must be 'Class extends Payload>[]'.
PAYLOAD_DEFAULT_VALUE_MUST_BE_EMPTY_ARRAY=Default value of the 'payload()' member must be an empty array.
GROUP_SEQUENCE_PROVIDER_ANNOTATION_MUST_BE_DEFINED_ON_A_CLASS=The annotation @GroupSequenceProvider must be defined on a class.
GROUP_SEQUENCE_PROVIDER_ANNOTATION_NOT_ALLOWED_ON_CLASS_WITH_GROUP_SEQUENCE_ANNOTATION=The annotation @GroupSequenceProvider cannot be defined on class annotated with @GroupSequence.
GROUP_SEQUENCE_PROVIDER_ANNOTATION_VALUE_MUST_BE_AN_IMPLEMENTATION_CLASS=The annotation @GroupSequenceProvider must define an implementation or a concrete implementation of DefaultGroupSequenceProvider interface.
GROUP_SEQUENCE_PROVIDER_ANNOTATION_VALUE_DEFINED_PROVIDER_CLASS_WITH_WRONG_TYPE=The annotation @GroupSequenceProvider defines a default group sequence provider for type {0} instead of {1} (super)type.
GROUP_SEQUENCE_PROVIDER_ANNOTATION_VALUE_CLASS_MUST_HAVE_DEFAULT_CONSTRUCTOR=The annotation @GroupSequenceProvider defines a default group sequence provider class without a public default constructor.
ONLY_NON_VOID_METHODS_MAY_BE_ANNOTATED=Void methods may not be annotated with constraint annotations.
hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/ 0000775 0000000 0000000 00000000000 12364444513 0030357 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/ 0000775 0000000 0000000 00000000000 12364444513 0031300 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/ 0000775 0000000 0000000 00000000000 12364444513 0032067 5 ustar 00root root 0000000 0000000 0000775 0000000 0000000 00000000000 12364444513 0033751 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate 0000775 0000000 0000000 00000000000 12364444513 0035736 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator 0000775 0000000 0000000 00000000000 12364444513 0036336 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap AnnotationTypeValidationTest.java 0000664 0000000 0000000 00000015045 12364444513 0045035 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap;
import java.io.File;
import javax.tools.Diagnostic.Kind;
import org.testng.annotations.Test;
import org.hibernate.validator.ap.testmodel.constrainttypes.ConstraintsWithIllegalRetentionPolicies;
import org.hibernate.validator.ap.testmodel.constrainttypes.ConstraintsWithIllegalTargets;
import org.hibernate.validator.ap.testmodel.constrainttypes.ConstraintsWithWrongGroupsAttribute;
import org.hibernate.validator.ap.testmodel.constrainttypes.ConstraintsWithWrongMessageAttribute;
import org.hibernate.validator.ap.testmodel.constrainttypes.ConstraintsWithWrongPayloadAttribute;
import org.hibernate.validator.ap.testmodel.constrainttypes.ConstraintsWithoutValidator;
import org.hibernate.validator.ap.testmodel.constrainttypes.DummyValidator;
import org.hibernate.validator.ap.testmodel.constrainttypes.ValidCustomerNumber;
import org.hibernate.validator.ap.util.DiagnosticExpectation;
import static org.hibernate.validator.ap.testutil.CompilerTestHelper.assertThatDiagnosticsMatch;
import static org.testng.Assert.assertFalse;
/**
* Test cases for {@link ConstraintValidationProcessor} testing the checking of constraint
* annotation type declarations.
*
* @author Gunnar Morling.
*/
public class AnnotationTypeValidationTest extends ConstraintValidationProcessorTestBase {
@Test
public void testThatSpecifyingConstraintAnnotationAtNonConstraintAnnotationTypeCausesCompilationError() {
File sourceFile = compilerHelper.getSourceFile( ValidCustomerNumber.class );
boolean compilationResult =
compilerHelper.compile( new ConstraintValidationProcessor(), diagnostics, sourceFile );
assertFalse( compilationResult );
assertThatDiagnosticsMatch(
diagnostics, new DiagnosticExpectation( Kind.ERROR, 27 ), new DiagnosticExpectation( Kind.ERROR, 28 )
);
}
@Test
public void testThatConstraintAnnotationTypeWithWrongRetentionPolicyCausesCompilationError() {
File sourceFile1 = compilerHelper.getSourceFile( ConstraintsWithIllegalRetentionPolicies.class );
File sourceFile2 = compilerHelper.getSourceFile( DummyValidator.class );
boolean compilationResult =
compilerHelper.compile( new ConstraintValidationProcessor(), diagnostics, sourceFile1, sourceFile2 );
assertFalse( compilationResult );
assertThatDiagnosticsMatch(
diagnostics,
new DiagnosticExpectation( Kind.ERROR, 33 ), new DiagnosticExpectation( Kind.ERROR, 48 )
);
}
@Test
public void testThatConstraintAnnotationTypeWithWrongTargetCausesCompilationError() {
File sourceFile1 = compilerHelper.getSourceFile( ConstraintsWithIllegalTargets.class );
File sourceFile2 = compilerHelper.getSourceFile( DummyValidator.class );
boolean compilationResult =
compilerHelper.compile( new ConstraintValidationProcessor(), diagnostics, sourceFile1, sourceFile2 );
assertFalse( compilationResult );
assertThatDiagnosticsMatch(
diagnostics,
new DiagnosticExpectation( Kind.ERROR, 42 ), new DiagnosticExpectation( Kind.ERROR, 58 )
);
}
@Test
public void testThatConstraintAnnotationTypeWithoutValidatorCausesCompilationError() {
File sourceFile1 = compilerHelper.getSourceFile( ConstraintsWithoutValidator.class );
File sourceFile2 = compilerHelper.getSourceFile( DummyValidator.class );
boolean compilationResult =
compilerHelper.compile( new ConstraintValidationProcessor(), diagnostics, sourceFile1, sourceFile2 );
assertFalse( compilationResult );
assertThatDiagnosticsMatch(
diagnostics,
new DiagnosticExpectation( Kind.ERROR, 34 )
);
}
@Test
public void testThatConstraintAnnotationTypeWithMissingOrWrongMessageAttributeCausesCompilationError() {
File sourceFile1 = compilerHelper.getSourceFile( ConstraintsWithWrongMessageAttribute.class );
File sourceFile2 = compilerHelper.getSourceFile( DummyValidator.class );
boolean compilationResult =
compilerHelper.compile( new ConstraintValidationProcessor(), diagnostics, sourceFile1, sourceFile2 );
assertFalse( compilationResult );
assertThatDiagnosticsMatch(
diagnostics,
new DiagnosticExpectation( Kind.ERROR, 34 ), new DiagnosticExpectation( Kind.ERROR, 49 )
);
}
@Test
public void testThatConstraintAnnotationTypeWithMissingOrWrongGroupsAttributeCausesCompilationError() {
File sourceFile1 = compilerHelper.getSourceFile( ConstraintsWithWrongGroupsAttribute.class );
File sourceFile2 = compilerHelper.getSourceFile( DummyValidator.class );
boolean compilationResult =
compilerHelper.compile( new ConstraintValidationProcessor(), diagnostics, sourceFile1, sourceFile2 );
assertFalse( compilationResult );
assertThatDiagnosticsMatch(
diagnostics,
new DiagnosticExpectation( Kind.ERROR, 34 ),
new DiagnosticExpectation( Kind.ERROR, 51 ),
new DiagnosticExpectation( Kind.ERROR, 66 ),
new DiagnosticExpectation( Kind.ERROR, 81 ),
new DiagnosticExpectation( Kind.ERROR, 96 ),
new DiagnosticExpectation( Kind.ERROR, 111 ),
new DiagnosticExpectation( Kind.ERROR, 126 )
);
}
@Test
public void testThatConstraintAnnotationTypeWithMissingOrPayloadGroupsAttributeCausesCompilationError() {
File sourceFile1 = compilerHelper.getSourceFile( ConstraintsWithWrongPayloadAttribute.class );
File sourceFile2 = compilerHelper.getSourceFile( DummyValidator.class );
boolean compilationResult =
compilerHelper.compile( new ConstraintValidationProcessor(), diagnostics, sourceFile1, sourceFile2 );
assertFalse( compilationResult );
assertThatDiagnosticsMatch(
diagnostics,
new DiagnosticExpectation( Kind.ERROR, 34 ),
new DiagnosticExpectation( Kind.ERROR, 52 ),
new DiagnosticExpectation( Kind.ERROR, 67 ),
new DiagnosticExpectation( Kind.ERROR, 82 ),
new DiagnosticExpectation( Kind.ERROR, 97 ),
new DiagnosticExpectation( Kind.ERROR, 112 ),
new DiagnosticExpectation( Kind.ERROR, 127 ),
new DiagnosticExpectation( Kind.ERROR, 142 )
);
}
}
ConstraintValidationProcessorTest.java 0000664 0000000 0000000 00000042252 12364444513 0046105 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap;
import java.io.File;
import javax.tools.Diagnostic;
import javax.tools.Diagnostic.Kind;
import org.testng.annotations.Test;
import org.hibernate.validator.ap.testmodel.FieldLevelValidationUsingBuiltInConstraints;
import org.hibernate.validator.ap.testmodel.MethodLevelValidationUsingBuiltInConstraints;
import org.hibernate.validator.ap.testmodel.ModelWithJodaTypes;
import org.hibernate.validator.ap.testmodel.MultipleConstraintsOfSameType;
import org.hibernate.validator.ap.testmodel.ValidationUsingAtValidAnnotation;
import org.hibernate.validator.ap.testmodel.boxing.ValidLong;
import org.hibernate.validator.ap.testmodel.boxing.ValidLongValidator;
import org.hibernate.validator.ap.testmodel.boxing.ValidationUsingBoxing;
import org.hibernate.validator.ap.testmodel.classlevelconstraints.ClassLevelValidation;
import org.hibernate.validator.ap.testmodel.classlevelconstraints.ValidCustomer;
import org.hibernate.validator.ap.testmodel.classlevelconstraints.ValidCustomerValidator;
import org.hibernate.validator.ap.testmodel.composedconstraint.FieldLevelValidationUsingComposedConstraint;
import org.hibernate.validator.ap.testmodel.composedconstraint.ValidOrderNumber;
import org.hibernate.validator.ap.testmodel.composedconstraint2.ComposedConstraint;
import org.hibernate.validator.ap.testmodel.composedconstraint2.ComposingConstraint1;
import org.hibernate.validator.ap.testmodel.composedconstraint2.ComposingConstraint1ValidatorForGregorianCalendar;
import org.hibernate.validator.ap.testmodel.composedconstraint2.ComposingConstraint1ValidatorForList;
import org.hibernate.validator.ap.testmodel.composedconstraint2.ComposingConstraint1ValidatorForString;
import org.hibernate.validator.ap.testmodel.composedconstraint2.ComposingConstraint2;
import org.hibernate.validator.ap.testmodel.composedconstraint2.ComposingConstraint2ValidatorForArrayList;
import org.hibernate.validator.ap.testmodel.composedconstraint2.ComposingConstraint2ValidatorForCalendar;
import org.hibernate.validator.ap.testmodel.composedconstraint2.ComposingConstraint2ValidatorForCollection;
import org.hibernate.validator.ap.testmodel.composedconstraint2.FieldLevelValidationUsingComplexComposedConstraint;
import org.hibernate.validator.ap.testmodel.customconstraints.CaseMode;
import org.hibernate.validator.ap.testmodel.customconstraints.CheckCase;
import org.hibernate.validator.ap.testmodel.customconstraints.CheckCaseValidator;
import org.hibernate.validator.ap.testmodel.customconstraints.FieldLevelValidationUsingCustomConstraints;
import org.hibernate.validator.ap.testmodel.groupsequenceprovider.BazDefaultGroupSequenceProvider;
import org.hibernate.validator.ap.testmodel.groupsequenceprovider.FooBarBazDefaultGroupSequenceProvider;
import org.hibernate.validator.ap.testmodel.groupsequenceprovider.FooBarDefaultGroupSequenceProvider;
import org.hibernate.validator.ap.testmodel.groupsequenceprovider.FooDefaultGroupSequenceProvider;
import org.hibernate.validator.ap.testmodel.groupsequenceprovider.GroupSequenceProviderDefinition;
import org.hibernate.validator.ap.testmodel.groupsequenceprovider.QuxDefaultGroupSequenceProvider;
import org.hibernate.validator.ap.testmodel.groupsequenceprovider.SampleDefaultGroupSequenceProvider;
import org.hibernate.validator.ap.testmodel.inheritedvalidator.AbstractCustomConstraintValidator;
import org.hibernate.validator.ap.testmodel.inheritedvalidator.CustomConstraint;
import org.hibernate.validator.ap.testmodel.inheritedvalidator.CustomConstraintValidator;
import org.hibernate.validator.ap.testmodel.inheritedvalidator.FieldLevelValidationUsingInheritedValidator;
import org.hibernate.validator.ap.testmodel.nouniquevalidatorresolution.NoUniqueValidatorResolution;
import org.hibernate.validator.ap.testmodel.nouniquevalidatorresolution.SerializableCollection;
import org.hibernate.validator.ap.testmodel.nouniquevalidatorresolution.Size;
import org.hibernate.validator.ap.testmodel.nouniquevalidatorresolution.SizeValidatorForCollection;
import org.hibernate.validator.ap.testmodel.nouniquevalidatorresolution.SizeValidatorForSerializable;
import org.hibernate.validator.ap.testmodel.nouniquevalidatorresolution.SizeValidatorForSet;
import org.hibernate.validator.ap.util.DiagnosticExpectation;
import static org.hibernate.validator.ap.testutil.CompilerTestHelper.assertThatDiagnosticsMatch;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
/**
* Miscellaneous tests for {@link ConstraintValidationProcessor}.
*
* @author Gunnar Morling.
* @author Kevin Pollet - SERLI - (kevin.pollet@serli.com)
*/
public class ConstraintValidationProcessorTest extends ConstraintValidationProcessorTestBase {
@Test
public void fieldLevelValidationUsingBuiltInConstraints() {
File sourceFile = compilerHelper.getSourceFile( FieldLevelValidationUsingBuiltInConstraints.class );
boolean compilationResult =
compilerHelper.compile( new ConstraintValidationProcessor(), diagnostics, sourceFile );
assertFalse( compilationResult );
assertThatDiagnosticsMatch(
diagnostics, new DiagnosticExpectation( Kind.ERROR, 53 ), new DiagnosticExpectation( Kind.ERROR, 59 )
);
}
@Test
public void testThatProcessorOptionsAreEvaluated() {
File sourceFile = compilerHelper.getSourceFile( FieldLevelValidationUsingBuiltInConstraints.class );
// compile with -AdiagnosticKind=Kind.WARNING and -Averbose=true
boolean compilationResult =
compilerHelper.compile(
new ConstraintValidationProcessor(), diagnostics, Kind.WARNING, true, false, sourceFile
);
// compilation succeeds as there are problems, but Kind.WARNING won't stop compilation
assertTrue( compilationResult );
assertThatDiagnosticsMatch(
diagnostics,
new DiagnosticExpectation( Kind.NOTE, Diagnostic.NOPOS ), //says that verbose messaging is enabled
new DiagnosticExpectation( Kind.WARNING, 53 ),
new DiagnosticExpectation( Kind.WARNING, 59 )
);
}
@Test
public void fieldLevelValidationUsingCustomConstraints() {
File sourceFile1 = compilerHelper.getSourceFile( FieldLevelValidationUsingCustomConstraints.class );
File sourceFile2 = compilerHelper.getSourceFile( CheckCase.class );
File sourceFile3 = compilerHelper.getSourceFile( CaseMode.class );
File sourceFile4 = compilerHelper.getSourceFile( CheckCaseValidator.class );
boolean compilationResult =
compilerHelper.compile(
new ConstraintValidationProcessor(),
diagnostics,
sourceFile1,
sourceFile2,
sourceFile3,
sourceFile4
);
assertFalse( compilationResult );
assertThatDiagnosticsMatch( diagnostics, new DiagnosticExpectation( Kind.ERROR, 29 ) );
}
@Test
public void testThatInheritedValidatorClassesAreHandledCorrectly() {
File sourceFile1 = compilerHelper.getSourceFile( FieldLevelValidationUsingInheritedValidator.class );
File sourceFile2 = compilerHelper.getSourceFile( CustomConstraint.class );
File sourceFile3 = compilerHelper.getSourceFile( AbstractCustomConstraintValidator.class );
File sourceFile4 = compilerHelper.getSourceFile( CustomConstraintValidator.class );
boolean compilationResult =
compilerHelper.compile(
new ConstraintValidationProcessor(),
diagnostics,
sourceFile1,
sourceFile2,
sourceFile3,
sourceFile4
);
assertFalse( compilationResult );
assertThatDiagnosticsMatch( diagnostics, new DiagnosticExpectation( Kind.ERROR, 29 ) );
}
@Test
public void methodLevelValidationUsingBuiltInConstraints() {
File sourceFile = compilerHelper.getSourceFile( MethodLevelValidationUsingBuiltInConstraints.class );
boolean compilationResult =
compilerHelper.compile( new ConstraintValidationProcessor(), diagnostics, false, false, sourceFile );
assertFalse( compilationResult );
assertThatDiagnosticsMatch(
diagnostics,
new DiagnosticExpectation( Kind.ERROR, 31 ),
new DiagnosticExpectation( Kind.ERROR, 38 ),
new DiagnosticExpectation( Kind.ERROR, 46 ),
new DiagnosticExpectation( Kind.ERROR, 53 ),
new DiagnosticExpectation( Kind.ERROR, 61 ),
new DiagnosticExpectation( Kind.ERROR, 69 ),
new DiagnosticExpectation( Kind.ERROR, 77 ),
new DiagnosticExpectation( Kind.ERROR, 84 )
);
}
/**
* Constraints are allowed at non-getters per processor option, but all other
* checks (no static methods allowed etc.) still apply.
*/
@Test
public void methodLevelConstraintsAllowedAtNonGetterMethods() {
File sourceFile = compilerHelper.getSourceFile( MethodLevelValidationUsingBuiltInConstraints.class );
//compile with -AmethodConstraintsSupported
boolean compilationResult =
compilerHelper.compile( new ConstraintValidationProcessor(), diagnostics, false, true, sourceFile );
assertFalse( compilationResult );
assertThatDiagnosticsMatch(
diagnostics,
new DiagnosticExpectation( Kind.ERROR, 31 ),
new DiagnosticExpectation( Kind.ERROR, 38 ),
new DiagnosticExpectation( Kind.ERROR, 46 ),
new DiagnosticExpectation( Kind.ERROR, 53 ),
new DiagnosticExpectation( Kind.ERROR, 69 ),
new DiagnosticExpectation( Kind.ERROR, 77 ),
new DiagnosticExpectation( Kind.ERROR, 84 )
);
}
@Test
public void classLevelValidation() {
File sourceFile1 = compilerHelper.getSourceFile( ClassLevelValidation.class );
File sourceFile2 = compilerHelper.getSourceFile( ValidCustomer.class );
File sourceFile3 = compilerHelper.getSourceFile( ValidCustomerValidator.class );
boolean compilationResult =
compilerHelper.compile(
new ConstraintValidationProcessor(), diagnostics, sourceFile1, sourceFile2, sourceFile3
);
assertFalse( compilationResult );
assertThatDiagnosticsMatch( diagnostics, new DiagnosticExpectation( Kind.ERROR, 27 ) );
}
@Test
public void validationUsingComposedConstraint() {
File sourceFile1 = compilerHelper.getSourceFile( FieldLevelValidationUsingComposedConstraint.class );
File sourceFile2 = compilerHelper.getSourceFile( ValidOrderNumber.class );
boolean compilationResult =
compilerHelper.compile( new ConstraintValidationProcessor(), diagnostics, sourceFile1, sourceFile2 );
assertFalse( compilationResult );
assertThatDiagnosticsMatch( diagnostics, new DiagnosticExpectation( Kind.ERROR, 28 ) );
}
@Test
public void validationUsingComplexComposedConstraint() {
File sourceFile1 = compilerHelper.getSourceFile( FieldLevelValidationUsingComplexComposedConstraint.class );
File sourceFile2 = compilerHelper.getSourceFile( ComposedConstraint.class );
File sourceFile3 = compilerHelper.getSourceFile( ComposingConstraint1.class );
File sourceFile4 = compilerHelper.getSourceFile( ComposingConstraint1ValidatorForString.class );
File sourceFile5 = compilerHelper.getSourceFile( ComposingConstraint1ValidatorForGregorianCalendar.class );
File sourceFile6 = compilerHelper.getSourceFile( ComposingConstraint1ValidatorForList.class );
File sourceFile7 = compilerHelper.getSourceFile( ComposingConstraint2.class );
File sourceFile8 = compilerHelper.getSourceFile( ComposingConstraint2ValidatorForArrayList.class );
File sourceFile9 = compilerHelper.getSourceFile( ComposingConstraint2ValidatorForCalendar.class );
File sourceFile10 = compilerHelper.getSourceFile( ComposingConstraint2ValidatorForCollection.class );
boolean compilationResult =
compilerHelper.compile(
new ConstraintValidationProcessor(),
diagnostics,
sourceFile1,
sourceFile2,
sourceFile3,
sourceFile4,
sourceFile5,
sourceFile6,
sourceFile7,
sourceFile8,
sourceFile9,
sourceFile10
);
assertFalse( compilationResult );
assertThatDiagnosticsMatch(
diagnostics,
new DiagnosticExpectation( Kind.ERROR, 28 ),
new DiagnosticExpectation( Kind.ERROR, 40 ),
new DiagnosticExpectation( Kind.ERROR, 49 ),
new DiagnosticExpectation( Kind.ERROR, 55 )
);
}
@Test
public void validationUsingBoxing() {
File sourceFile1 = compilerHelper.getSourceFile( ValidationUsingBoxing.class );
File sourceFile2 = compilerHelper.getSourceFile( ValidLong.class );
File sourceFile3 = compilerHelper.getSourceFile( ValidLongValidator.class );
boolean compilationResult =
compilerHelper.compile(
new ConstraintValidationProcessor(), diagnostics, sourceFile1, sourceFile2, sourceFile3
);
assertFalse( compilationResult );
assertThatDiagnosticsMatch(
diagnostics,
new DiagnosticExpectation( Kind.ERROR, 30 ),
new DiagnosticExpectation( Kind.ERROR, 36 ),
new DiagnosticExpectation( Kind.ERROR, 42 ),
new DiagnosticExpectation( Kind.ERROR, 58 ),
new DiagnosticExpectation( Kind.ERROR, 66 )
);
}
@Test
public void testThatNonUniqueValidatorResolutionCausesCompilationError() {
File sourceFile1 = compilerHelper.getSourceFile( NoUniqueValidatorResolution.class );
File sourceFile2 = compilerHelper.getSourceFile( Size.class );
File sourceFile3 = compilerHelper.getSourceFile( SizeValidatorForCollection.class );
File sourceFile4 = compilerHelper.getSourceFile( SizeValidatorForSerializable.class );
File sourceFile5 = compilerHelper.getSourceFile( SerializableCollection.class );
File sourceFile6 = compilerHelper.getSourceFile( SizeValidatorForSet.class );
boolean compilationResult =
compilerHelper.compile(
new ConstraintValidationProcessor(),
diagnostics,
sourceFile1,
sourceFile2,
sourceFile3,
sourceFile4,
sourceFile5,
sourceFile6
);
assertFalse( compilationResult );
assertThatDiagnosticsMatch(
diagnostics, new DiagnosticExpectation(
Kind.ERROR, 32
)
);
}
@Test
public void testThatMultiValuedConstrainedIsOnlyGivenAtSupportedType() {
File sourceFile1 = compilerHelper.getSourceFile( MultipleConstraintsOfSameType.class );
boolean compilationResult = compilerHelper.compile(
new ConstraintValidationProcessor(), diagnostics, sourceFile1
);
assertFalse( compilationResult );
assertThatDiagnosticsMatch(
diagnostics,
new DiagnosticExpectation( Kind.ERROR, 32 ),
new DiagnosticExpectation( Kind.ERROR, 32 )
);
}
@Test
public void testThatAtValidAnnotationGivenAtNotSupportedTypesCausesCompilationErrors() {
File sourceFile1 = compilerHelper.getSourceFile( ValidationUsingAtValidAnnotation.class );
boolean compilationResult = compilerHelper.compile(
new ConstraintValidationProcessor(), diagnostics, false, false, sourceFile1
);
assertFalse( compilationResult );
assertThatDiagnosticsMatch(
diagnostics,
new DiagnosticExpectation( Kind.ERROR, 33 ),
new DiagnosticExpectation( Kind.ERROR, 39 ),
new DiagnosticExpectation( Kind.ERROR, 55 ),
new DiagnosticExpectation( Kind.ERROR, 63 ),
new DiagnosticExpectation( Kind.ERROR, 71 ),
new DiagnosticExpectation( Kind.ERROR, 79 ),
new DiagnosticExpectation( Kind.ERROR, 87 )
);
}
@Test
public void groupSequenceProvider() {
File sourceFile1 = compilerHelper.getSourceFile( GroupSequenceProviderDefinition.class );
File sourceFile2 = compilerHelper.getSourceFile( BazDefaultGroupSequenceProvider.class );
File sourceFile3 = compilerHelper.getSourceFile( FooDefaultGroupSequenceProvider.class );
File sourceFile4 = compilerHelper.getSourceFile( QuxDefaultGroupSequenceProvider.class );
File sourceFile5 = compilerHelper.getSourceFile( SampleDefaultGroupSequenceProvider.class );
File sourceFile6 = compilerHelper.getSourceFile( FooBarDefaultGroupSequenceProvider.class );
File sourceFile7 = compilerHelper.getSourceFile( FooBarBazDefaultGroupSequenceProvider.class );
boolean compilationResult = compilerHelper.compile(
new ConstraintValidationProcessor(),
diagnostics,
sourceFile1,
sourceFile2,
sourceFile3,
sourceFile4,
sourceFile5,
sourceFile6,
sourceFile7
);
assertFalse( compilationResult );
assertThatDiagnosticsMatch(
diagnostics,
new DiagnosticExpectation( Kind.ERROR, 35 ),
new DiagnosticExpectation( Kind.ERROR, 44 ),
new DiagnosticExpectation( Kind.ERROR, 52 ),
new DiagnosticExpectation( Kind.ERROR, 60 ),
new DiagnosticExpectation( Kind.ERROR, 68 ),
new DiagnosticExpectation( Kind.ERROR, 76 )
);
}
/**
* HV-418: No error shall be raised, when @Past/@Future are given at Joda
* date/time types.
*/
@Test()
public void timeConstraintsAllowedAtJodaTypes() {
File sourceFile1 = compilerHelper.getSourceFile( ModelWithJodaTypes.class );
boolean compilationResult = compilerHelper.compile(
new ConstraintValidationProcessor(), diagnostics, sourceFile1
);
assertFalse( compilationResult );
assertThatDiagnosticsMatch(
diagnostics,
new DiagnosticExpectation( Kind.ERROR, 59 ),
new DiagnosticExpectation( Kind.ERROR, 60 )
);
}
}
ConstraintValidationProcessorTestBase.java 0000664 0000000 0000000 00000003263 12364444513 0046677 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap;
import javax.tools.DiagnosticCollector;
import javax.tools.JavaFileObject;
import javax.tools.ToolProvider;
import org.hibernate.validator.ap.testutil.CompilerTestHelper;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
/**
* Base class providing common functionality for all tests for the constraint validation processor using the Java compiler
* API as defined by JSR 199.
*
* @author Gunnar Morling
*/
public abstract class ConstraintValidationProcessorTestBase {
protected static CompilerTestHelper compilerHelper;
protected DiagnosticCollector diagnostics;
@BeforeClass
public static void setUpCompilerHelper() {
compilerHelper =
new CompilerTestHelper( ToolProvider.getSystemJavaCompiler() );
}
@BeforeMethod
public void setUpDiagnostics() {
diagnostics = new DiagnosticCollector();
}
}
0000775 0000000 0000000 00000000000 12364444513 0040336 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel FieldLevelValidationUsingBuiltInConstraints.java 0000664 0000000 0000000 00000003247 12364444513 0051762 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testmodel;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import javax.validation.constraints.Size;
public class FieldLevelValidationUsingBuiltInConstraints {
@Size(min = 10)
public String string;
@Size(min = 10)
public Collection collection1;
@Size(min = 10)
public Collection> collection2;
@Size(min = 10)
public Collection stringCollection;
/**
* Allowed, as List extends Collection.
*/
@Size(min = 10)
public List list1;
@Size(min = 10)
public List> list2;
@Size(min = 10)
public List stringList;
/**
* Not allowed (unsupported type).
*/
@Size(min = 10)
public Date date;
/**
* Not allowed (static field).
*/
@Size(min = 10)
public static String staticString;
@Size(min = 10)
public Object[] objectArray;
@Size(min = 10)
public Integer[] integerArray;
@Size(min = 10)
public int[] intArray;
}
MethodLevelValidationUsingBuiltInConstraints.java 0000664 0000000 0000000 00000004005 12364444513 0052150 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testmodel;
import java.util.Date;
import javax.validation.constraints.Size;
public class MethodLevelValidationUsingBuiltInConstraints {
@Size(min = 10)
public String getString() {
return null;
}
/**
* Not allowed. Method is no getter.
*/
@Size(min = 10)
public void setString() {
}
/**
* Not allowed. Return type doesn't match.
*/
@Size(min = 10)
public Date getDate() {
return null;
}
/**
* Not allowed. No return type.
*/
@Size(min = 10)
public void getAnotherString() {
}
/**
* Not allowed. Static method.
*/
@Size(min = 10)
public static String getStringStatically() {
return null;
}
/**
* No getter, but allowed with -AmethodConstraintsSupported.
*/
@Size(min = 10)
public String doSomething() {
return null;
}
/**
* Also with -AmethodConstraintsSupported not allowed, as return type doesn't match.
*/
@Size(min = 10)
public Date doSomethingReturningDate() {
return null;
}
/**
* Also with -AmethodConstraintsSupported not allowed. No return type.
*/
@Size(min = 10)
public void voidDoSomething() {
}
/**
* Also with -AmethodConstraintsSupported not allowed. Static method.
*/
@Size(min = 10)
public static String staticDoSomething() {
return null;
}
}
ModelWithJodaTypes.java 0000664 0000000 0000000 00000002766 12364444513 0044733 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel /*
* JBoss, Home of Professional Open Source
* Copyright 2011, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testmodel;
import java.util.Date;
import java.util.GregorianCalendar;
import javax.validation.constraints.Future;
import javax.validation.constraints.Past;
import org.joda.time.DateMidnight;
import org.joda.time.LocalDate;
import org.joda.time.ReadableInstant;
import org.joda.time.ReadablePartial;
public class ModelWithJodaTypes {
@Past
@Future
public Date jdkDate;
@Past
@Future
public GregorianCalendar jdkCalendar;
@Past
@Future
public ReadableInstant jodaInstant;
@Past
@Future
public DateMidnight jodaDateMidnight;
@Past
@Future
public ReadablePartial jodaPartial;
@Past
@Future
public LocalDate jodaLocalDate;
/**
* Not allowed.
*/
@Future
@Past
public String string;
}
MultipleConstraintsOfSameType.java 0000664 0000000 0000000 00000002242 12364444513 0047161 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testmodel;
import java.util.Date;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Pattern.List;
public class MultipleConstraintsOfSameType {
@List(value = { @Pattern(regexp = ""), @Pattern(regexp = "") })
public String string;
/**
* Not allowed.
*/
@List(value = { @Pattern(regexp = ""), @Pattern(regexp = "") })
public Date date;
}
ValidationUsingAtValidAnnotation.java 0000664 0000000 0000000 00000003427 12364444513 0047607 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testmodel;
import java.util.Collection;
import javax.validation.Valid;
public class ValidationUsingAtValidAnnotation {
@Valid
public Integer integer;
@Valid
public Collection> collection1;
/**
* Not allowed (primitive type).
*/
@Valid
public int primitiveInt;
/**
* Not allowed (static field).
*/
@Valid
public static Integer staticInteger;
@Valid
public Integer getInteger() {
return null;
}
@Valid
public Collection> getCollection() {
return null;
}
/**
* Not allowed (primitive type).
*/
@Valid
public int getPrimitiveInt() {
return 0;
}
/**
* Not allowed (static field).
*/
@Valid
public static Integer getStaticInteger() {
return null;
}
/**
* Not allowed (no getter).
*/
@Valid
public Collection> getCollectionWithParams(int i) {
return null;
}
/**
* Not allowed (no getter).
*/
@Valid
public Collection> setCollection() {
return null;
}
/**
* Not allowed (no getter).
*/
@Valid
public void getVoid() {
}
}
0000775 0000000 0000000 00000000000 12364444513 0041624 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/boxing ValidLong.java 0000664 0000000 0000000 00000002760 12364444513 0044353 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/boxing /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testmodel.boxing;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import javax.validation.Constraint;
import javax.validation.Payload;
import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Target({ METHOD, FIELD, ANNOTATION_TYPE })
@Retention(RUNTIME)
@Constraint(validatedBy = ValidLongValidator.class)
@Documented
public @interface ValidLong {
String message() default "";
Class>[] groups() default { };
Class extends Payload>[] payload() default { };
}
ValidLongValidator.java 0000664 0000000 0000000 00000002223 12364444513 0046213 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/boxing /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testmodel.boxing;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
public class ValidLongValidator implements ConstraintValidator {
public void initialize(ValidLong constraintAnnotation) {
}
public boolean isValid(Long object, ConstraintValidatorContext constraintContext) {
return true;
}
}
ValidationUsingBoxing.java 0000664 0000000 0000000 00000002657 12364444513 0046750 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/boxing /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testmodel.boxing;
public class ValidationUsingBoxing {
@ValidLong
public long primitiveLongField;
@ValidLong
public Long longField;
/**
* Not allowed.
*/
@ValidLong
public int intField;
/**
* Not allowed.
*/
@ValidLong
public Integer integerField;
/**
* Not allowed.
*/
@ValidLong
public double doubleField;
@ValidLong
public long getPrimitiveLong() {
return 0;
}
@ValidLong
public Long getLong() {
return Long.MIN_VALUE;
}
/**
* Not allowed.
*/
@ValidLong
public int getInt() {
return 0;
}
/**
* Not allowed.
*/
@ValidLong
public Integer getInteger() {
return Integer.MIN_VALUE;
}
}
0000775 0000000 0000000 00000000000 12364444513 0044763 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/classlevelconstraints ClassLevelValidation.java 0000664 0000000 0000000 00000001754 12364444513 0051705 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/classlevelconstraints /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testmodel.classlevelconstraints;
public class ClassLevelValidation {
@ValidCustomer
public static class Customer {
}
/**
* Not allowed.
*/
@ValidCustomer
public static class Order {
}
}
ValidCustomer.java 0000664 0000000 0000000 00000002565 12364444513 0050417 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/classlevelconstraints /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testmodel.classlevelconstraints;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import javax.validation.Constraint;
import javax.validation.Payload;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Target({ TYPE })
@Retention(RUNTIME)
@Constraint(validatedBy = ValidCustomerValidator.class)
@Documented
public @interface ValidCustomer {
String message() default "";
Class>[] groups() default { };
Class extends Payload>[] payload() default { };
}
ValidCustomerValidator.java 0000664 0000000 0000000 00000002432 12364444513 0052256 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/classlevelconstraints /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testmodel.classlevelconstraints;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import org.hibernate.validator.ap.testmodel.classlevelconstraints.ClassLevelValidation.Customer;
public class ValidCustomerValidator implements ConstraintValidator {
public void initialize(ValidCustomer constraintAnnotation) {
}
public boolean isValid(Customer customer, ConstraintValidatorContext constraintContext) {
return true;
}
}
0000775 0000000 0000000 00000000000 12364444513 0044254 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/composedconstraint FieldLevelValidationUsingComposedConstraint.java 0000664 0000000 0000000 00000002005 12364444513 0055707 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/composedconstraint /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testmodel.composedconstraint;
import java.util.Date;
public class FieldLevelValidationUsingComposedConstraint {
@ValidOrderNumber
public String string;
/**
* Not allowed.
*/
@ValidOrderNumber
public Date date;
}
ValidOrderNumber.java 0000664 0000000 0000000 00000003150 12364444513 0050322 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/composedconstraint /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testmodel.composedconstraint;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import javax.validation.Constraint;
import javax.validation.Payload;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
@NotNull
@Size(min = 10, max = 10)
@Target({ METHOD, FIELD, ANNOTATION_TYPE })
@Retention(RUNTIME)
@Constraint(validatedBy = { })
@Documented
public @interface ValidOrderNumber {
String message() default "";
Class>[] groups() default { };
Class extends Payload>[] payload() default { };
}
0000775 0000000 0000000 00000000000 12364444513 0044336 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/composedconstraint2 ComposedConstraint.java 0000664 0000000 0000000 00000003035 12364444513 0051020 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/composedconstraint2 /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testmodel.composedconstraint2;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import javax.validation.Constraint;
import javax.validation.Payload;
import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
@ComposingConstraint1
@ComposingConstraint2
@Target({ METHOD, FIELD, ANNOTATION_TYPE })
@Retention(RUNTIME)
@Constraint(validatedBy = { })
@Documented
public @interface ComposedConstraint {
String message() default "";
Class>[] groups() default { };
Class extends Payload>[] payload() default { };
}
ComposingConstraint1.java 0000664 0000000 0000000 00000003213 12364444513 0051264 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/composedconstraint2 /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testmodel.composedconstraint2;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import javax.validation.Constraint;
import javax.validation.Payload;
import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Target({ METHOD, FIELD, ANNOTATION_TYPE })
@Retention(RUNTIME)
@Constraint(validatedBy = {
ComposingConstraint1ValidatorForList.class,
ComposingConstraint1ValidatorForString.class,
ComposingConstraint1ValidatorForGregorianCalendar.class
})
@Documented
public @interface ComposingConstraint1 {
String message() default "";
Class>[] groups() default { };
Class extends Payload>[] payload() default { };
}
ComposingConstraint1ValidatorForGregorianCalendar.java 0000664 0000000 0000000 00000002425 12364444513 0057075 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/composedconstraint2 /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testmodel.composedconstraint2;
import java.util.GregorianCalendar;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
public class ComposingConstraint1ValidatorForGregorianCalendar
implements ConstraintValidator {
public void initialize(ComposingConstraint1 constraintAnnotation) {
}
public boolean isValid(GregorianCalendar object, ConstraintValidatorContext constraintContext) {
return true;
}
}
ComposingConstraint1ValidatorForList.java 0000664 0000000 0000000 00000002346 12364444513 0054443 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/composedconstraint2 /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testmodel.composedconstraint2;
import java.util.List;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
public class ComposingConstraint1ValidatorForList implements ConstraintValidator> {
public void initialize(ComposingConstraint1 constraintAnnotation) {
}
public boolean isValid(List> object, ConstraintValidatorContext constraintContext) {
return true;
}
}
ComposingConstraint1ValidatorForString.java 0000664 0000000 0000000 00000002332 12364444513 0054771 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/composedconstraint2 /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testmodel.composedconstraint2;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
public class ComposingConstraint1ValidatorForString implements
ConstraintValidator {
public void initialize(ComposingConstraint1 constraintAnnotation) {
}
public boolean isValid(String object,
ConstraintValidatorContext constraintContext) {
return true;
}
}
ComposingConstraint2.java 0000664 0000000 0000000 00000003213 12364444513 0051265 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/composedconstraint2 /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testmodel.composedconstraint2;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import javax.validation.Constraint;
import javax.validation.Payload;
import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Target({ METHOD, FIELD, ANNOTATION_TYPE })
@Retention(RUNTIME)
@Constraint(validatedBy = {
ComposingConstraint2ValidatorForArrayList.class,
ComposingConstraint2ValidatorForCalendar.class,
ComposingConstraint2ValidatorForCollection.class
})
@Documented
public @interface ComposingConstraint2 {
String message() default "";
Class>[] groups() default { };
Class extends Payload>[] payload() default { };
}
ComposingConstraint2ValidatorForArrayList.java 0000664 0000000 0000000 00000002374 12364444513 0055444 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/composedconstraint2 /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testmodel.composedconstraint2;
import java.util.ArrayList;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
public class ComposingConstraint2ValidatorForArrayList
implements ConstraintValidator> {
public void initialize(ComposingConstraint2 constraintAnnotation) {
}
public boolean isValid(ArrayList> object, ConstraintValidatorContext constraintContext) {
return true;
}
}
ComposingConstraint2ValidatorForCalendar.java 0000664 0000000 0000000 00000002371 12364444513 0055240 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/composedconstraint2 /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testmodel.composedconstraint2;
import java.util.Calendar;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
public class ComposingConstraint2ValidatorForCalendar implements
ConstraintValidator {
public void initialize(ComposingConstraint2 constraintAnnotation) {
}
public boolean isValid(Calendar object,
ConstraintValidatorContext constraintContext) {
return true;
}
}
ComposingConstraint2ValidatorForCollection.java 0000664 0000000 0000000 00000002377 12364444513 0055630 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/composedconstraint2 /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testmodel.composedconstraint2;
import java.util.Collection;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
public class ComposingConstraint2ValidatorForCollection
implements ConstraintValidator> {
public void initialize(ComposingConstraint2 constraintAnnotation) {
}
public boolean isValid(Collection> object, ConstraintValidatorContext constraintContext) {
return true;
}
}
FieldLevelValidationUsingComplexComposedConstraint.java 0000664 0000000 0000000 00000002743 12364444513 0057332 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/composedconstraint2 /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testmodel.composedconstraint2;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
public class FieldLevelValidationUsingComplexComposedConstraint {
@ComposedConstraint
public String string;
@ComposedConstraint
public List> list;
/**
* Allowed
*/
@ComposedConstraint
public GregorianCalendar gregorianCalendar;
@ComposedConstraint
public Collection> collection;
/**
* Allowed
*/
@ComposedConstraint
public ArrayList> arrayList;
@ComposedConstraint
public Calendar calendar;
/**
* Not allowed.
*/
@ComposedConstraint
public Date date;
}
0000775 0000000 0000000 00000000000 12364444513 0043607 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/constrainttypes ConstraintsWithIllegalRetentionPolicies.java 0000664 0000000 0000000 00000004055 12364444513 0054473 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/constrainttypes /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testmodel.constrainttypes;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import javax.validation.Constraint;
import javax.validation.Payload;
/**
* @author Gunnar Morling
*/
public interface ConstraintsWithIllegalRetentionPolicies {
/**
* Compilation error expected as wrong retention policy is given.
*/
@Constraint(validatedBy = { DummyValidator.class })
@Retention(RetentionPolicy.CLASS)
public @interface ConstraintWithWrongRetentionPolicy {
String message() default "";
Class>[] groups() default { };
Class extends Payload>[] payload() default { };
}
/**
* Compilation error expected as no retention policy is given.
*/
@Constraint(validatedBy = { DummyValidator.class })
public @interface ConstraintWithoutRetentionPolicy {
String message() default "";
Class>[] groups() default { };
Class extends Payload>[] payload() default { };
}
/**
* No compilation error expected as correct retention policy is given.
*/
@Constraint(validatedBy = { DummyValidator.class })
@Retention(RetentionPolicy.RUNTIME)
public @interface ConstraintWithCorrectRetentionPolicy {
String message() default "";
Class>[] groups() default { };
Class extends Payload>[] payload() default { };
}
}
ConstraintsWithIllegalTargets.java 0000664 0000000 0000000 00000007723 12364444513 0052452 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/constrainttypes /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testmodel.constrainttypes;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import javax.validation.Constraint;
import javax.validation.Payload;
import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.LOCAL_VARIABLE;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
/**
* @author Gunnar Morling
*/
public interface ConstraintsWithIllegalTargets {
/**
* Compilation error expected due to none supported target type being given.
*/
@Constraint(validatedBy = { DummyValidator.class })
@Retention(RetentionPolicy.RUNTIME)
@Target({ LOCAL_VARIABLE })
public @interface ConstraintWithWrongTarget {
String message() default "";
Class>[] groups() default { };
Class extends Payload>[] payload() default { };
}
/**
* Compilation error expected as no supported target type is given.
*/
@Constraint(validatedBy = { DummyValidator.class })
@Retention(RetentionPolicy.RUNTIME)
@Target({ })
public @interface ConstraintWithEmptyTarget {
String message() default "";
Class>[] groups() default { };
Class extends Payload>[] payload() default { };
}
/**
* No compilation error expected, as not specifying @Target allows this constraint for all element types.
*/
@Constraint(validatedBy = { DummyValidator.class })
@Retention(RetentionPolicy.RUNTIME)
public @interface ConstraintWithDefaultTarget {
String message() default "";
Class>[] groups() default { };
Class extends Payload>[] payload() default { };
}
/**
* No compilation error expected, as supported target type FIELD is given.
*/
@Constraint(validatedBy = { DummyValidator.class })
@Retention(RetentionPolicy.RUNTIME)
@Target({ FIELD })
public @interface ConstraintWithAllowedTargetField {
String message() default "";
Class>[] groups() default { };
Class extends Payload>[] payload() default { };
}
/**
* No compilation error expected, as supported target type METHOD is given.
*/
@Constraint(validatedBy = { DummyValidator.class })
@Retention(RetentionPolicy.RUNTIME)
@Target({ METHOD })
public @interface ConstraintWithAllowedTargetMethod {
String message() default "";
Class>[] groups() default { };
Class extends Payload>[] payload() default { };
}
/**
* No compilation error expected, as supported target type TYPE is given.
*/
@Constraint(validatedBy = { DummyValidator.class })
@Retention(RetentionPolicy.RUNTIME)
@Target({ TYPE })
public @interface ConstraintWithAllowedTargetType {
String message() default "";
Class>[] groups() default { };
Class extends Payload>[] payload() default { };
}
/**
* No compilation error expected, as supported target type ANNOTATION_TYPE is given.
*/
@Constraint(validatedBy = { DummyValidator.class })
@Retention(RetentionPolicy.RUNTIME)
@Target({ ANNOTATION_TYPE })
public @interface ConstraintWithAllowedTargetAnnotationType {
String message() default "";
Class>[] groups() default { };
Class extends Payload>[] payload() default { };
}
}
ConstraintsWithWrongGroupsAttribute.java 0000664 0000000 0000000 00000007540 12364444513 0053724 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/constrainttypes /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testmodel.constrainttypes;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import javax.validation.Constraint;
import javax.validation.Payload;
/**
* @author Gunnar Morling
*/
public interface ConstraintsWithWrongGroupsAttribute {
/**
* Compilation error expected due to missing groups attribute.
*/
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = { DummyValidator.class })
public @interface ConstraintWithoutGroupsParameter {
String message() default "";
Class extends Payload>[] payload() default { };
}
/**
* Compilation error expected due to groups attribute of wrong type.
*/
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = { DummyValidator.class })
public @interface ConstraintWithGroupsParameterWithWrongType1 {
String message() default "";
int[] groups() default { };
Class extends Payload>[] payload() default { };
}
/**
* Compilation error expected due to groups attribute of non-array class type.
*/
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = { DummyValidator.class })
public @interface ConstraintWithGroupsParameterWithWrongType2 {
String message() default "";
Class> groups();
Class extends Payload>[] payload() default { };
}
/**
* Compilation error expected due to groups attribute with super bound.
*/
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = { DummyValidator.class })
public @interface ConstraintWithGroupsParameterWithSuperBound {
String message() default "";
Class super Long>[] groups() default { };
Class extends Payload>[] payload() default { };
}
/**
* Compilation error expected due to groups attribute with extends bound.
*/
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = { DummyValidator.class })
public @interface ConstraintWithGroupsParameterWithExtendsBound {
String message() default "";
Class extends Long>[] groups() default { };
Class extends Payload>[] payload() default { };
}
/**
* Compilation error expected due missing default value for groups attribute.
*/
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = { DummyValidator.class })
public @interface ConstraintWithGroupsParameterWithoutDefaultValue {
String message() default "";
Class>[] groups();
Class extends Payload>[] payload() default { };
}
/**
* Compilation error expected due to non-empty default value for groups attribute.
*/
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = { DummyValidator.class })
public @interface ConstraintWithGroupsParameterWithNonEmptyDefaultValue {
String message() default "";
Class>[] groups() default { Object.class };
Class extends Payload>[] payload() default { };
}
/**
* No compilation error expected.
*/
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = { DummyValidator.class })
public @interface ConstraintWithCorrectGroupsParameter {
String message() default "";
Class>[] groups() default { };
Class extends Payload>[] payload() default { };
}
}
ConstraintsWithWrongMessageAttribute.java 0000664 0000000 0000000 00000004055 12364444513 0054027 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/constrainttypes /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testmodel.constrainttypes;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import javax.validation.Constraint;
import javax.validation.Payload;
/**
* @author Gunnar Morling
*/
public interface ConstraintsWithWrongMessageAttribute {
/**
* Compilation error expected as no message() attribute is specified.
*/
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = { DummyValidator.class })
public @interface ConstraintWithoutMessageAttribute {
Class>[] groups() default { };
Class extends Payload>[] payload() default { };
}
/**
* Compilation error expected as message() attribute doesn't have String as return type.
*/
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = { DummyValidator.class })
public @interface ConstraintWithMessageAttributeWithWrongReturnType {
public int message();
Class>[] groups() default { };
Class extends Payload>[] payload() default { };
}
/**
* No compilation error expected.
*/
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = { DummyValidator.class })
public @interface ConstraintWithMessageAttribute {
String message() default "";
Class>[] groups() default { };
Class extends Payload>[] payload() default { };
}
}
ConstraintsWithWrongPayloadAttribute.java 0000664 0000000 0000000 00000010346 12364444513 0054034 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/constrainttypes /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testmodel.constrainttypes;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import javax.validation.Constraint;
import javax.validation.Payload;
/**
* @author Gunnar Morling
*/
public interface ConstraintsWithWrongPayloadAttribute {
/**
* Compilation error expected due to missing payload attribute.
*/
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = { DummyValidator.class })
public @interface ConstraintWithoutPayloadParameter {
String message() default "";
Class>[] groups() default { };
}
/**
* Compilation error expected due to payload attribute of wrong type.
*/
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = { DummyValidator.class })
public @interface ConstraintWithPayloadParameterWithWrongType1 {
String message() default "";
Class>[] groups() default { };
int[] payload() default { };
}
/**
* Compilation error expected due to payload attribute of non-array class type.
*/
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = { DummyValidator.class })
public @interface ConstraintWithPayloadParameterWithWrongType2 {
String message() default "";
Class>[] groups() default { };
Class extends Payload> payload();
}
/**
* Compilation error expected due to payload attribute with wrong extends bound.
*/
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = { DummyValidator.class })
public @interface ConstraintWithPayloadParameterWithWrongExtendsBound {
String message() default "";
Class>[] groups() default { };
Class extends Long>[] payload() default { };
}
/**
* Compilation error expected due to payload attribute without extend bound.
*/
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = { DummyValidator.class })
public @interface ConstraintWithPayloadParameterWithoutExtendsBound {
String message() default "";
Class>[] groups() default { };
Class>[] payload() default { };
}
/**
* Compilation error expected due to payload attribute with super bound.
*/
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = { DummyValidator.class })
public @interface ConstraintWithPayloadParameterWithSuperBound {
String message() default "";
Class>[] groups() default { };
Class super Payload>[] payload() default { };
}
/**
* Compilation error expected due missing default value for payload attribute.
*/
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = { DummyValidator.class })
public @interface ConstraintWithPayloadParameterWithoutDefaultValue {
String message() default "";
Class>[] groups() default { };
Class extends Payload>[] payload();
}
/**
* Compilation error expected due to non-empty default value for payload attribute.
*/
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = { DummyValidator.class })
public @interface ConstraintWithPayloadParameterWithNonEmptyDefaultValue {
String message() default "";
Class>[] groups() default { };
Class extends Payload>[] payload() default { SamplePayload.class };
}
/**
* No compilation error expected.
*/
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = { DummyValidator.class })
public @interface ConstraintWithCorrectPayloadParameter {
String message() default "";
Class>[] groups() default { };
Class extends Payload>[] payload() default { };
}
public static class SamplePayload implements Payload {
}
}
ConstraintsWithoutValidator.java 0000664 0000000 0000000 00000004040 12364444513 0052211 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/constrainttypes /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testmodel.constrainttypes;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import javax.validation.Constraint;
import javax.validation.Payload;
import javax.validation.constraints.Size;
/**
* @author Gunnar Morling
*/
public interface ConstraintsWithoutValidator {
/**
* Compilation error expected as no validator is given.
*/
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = { })
public @interface ConstraintWithoutValidator {
String message() default "";
Class>[] groups() default { };
Class extends Payload>[] payload() default { };
}
/**
* No compilation error expected as a validator is given.
*/
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = { DummyValidator.class })
public @interface ConstraintWithValidator {
String message() default "";
Class>[] groups() default { };
Class extends Payload>[] payload() default { };
}
/**
* No compilation error as this is a composed constraint.
*/
@Size
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = { })
public @interface ComposedConstraintWithoutValidator {
String message() default "";
Class>[] groups() default { };
Class extends Payload>[] payload() default { };
}
}
DummyValidator.java 0000664 0000000 0000000 00000002520 12364444513 0047412 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/constrainttypes /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testmodel.constrainttypes;
import java.lang.annotation.Annotation;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
/**
* @author Gunnar Morling
*/
public class DummyValidator implements ConstraintValidator {
public void initialize(Annotation constraintAnnotation) {
throw new UnsupportedOperationException( "Not implemented" );
}
public boolean isValid(Object value, ConstraintValidatorContext context) {
throw new UnsupportedOperationException( "Not implemented" );
}
}
ValidCustomerNumber.java 0000664 0000000 0000000 00000002371 12364444513 0050407 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/constrainttypes /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testmodel.constrainttypes;
import javax.validation.Payload;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
/**
* Constraint annotations are not allowed here, as ValidCustomerNumber isn't a
* proper constraint type definition.
*/
@NotNull
@Size(min = 10, max = 10)
public @interface ValidCustomerNumber {
String message() default "";
Class>[] groups() default { };
Class extends Payload>[] payload() default { };
}
0000775 0000000 0000000 00000000000 12364444513 0044140 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/customconstraints CaseMode.java 0000664 0000000 0000000 00000001554 12364444513 0046470 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/customconstraints /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testmodel.customconstraints;
public enum CaseMode {
UPPER,
LOWER;
}
CheckCase.java 0000664 0000000 0000000 00000003017 12364444513 0046615 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/customconstraints /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testmodel.customconstraints;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import javax.validation.Constraint;
import javax.validation.Payload;
import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Target({ METHOD, FIELD, ANNOTATION_TYPE })
@Retention(RUNTIME)
@Constraint(validatedBy = CheckCaseValidator.class)
@Documented
public @interface CheckCase {
String message() default "";
Class>[] groups() default { };
Class extends Payload>[] payload() default { };
CaseMode value();
}
CheckCaseValidator.java 0000664 0000000 0000000 00000002650 12364444513 0050465 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/customconstraints /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testmodel.customconstraints;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
public class CheckCaseValidator implements ConstraintValidator {
private CaseMode caseMode;
public void initialize(CheckCase constraintAnnotation) {
this.caseMode = constraintAnnotation.value();
}
public boolean isValid(String object, ConstraintValidatorContext constraintContext) {
if ( object == null ) {
return true;
}
if ( caseMode == CaseMode.UPPER ) {
return object.equals( object.toUpperCase() );
}
else {
return object.equals( object.toLowerCase() );
}
}
}
FieldLevelValidationUsingCustomConstraints.java 0000664 0000000 0000000 00000002030 12364444513 0055455 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/customconstraints /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testmodel.customconstraints;
import java.util.Date;
public class FieldLevelValidationUsingCustomConstraints {
@CheckCase(CaseMode.UPPER)
public String string;
/**
* Not allowed.
*/
@CheckCase(CaseMode.UPPER)
public Date date;
}
0000775 0000000 0000000 00000000000 12364444513 0044776 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/groupsequenceprovider BazDefaultGroupSequenceProvider.java 0000664 0000000 0000000 00000002451 12364444513 0054105 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/groupsequenceprovider /*
* JBoss, Home of Professional Open Source
* Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testmodel.groupsequenceprovider;
import java.util.List;
import org.hibernate.validator.group.DefaultGroupSequenceProvider;
import static org.hibernate.validator.ap.testmodel.groupsequenceprovider.GroupSequenceProviderDefinition.Baz;
/**
* @author Kevin Pollet - SERLI - (kevin.pollet@serli.com)
*/
public interface BazDefaultGroupSequenceProvider extends DefaultGroupSequenceProvider {
public List> getValidationGroups(GroupSequenceProviderDefinition.Baz object);
}
FooBarBazDefaultGroupSequenceProvider.java 0000664 0000000 0000000 00000002574 12364444513 0055204 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/groupsequenceprovider /*
* JBoss, Home of Professional Open Source
* Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testmodel.groupsequenceprovider;
import java.util.List;
import org.hibernate.validator.group.DefaultGroupSequenceProvider;
import static org.hibernate.validator.ap.testmodel.groupsequenceprovider.GroupSequenceProviderDefinition.FooBarBaz;
/**
* @author Kevin Pollet - SERLI - (kevin.pollet@serli.com)
*/
public class FooBarBazDefaultGroupSequenceProvider implements DefaultGroupSequenceProvider {
public FooBarBazDefaultGroupSequenceProvider(FooBarBaz fooBarBaz) {
}
public List> getValidationGroups(FooBarBaz object) {
return null;
}
}
FooBarDefaultGroupSequenceProvider.java 0000664 0000000 0000000 00000002446 12364444513 0054545 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/groupsequenceprovider /*
* JBoss, Home of Professional Open Source
* Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testmodel.groupsequenceprovider;
import java.util.List;
import org.hibernate.validator.group.DefaultGroupSequenceProvider;
import static org.hibernate.validator.ap.testmodel.groupsequenceprovider.GroupSequenceProviderDefinition.FooBar;
/**
* @author Kevin Pollet - SERLI - (kevin.pollet@serli.com)
*/
public abstract class FooBarDefaultGroupSequenceProvider implements DefaultGroupSequenceProvider {
public abstract List> getValidationGroups(FooBar object);
}
FooDefaultGroupSequenceProvider.java 0000664 0000000 0000000 00000002433 12364444513 0054114 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/groupsequenceprovider /*
* JBoss, Home of Professional Open Source
* Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testmodel.groupsequenceprovider;
import java.util.List;
import org.hibernate.validator.group.DefaultGroupSequenceProvider;
import static org.hibernate.validator.ap.testmodel.groupsequenceprovider.GroupSequenceProviderDefinition.Foo;
/**
* @author Kevin Pollet - SERLI - (kevin.pollet@serli.com)
*/
public class FooDefaultGroupSequenceProvider implements DefaultGroupSequenceProvider {
public List> getValidationGroups(Foo object) {
return null;
}
}
GroupSequenceProviderDefinition.java 0000664 0000000 0000000 00000004360 12364444513 0054155 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/groupsequenceprovider /*
* JBoss, Home of Professional Open Source
* Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testmodel.groupsequenceprovider;
import javax.validation.GroupSequence;
import org.hibernate.validator.group.GroupSequenceProvider;
/**
* @author Kevin Pollet - SERLI - (kevin.pollet@serli.com)
*/
public class GroupSequenceProviderDefinition {
@GroupSequenceProvider(FooDefaultGroupSequenceProvider.class)
public static class Foo {
}
/**
* Not allowed
*/
@GroupSequenceProvider(SampleDefaultGroupSequenceProvider.class)
@GroupSequence( { Sample.class })
public static class Sample {
}
/**
* Not allowed. Default group sequence provider class defines
* a wrong generic type.
*/
@GroupSequenceProvider(FooDefaultGroupSequenceProvider.class)
public static class Bar {
}
/**
* Not allowed. Default group sequence provider class is an
* interface.
*/
@GroupSequenceProvider(BazDefaultGroupSequenceProvider.class)
public static class Baz {
}
/**
* Not allowed. GroupSequenceProvider annotation is added on
* on an interface.
*/
@GroupSequenceProvider(QuxDefaultGroupSequenceProvider.class)
public interface Qux {
}
/**
* Not allowed. Default group sequence provider class is
* abstract.
*/
@GroupSequenceProvider(FooBarDefaultGroupSequenceProvider.class)
public static class FooBar {
}
/**
* Not allowed. Default group sequence provider class has
* no public default constructor.
*/
@GroupSequenceProvider(FooBarBazDefaultGroupSequenceProvider.class)
public static class FooBarBaz {
}
}
QuxDefaultGroupSequenceProvider.java 0000664 0000000 0000000 00000002433 12364444513 0054146 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/groupsequenceprovider /*
* JBoss, Home of Professional Open Source
* Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testmodel.groupsequenceprovider;
import java.util.List;
import org.hibernate.validator.group.DefaultGroupSequenceProvider;
import static org.hibernate.validator.ap.testmodel.groupsequenceprovider.GroupSequenceProviderDefinition.Qux;
/**
* @author Kevin Pollet - SERLI - (kevin.pollet@serli.com)
*/
public class QuxDefaultGroupSequenceProvider implements DefaultGroupSequenceProvider {
public List> getValidationGroups(Qux object) {
return null;
}
}
SampleDefaultGroupSequenceProvider.java 0000664 0000000 0000000 00000002447 12364444513 0054617 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/groupsequenceprovider /*
* JBoss, Home of Professional Open Source
* Copyright 2011, Red Hat, Inc. and/or its affiliates, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testmodel.groupsequenceprovider;
import java.util.List;
import org.hibernate.validator.group.DefaultGroupSequenceProvider;
import static org.hibernate.validator.ap.testmodel.groupsequenceprovider.GroupSequenceProviderDefinition.Sample;
/**
* @author Kevin Pollet - SERLI - (kevin.pollet@serli.com)
*/
public class SampleDefaultGroupSequenceProvider implements DefaultGroupSequenceProvider {
public List> getValidationGroups(Sample object) {
return null;
}
}
0000775 0000000 0000000 00000000000 12364444513 0044217 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/inheritedvalidator AbstractCustomConstraintValidator.java 0000664 0000000 0000000 00000001750 12364444513 0053736 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/inheritedvalidator /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testmodel.inheritedvalidator;
import javax.validation.ConstraintValidator;
public abstract class AbstractCustomConstraintValidator implements ConstraintValidator {
}
CustomConstraint.java 0000664 0000000 0000000 00000003014 12364444513 0050377 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/inheritedvalidator /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testmodel.inheritedvalidator;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import javax.validation.Constraint;
import javax.validation.Payload;
import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Target({ METHOD, FIELD, ANNOTATION_TYPE })
@Retention(RUNTIME)
@Constraint(validatedBy = CustomConstraintValidator.class)
@Documented
public @interface CustomConstraint {
String message() default "";
Class>[] groups() default { };
Class extends Payload>[] payload() default { };
}
CustomConstraintValidator.java 0000664 0000000 0000000 00000002175 12364444513 0052254 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/inheritedvalidator /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testmodel.inheritedvalidator;
import javax.validation.ConstraintValidatorContext;
public class CustomConstraintValidator extends AbstractCustomConstraintValidator {
public void initialize(CustomConstraint constraintAnnotation) {
}
public boolean isValid(String object, ConstraintValidatorContext constraintContext) {
return true;
}
}
FieldLevelValidationUsingInheritedValidator.java 0000664 0000000 0000000 00000002007 12364444513 0055617 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/inheritedvalidator /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testmodel.inheritedvalidator;
import java.util.Date;
public class FieldLevelValidationUsingInheritedValidator {
@CustomConstraint
public String string;
/**
* Not allowed.
*/
@CustomConstraint
public Date date;
}
0000775 0000000 0000000 00000000000 12364444513 0046233 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/nouniquevalidatorresolution NoUniqueValidatorResolution.java 0000664 0000000 0000000 00000002173 12364444513 0054576 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/nouniquevalidatorresolution /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testmodel.nouniquevalidatorresolution;
import java.util.Set;
public class NoUniqueValidatorResolution {
/**
* Allowed, as there is one maximally specific validator.
*/
@Size
public Set> set;
/**
* Not allowed, as two maximally specific validators exist.
*/
@Size
public SerializableCollection> serializableCollection;
}
SerializableCollection.java 0000664 0000000 0000000 00000001753 12364444513 0053526 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/nouniquevalidatorresolution /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testmodel.nouniquevalidatorresolution;
import java.io.Serializable;
import java.util.Collection;
public interface SerializableCollection extends Serializable, Collection {
}
Size.java 0000664 0000000 0000000 00000003115 12364444513 0050010 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/nouniquevalidatorresolution /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testmodel.nouniquevalidatorresolution;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import javax.validation.Constraint;
import javax.validation.Payload;
import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Target({ METHOD, FIELD, ANNOTATION_TYPE })
@Retention(RUNTIME)
@Constraint(validatedBy = {
SizeValidatorForCollection.class, SizeValidatorForSerializable.class, SizeValidatorForSet.class
})
@Documented
public @interface Size {
String message() default "";
Class>[] groups() default { };
Class extends Payload>[] payload() default { };
}
SizeValidatorForCollection.java 0000664 0000000 0000000 00000002320 12364444513 0054336 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/nouniquevalidatorresolution /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testmodel.nouniquevalidatorresolution;
import java.util.Collection;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
public class SizeValidatorForCollection implements ConstraintValidator {
public void initialize(Size constraintAnnotation) {
}
public boolean isValid(Collection object, ConstraintValidatorContext constraintContext) {
return true;
}
}
SizeValidatorForSerializable.java 0000664 0000000 0000000 00000002326 12364444513 0054657 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/nouniquevalidatorresolution /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testmodel.nouniquevalidatorresolution;
import java.io.Serializable;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
public class SizeValidatorForSerializable implements ConstraintValidator {
public void initialize(Size constraintAnnotation) {
}
public boolean isValid(Serializable object, ConstraintValidatorContext constraintContext) {
return true;
}
}
SizeValidatorForSet.java 0000664 0000000 0000000 00000002264 12364444513 0053005 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testmodel/nouniquevalidatorresolution /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testmodel.nouniquevalidatorresolution;
import java.util.Set;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
public class SizeValidatorForSet implements ConstraintValidator {
public void initialize(Size constraintAnnotation) {
}
public boolean isValid(Set object, ConstraintValidatorContext constraintContext) {
return true;
}
}
0000775 0000000 0000000 00000000000 12364444513 0040213 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testutil CompilerTestHelper.java 0000664 0000000 0000000 00000015065 12364444513 0044637 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/testutil /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.testutil;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.annotation.processing.Processor;
import javax.tools.Diagnostic;
import javax.tools.Diagnostic.Kind;
import javax.tools.DiagnosticCollector;
import javax.tools.JavaCompiler;
import javax.tools.JavaCompiler.CompilationTask;
import javax.tools.JavaFileObject;
import javax.tools.StandardJavaFileManager;
import org.hibernate.validator.ap.util.Configuration;
import org.hibernate.validator.ap.util.DiagnosticExpectation;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
/**
* Infrastructure for unit tests based on the Java Compiler API.
*
* @author Gunnar Morling
*/
public class CompilerTestHelper {
private final JavaCompiler compiler;
private final String sourceBaseDir;
public CompilerTestHelper(JavaCompiler compiler) {
this.compiler = compiler;
String basePath;
try {
basePath = new File( "." ).getCanonicalPath();
}
catch ( IOException e ) {
throw new RuntimeException( e );
}
this.sourceBaseDir = basePath + "/src/test/java";
}
/**
* Retrieves a file object containing the source of the given class.
*
* @param clazz The class of interest.
*
* @return A file with the source of the given class.
*/
public File getSourceFile(Class> clazz) {
String sourceFileName =
File.separator + clazz.getName().replace( ".", File.separator ) + ".java";
return new File( sourceBaseDir + sourceFileName );
}
/**
* @see CompilerTestHelper#compile(Processor, DiagnosticCollector, Kind, Boolean, Boolean, File...)
*/
public boolean compile(
Processor annotationProcessor, DiagnosticCollector diagnostics, File... sourceFiles) {
return compile( annotationProcessor, diagnostics, null, null, null, sourceFiles );
}
/**
* @see CompilerTestHelper#compile(Processor, DiagnosticCollector, Kind, Boolean, Boolean, File...)
*/
public boolean compile(
Processor annotationProcessor, DiagnosticCollector diagnostics, Kind diagnosticKind, File... sourceFiles) {
return compile( annotationProcessor, diagnostics, diagnosticKind, null, null, sourceFiles );
}
/**
* @see CompilerTestHelper#compile(Processor, DiagnosticCollector, Kind, Boolean, Boolean, File...)
*/
public boolean compile(
Processor annotationProcessor, DiagnosticCollector diagnostics, boolean verbose, boolean allowMethodConstraints, File... sourceFiles) {
return compile( annotationProcessor, diagnostics, null, verbose, allowMethodConstraints, sourceFiles );
}
/**
* Creates and executes a {@link CompilationTask} using the given input.
*
* @param annotationProcessor An annotation processor to be attached to the task.
* @param diagnostics An diagnostics listener to be attached to the task.
* @param diagnosticKind A value for the "diagnosticKind" option.
* @param verbose A value for the "verbose" option.
* @param sourceFiles The source files to be compiled.
*
* @return True, if the source files could be compiled successfully (meaning
* in especially, that the given annotation processor didn't raise
* any errors), false otherwise.
*/
public boolean compile(
Processor annotationProcessor, DiagnosticCollector diagnostics, Kind diagnosticKind, Boolean verbose, Boolean allowMethodConstraints, File... sourceFiles) {
StandardJavaFileManager fileManager =
compiler.getStandardFileManager( null, null, null );
Iterable extends JavaFileObject> compilationUnits = fileManager.getJavaFileObjects( sourceFiles );
List options = new ArrayList();
options.addAll( Arrays.asList( "-classpath", System.getProperty( "java.class.path" ), "-d", "target" ) );
if ( diagnosticKind != null ) {
options.add( String.format( "-A%s=%s", Configuration.DIAGNOSTIC_KIND_PROCESSOR_OPTION, diagnosticKind ) );
}
if ( verbose != null ) {
options.add( String.format( "-A%s=%b", Configuration.VERBOSE_PROCESSOR_OPTION, verbose ) );
}
if ( allowMethodConstraints != null ) {
options.add(
String.format(
"-A%s=%b",
Configuration.METHOD_CONSTRAINTS_SUPPORTED_PROCESSOR_OPTION,
allowMethodConstraints
)
);
}
CompilationTask task = compiler.getTask( null, fileManager, diagnostics, options, null, compilationUnits );
task.setProcessors( Arrays.asList( annotationProcessor ) );
return task.call();
}
/**
*
* Asserts, that the given diagnostics match with the given expectations.
*
*
* First checks, whether the number of actual diagnostics matches with the
* number of given expectations. If that's the case, {@link Kind} and line
* number of each expectation are compared.
*
*
* @param diagnostics The actual diagnostics as populated by the executed
* {@link CompilationTask}.
* @param expectations The expectations to compare against.
*/
public static void assertThatDiagnosticsMatch(DiagnosticCollector diagnostics, DiagnosticExpectation... expectations) {
List> diagnosticsList = diagnostics.getDiagnostics();
if ( expectations == null ) {
assertTrue( diagnosticsList.isEmpty() );
}
else {
if ( diagnosticsList.size() != expectations.length ) {
for ( Diagnostic extends JavaFileObject> oneDiagnostic : diagnosticsList ) {
System.out.println( oneDiagnostic );
}
}
assertEquals( diagnosticsList.size(), expectations.length, "Wrong number of diagnostics." );
int i = 0;
for ( DiagnosticExpectation oneExpectation : expectations ) {
assertEquals( diagnosticsList.get( i ).getKind(), oneExpectation.getKind() );
assertEquals( diagnosticsList.get( i ).getLineNumber(), oneExpectation.getLineNumber() );
i++;
}
}
}
}
0000775 0000000 0000000 00000000000 12364444513 0037313 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/util DiagnosticExpectation.java 0000664 0000000 0000000 00000002627 12364444513 0044455 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-annotation-processor/src/test/java/org/hibernate/validator/ap/util /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hibernate.validator.ap.util;
import javax.tools.Diagnostic;
import javax.tools.Diagnostic.Kind;
/**
* Expectation value to be matched against a given {@link Diagnostic}.
*
* @author Gunnar Morling
*/
public class DiagnosticExpectation {
private final Kind kind;
private final long lineNumber;
public DiagnosticExpectation(Kind kind, long lineNumber) {
this.kind = kind;
this.lineNumber = lineNumber;
}
public Kind getKind() {
return kind;
}
public long getLineNumber() {
return lineNumber;
}
@Override
public String toString() {
return "DiagnosticExpectation [kind=" + kind + ", lineNumber=" + lineNumber + "]";
}
}
hibernate-validator-4.2.1.Final/hibernate-validator-archetype/ 0000775 0000000 0000000 00000000000 12364444513 0024406 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-archetype/archetype.properties 0000664 0000000 0000000 00000000232 12364444513 0030505 0 ustar 00root root 0000000 0000000 archetype.groupId=org.hibernate
archetype.artifactId=hibernate-validator-quickstart-archetype
archetype.filteredExtensions=java
archetype.languages=java
hibernate-validator-4.2.1.Final/hibernate-validator-archetype/pom.xml 0000664 0000000 0000000 00000007574 12364444513 0025740 0 ustar 00root root 0000000 0000000
4.0.0hibernate-validator-parentorg.hibernate4.2.1.Final../pom.xmlcom.examplehibernate-validator-quickstartjarHibernate Validator Quickstartorg.hibernatehibernate-validator${project.parent.version}org.slf4jslf4j-log4j12runtimejunitjunit4.8.2testjavax.xml.bindjaxb-apiprovidedcom.sun.xml.bindjaxb-implprovidedtestmaven-compiler-plugin1.51.5maven-deploy-plugintruearchetypearchetype.propertiesorg.apache.maven.pluginsmaven-archetype-pluginjboss-public-repositoryhttps://repository.jboss.org/nexus/content/repositories/public
hibernate-validator-4.2.1.Final/hibernate-validator-archetype/src/ 0000775 0000000 0000000 00000000000 12364444513 0025175 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-archetype/src/main/ 0000775 0000000 0000000 00000000000 12364444513 0026121 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-archetype/src/main/java/ 0000775 0000000 0000000 00000000000 12364444513 0027042 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-archetype/src/main/java/com/ 0000775 0000000 0000000 00000000000 12364444513 0027620 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-archetype/src/main/java/com/example/ 0000775 0000000 0000000 00000000000 12364444513 0031253 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-archetype/src/main/java/com/example/Car.java 0000664 0000000 0000000 00000006367 12364444513 0032637 0 ustar 00root root 0000000 0000000 /**
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example;
import javax.validation.Valid;
import javax.validation.constraints.AssertTrue;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
/**
* An example entity class enriched with constraint annotations from
* the Bean Validation API (JSR
* 303). Have a look at {@link org.hibernate.validator.quickstart.CarTest} to learn, how the Bean Validation
* API can be used to validate {@code Car} instances.
*
* @author Gunnar Morling
* @author Hardy Ferentschik
* @author Kevin Pollet - SERLI - (kevin.pollet@serli.com)
*/
public class Car {
//The definition of the message in the constraints is just for testing purpose.
//In a real world scenario you would place your messages into resource bundles.
/**
* By annotating the field with @NotNull we specify, that null is not a valid
* value.
*/
@NotNull(message = "may not be null")
private String manufacturer;
/**
* This String field shall not only not allowed to be null, it shall also between
* 2 and 14 characters long.
*/
@NotNull
@Size(min = 2, max = 14, message = "size must be between {min} and {max}")
private String licensePlate;
/**
* This int field shall have a value of at least 2.
*/
@Min(value = 2, message = "must be greater than or equal to {value}")
private int seatCount;
@AssertTrue(message = "The car has to pass the vehicle inspection first", groups = CarChecks.class)
private boolean passedVehicleInspection;
@Valid
private Driver driver;
public Car(String manufacturer, String licencePlate, int seatCount) {
this.manufacturer = manufacturer;
this.licensePlate = licencePlate;
this.seatCount = seatCount;
}
public String getManufacturer() {
return manufacturer;
}
public void setManufacturer(String manufacturer) {
this.manufacturer = manufacturer;
}
public String getLicensePlate() {
return licensePlate;
}
public void setLicensePlate(String licensePlate) {
this.licensePlate = licensePlate;
}
public int getSeatCount() {
return seatCount;
}
public void setSeatCount(int seatCount) {
this.seatCount = seatCount;
}
public boolean getPassedVehicleInspection() {
return passedVehicleInspection;
}
public void setPassedVehicleInspection(boolean passed) {
this.passedVehicleInspection = passed;
}
public Driver getDriver() {
return driver;
}
public void setDriver(Driver driver) {
this.driver = driver;
}
}
CarChecks.java 0000664 0000000 0000000 00000001551 12364444513 0033667 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-archetype/src/main/java/com/example /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example;
/**
* @author Hardy Ferentschik
*/
public interface CarChecks {
}
hibernate-validator-4.2.1.Final/hibernate-validator-archetype/src/main/java/com/example/Driver.java 0000664 0000000 0000000 00000002630 12364444513 0033352 0 ustar 00root root 0000000 0000000 /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example;
import javax.validation.constraints.AssertTrue;
import javax.validation.constraints.Min;
/**
* @author Hardy Ferentschik
*/
public class Driver extends Person {
@Min(value = 18, message = "You have to be 18 to drive a car", groups = DriverChecks.class)
private int age;
@AssertTrue(message = "You first have to pass the driving test", groups = DriverChecks.class)
private boolean hasDrivingLicense;
public Driver(String name) {
super( name );
}
public void passedDrivingTest(boolean b) {
hasDrivingLicense = b;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
}
DriverChecks.java 0000664 0000000 0000000 00000001554 12364444513 0034420 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-archetype/src/main/java/com/example /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example;
/**
* @author Hardy Ferentschik
*/
public interface DriverChecks {
}
OrderedChecks.java 0000664 0000000 0000000 00000002004 12364444513 0034540 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-archetype/src/main/java/com/example /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example;
import javax.validation.GroupSequence;
import javax.validation.groups.Default;
/**
* @author Hardy Ferentschik
*/
@GroupSequence({ Default.class, CarChecks.class, DriverChecks.class })
public interface OrderedChecks {
}
hibernate-validator-4.2.1.Final/hibernate-validator-archetype/src/main/java/com/example/Person.java 0000664 0000000 0000000 00000002134 12364444513 0033364 0 ustar 00root root 0000000 0000000 /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example;
import javax.validation.constraints.NotNull;
/**
* @author Hardy Ferentschik
*/
public class Person {
@NotNull
private String name;
public Person(String name) {
super();
this.name = name;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
RentalCar.java 0000664 0000000 0000000 00000002120 12364444513 0033705 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-archetype/src/main/java/com/example /*
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example;
import javax.validation.GroupSequence;
/**
* @author Hardy Ferentschik
*/
@GroupSequence({ RentalCar.class, CarChecks.class })
public class RentalCar extends Car {
public RentalCar(String manufacturer, String licencePlate, int seatCount) {
super( manufacturer, licencePlate, seatCount );
}
}
hibernate-validator-4.2.1.Final/hibernate-validator-archetype/src/main/resources/ 0000775 0000000 0000000 00000000000 12364444513 0030133 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-archetype/src/main/resources/log4j.properties 0000664 0000000 0000000 00000001551 12364444513 0033272 0 ustar 00root root 0000000 0000000 ### direct log messages to stdout ###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
### direct messages to file hibernate.log ###
log4j.appender.file=org.apache.log4j.FileAppender
log4j.appender.file.File=hibernate.log
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
### direct messages to socket - chainsaw ###
log4j.appender.socket=org.apache.log4j.net.SocketAppender
log4j.appender.socket.remoteHost=localhost
log4j.appender.socket.port=4560
log4j.appender.socket.locationInfo=true
### set log levels - for more verbose logging change 'info' to 'debug' ###
log4j.rootLogger=debug, stdout
hibernate-validator-4.2.1.Final/hibernate-validator-archetype/src/test/ 0000775 0000000 0000000 00000000000 12364444513 0026154 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-archetype/src/test/java/ 0000775 0000000 0000000 00000000000 12364444513 0027075 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-archetype/src/test/java/com/ 0000775 0000000 0000000 00000000000 12364444513 0027653 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-archetype/src/test/java/com/example/ 0000775 0000000 0000000 00000000000 12364444513 0031306 5 ustar 00root root 0000000 0000000 BootstrapTest.java 0000664 0000000 0000000 00000007100 12364444513 0034705 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-archetype/src/test/java/com/example /**
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example;
import java.lang.annotation.ElementType;
import java.util.Locale;
import javax.validation.Configuration;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorFactory;
import javax.validation.MessageInterpolator;
import javax.validation.Path;
import javax.validation.TraversableResolver;
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
import static org.junit.Assert.assertNotNull;
import org.junit.Test;
import org.hibernate.validator.HibernateValidator;
import org.hibernate.validator.HibernateValidatorConfiguration;
/**
* A module test that shows the different bootstrap possibilities of Hibernate Validator.
*
* @author Hardy Ferentschik
*/
public class BootstrapTest {
@Test
public void testBuildDefaultValidatorFactory() {
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
Validator validator = factory.getValidator();
assertNotNull( validator );
}
@Test
public void testByDefaultProvider() {
Configuration> config = Validation.byDefaultProvider().configure();
config.messageInterpolator( new MyMessageInterpolator() )
.traversableResolver( new MyTraversableResolver() )
.constraintValidatorFactory( new MyConstraintValidatorFactory() );
ValidatorFactory factory = config.buildValidatorFactory();
Validator validator = factory.getValidator();
assertNotNull( validator );
}
@Test
public void testByProvider() {
HibernateValidatorConfiguration config = Validation.byProvider( HibernateValidator.class ).configure();
config.messageInterpolator( new MyMessageInterpolator() )
.traversableResolver( new MyTraversableResolver() )
.constraintValidatorFactory( new MyConstraintValidatorFactory() );
ValidatorFactory factory = config.buildValidatorFactory();
Validator validator = factory.getValidator();
assertNotNull( validator );
}
public class MyMessageInterpolator implements MessageInterpolator {
public String interpolate(String messageTemplate, Context context) {
return null;
}
public String interpolate(String messageTemplate, Context context, Locale locale) {
return null;
}
}
public class MyTraversableResolver implements TraversableResolver {
public boolean isReachable(Object traversableObject, Path.Node traversableProperty, Class> rootBeanType, Path pathToTraversableObject, ElementType elementType) {
return true;
}
public boolean isCascadable(Object traversableObject, Path.Node traversableProperty, Class> rootBeanType, Path pathToTraversableObject, ElementType elementType) {
return true;
}
}
public class MyConstraintValidatorFactory implements ConstraintValidatorFactory {
public > T getInstance(Class key) {
return null;
}
}
}
hibernate-validator-4.2.1.Final/hibernate-validator-archetype/src/test/java/com/example/CarTest.java0000664 0000000 0000000 00000007230 12364444513 0033520 0 ustar 00root root 0000000 0000000 /**
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example;
import java.util.Set;
import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
import static org.junit.Assert.assertEquals;
import com.example.Car;
import org.junit.BeforeClass;
import org.junit.Test;
/**
*
* A module test that shows how to use the Bean Validation (BV) API to validate
* the constraint annotations at the exemplary {@link Car} model class.
*
*
* The interface {@link Validator} is the main entry point the BV API. The
* test makes use of the validate() method of that interface, which
* returns a set of ConstraintViolations, that describe the
* problems occurred during validation.
*
*
* In case the object in question could be validated successfully this set will
* be empty.
*
*
* @author Gunnar Morling
* @author Hardy Ferentschik
*/
public class CarTest {
/**
* The validator to be used for object validation. Will be retrieved once
* for all test methods.
*/
private static Validator validator;
/**
* Retrieves the validator instance.
*/
@BeforeClass
public static void setUp() {
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
validator = factory.getValidator();
}
/**
* One constraint violation due to the manufacturer field being null
* expected.
*/
@Test
public void manufacturerIsNull() {
Car car = new Car( null, "DD-AB-123", 4 );
Set> constraintViolations = validator.validate( car );
assertEquals( 1, constraintViolations.size() );
assertEquals( "may not be null", constraintViolations.iterator().next().getMessage() );
}
/**
* One constraint violation due to the licensePlate field being too short
* expected.
*/
@Test
public void licensePlateTooShort() {
Car car = new Car( "Morris", "D", 4 );
Set> constraintViolations = validator.validate( car );
assertEquals( 1, constraintViolations.size() );
assertEquals( "size must be between 2 and 14", constraintViolations.iterator().next().getMessage() );
}
/**
* One constraint violation due to the seatCount field being too low
* expected.
*/
@Test
public void seatCountTooLow() {
Car car = new Car( "Morris", "DD-AB-123", 1 );
Set> constraintViolations = validator.validate( car );
assertEquals( 1, constraintViolations.size() );
assertEquals( "must be greater than or equal to 2", constraintViolations.iterator().next().getMessage() );
}
/**
* No constraint violation expected, as all fields of the validated Car
* instance have proper values.
*/
@Test
public void carIsValid() {
Car car = new Car( "Morris", "DD-AB-123", 2 );
Set> constraintViolations = validator.validate( car );
assertEquals( 0, constraintViolations.size() );
}
}
GroupTest.java 0000664 0000000 0000000 00000007371 12364444513 0034036 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-archetype/src/test/java/com/example /**
* JBoss, Home of Professional Open Source
* Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example;
import java.util.Set;
import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
import javax.validation.groups.Default;
import static org.junit.Assert.assertEquals;
import com.example.Car;
import com.example.CarChecks;
import com.example.Driver;
import com.example.DriverChecks;
import com.example.OrderedChecks;
import com.example.RentalCar;
import org.junit.BeforeClass;
import org.junit.Test;
/**
* A module test that shows how to use the grouping functionality of Bean Validation.
*
* @author Hardy Ferentschik
*/
public class GroupTest {
private static Validator validator;
@BeforeClass
public static void setUp() {
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
validator = factory.getValidator();
}
@Test
public void testDriveAway() {
// create a car and check that everything is ok with it.
Car car = new Car( "Morris", "DD-AB-123", 2 );
Set> constraintViolations = validator.validate( car );
assertEquals( 0, constraintViolations.size() );
// but has it passed the vehicle inspection?
constraintViolations = validator.validate( car, CarChecks.class );
assertEquals( 1, constraintViolations.size() );
assertEquals(
"The car has to pass the vehicle inspection first", constraintViolations.iterator().next().getMessage()
);
// let's go to the vehicle inspection
car.setPassedVehicleInspection( true );
assertEquals( 0, validator.validate( car ).size() );
// now let's add a driver. He is 18, but has not passed the driving test yet
Driver john = new Driver( "John Doe" );
john.setAge( 18 );
car.setDriver( john );
constraintViolations = validator.validate( car, DriverChecks.class );
assertEquals( 1, constraintViolations.size() );
assertEquals( "You first have to pass the driving test", constraintViolations.iterator().next().getMessage() );
// ok, John passes the test
john.passedDrivingTest( true );
assertEquals( 0, validator.validate( car, DriverChecks.class ).size() );
// just checking that everything is in order now
assertEquals( 0, validator.validate( car, Default.class, CarChecks.class, DriverChecks.class ).size() );
}
@Test
public void testOrderedChecks() {
Car car = new Car( "Morris", "DD-AB-123", 2 );
car.setPassedVehicleInspection( true );
Driver john = new Driver( "John Doe" );
john.setAge( 18 );
john.passedDrivingTest( true );
car.setDriver( john );
assertEquals( 0, validator.validate( car, OrderedChecks.class ).size() );
}
@Test
public void testOrderedChecksWithRedefinedDefault() {
RentalCar rentalCar = new RentalCar( "Morris", "DD-AB-123", 2 );
rentalCar.setPassedVehicleInspection( true );
Driver john = new Driver( "John Doe" );
john.setAge( 18 );
john.passedDrivingTest( true );
rentalCar.setDriver( john );
assertEquals( 0, validator.validate( rentalCar, Default.class, DriverChecks.class ).size() );
}
}
hibernate-validator-4.2.1.Final/hibernate-validator-distribution/ 0000775 0000000 0000000 00000000000 12364444513 0025141 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-distribution/pom.xml 0000664 0000000 0000000 00000013513 12364444513 0026461 0 ustar 00root root 0000000 0000000
hibernate-validator-parentorg.hibernate4.2.1.Final../pom.xml4.0.0hibernate-validator-distributionHibernate Validator Distribution
Builds the distribution bundles
trueorg.hibernatehibernate-validatororg.hibernatehibernate-validator-annotation-processorjavax.xml.bindjaxb-apicom.sun.xml.bindjaxb-implorg.slf4jslf4j-log4j12org.hibernate.javax.persistencehibernate-jpa-2.0-apijoda-timejoda-timeorg.jsoupjsoupcom.googlecode.jtypejtypeorg.apache.maven.pluginsmaven-javadoc-plugin
${basedir}/../hibernate-validator/src/main/java;
${basedir}/../hibernate-validator/target/generated-sources;
${basedir}/../hibernate-validator-annotation-processor/src/main/java
http://java.sun.com/j2se/1.6.0/docs/api/
http://docs.jboss.org/hibernate/stable/beanvalidation/api/
Hibernate Validator PackagesHibernate Validator ${project.version}Hibernate Validator ${project.version}Validator Packagesorg.hibernate.validator*Annotation Processor Packagesorg.hibernate.validator.ap*aggregate-javadocdeployjavadocorg.apache.maven.pluginsmaven-assembly-plugin${basedir}/src/main/assembly/dist.xmlhibernate-validator-${project.version}make-assemblydeploysingle
hibernate-validator-4.2.1.Final/hibernate-validator-distribution/src/ 0000775 0000000 0000000 00000000000 12364444513 0025730 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-distribution/src/main/ 0000775 0000000 0000000 00000000000 12364444513 0026654 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-distribution/src/main/assembly/ 0000775 0000000 0000000 00000000000 12364444513 0030473 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-distribution/src/main/assembly/dist.xml 0000664 0000000 0000000 00000010120 12364444513 0032152 0 ustar 00root root 0000000 0000000
disttar.gzziporg.hibernate:hibernate-validator-annotation-processororg.hibernate:hibernate-validatorlib/requiredjavax.validation:validation-apiorg.slf4j:slf4j-apilib/jdk5truejavax.xml.bind:jaxb-apicom.sun.xml.bind:jaxb-impljavax.xml.stream:*javax.activation:*lib/optionalorg.slf4j:slf4j-log4j12log4j:log4jjoda-time:joda-timeorg.hibernate.javax.persistence:hibernate-jpa-2.0-apiorg.jsoup:jsoup../readme.txt/../changelog.txt/../license.txt/..projecttruereadme.txtlicense.txt.git.gitignore**/target/****/.idea/**.sonar-ide.properties**/*.imltarget/site/apidocsdocs/api../hibernate-validator/target/docbook/publishdocs/reference
hibernate-validator-4.2.1.Final/hibernate-validator-tck-runner/ 0000775 0000000 0000000 00000000000 12364444513 0024512 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-tck-runner/pom.xml 0000664 0000000 0000000 00000037317 12364444513 0026042 0 ustar 00root root 0000000 0000000
4.0.0hibernate-validator-parentorg.hibernate4.2.1.Final../pom.xmlhibernate-validator-tck-runnerHibernate Validator TCK RunnerAggregates dependencies and runs the JSR-303 TCKjavax.validationvalidation-apiorg.hibernatehibernate-validatororg.slf4jslf4j-apitestorg.slf4jslf4j-simpletestorg.hibernate.javax.persistencehibernate-jpa-2.0-apitestorg.testngtestngorg.hibernate.jsr303.tckjsr303-tckorg.jboss.jbossas.as7-cdi-tckjbossas-container${env.JBOSS_HOME}org.hibernate.validator.HibernateValidatororg.apache.maven.pluginsmaven-dependency-plugincopygenerate-test-sourcescopytrueorg.hibernate.jsr303.tckjsr303-tckxmlsuitefalseorg.apache.maven.pluginsmaven-surefire-plugin${project.build.directory}/dependency/jsr303-tck-suite.xml-Xmx128moncevalidation.provider${validation.provider}org.jboss.testharness.spi.StandaloneContainersorg.hibernate.jsr303.tck.util.StandaloneContainersImplorg.apache.maven.pluginsmaven-surefire-report-plugingenerate-test-reporttestreport-only${project.build.directory}/surefire-reportstest-reportincontainer-debugdebug-Xnoagent -Djava.compiler=NONE -Xdebug
-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005
incontainerincontainerorg.jboss.asjboss-as-arquillian-container-managedtestorg.apache.maven.pluginsmaven-surefire-plugin${project.build.directory}/dependency/jsr303-tck-suite.xmljava.io.tmpdir${project.build.outputDirectory}org.jboss.testharness.standalonefalseorg.jboss.testharness.container.forceRestarttrueorg.jboss.testharness.runIntegrationTeststrueorg.jboss.testharness.libraryDirectory${project.build.directory}/dependency/liborg.jboss.testharness.outputDirectory${project.build.directory}jboss.options-Xms128m -Xmx512m -XX:MaxPermSize=512m -enableassertions
-Dvalidation.provider=${validation.provider} ${remote.debug}
org.jboss.testharness.spi.Containersorg.jboss.jbossas.cdiTck.container.ArquillianContainerAdaptororg.jboss.har2arq.containerorg.jboss.as.arquillian.container.managed.JBossAsManagedContainerjboss.home${jboss.home}validation.provider${validation.provider}bundled-dependenciesbundled-dependenciesorg.apache.maven.pluginsmaven-dependency-plugincopygenerate-test-sourcescopytrueorg.hibernate.jsr303.tckjsr303-tckxmlsuitefalsejavax.validationvalidation-apitrue${project.build.directory}/dependency/liborg.hibernatehibernate-validatortrue${project.build.directory}/dependency/liborg.slf4jslf4j-simpletrue${project.build.directory}/dependency/liborg.slf4jslf4j-apitrue${project.build.directory}/dependency/libwrite-artifacts-to-diskdumpArtifactsorg.codehaus.mojoexec-maven-plugingenerate-jsr-303-artifactstest-compilejavatestorg.jboss.testharness.api.TCKdumpArtifactstrueorg.jboss.testharness.outputDirectorytarget/jsr303-artifactsorg.jboss.testharness.libraryDirectorytarget/jsr303-artifacts/dependenciesorg.jboss.testharness.libraryDirectory${project.build.directory}/dependency/liborg.jboss.testharness.spi.StandaloneContainersorg.hibernate.jsr303.tck.util.StandaloneContainersImpl
hibernate-validator-4.2.1.Final/hibernate-validator-tck-runner/readme.md 0000664 0000000 0000000 00000002422 12364444513 0026271 0 ustar 00root root 0000000 0000000 # Hibernate Validator TCK Runner
This maven module allows to run the Bean Validation TCK against Hibernate Validator.
There are several ways of doing this. In any case you will need to define the *JBOSS_HOME*
environment variable referencing a AS 7 instance.
## Standalone
You can run the test as normal unit test using a JVM forked by the Surefire plugin. This is the default mode and
used when running
$ mvn clean test
## In container
You can also run the TCK test against JBoss AS7 (>Beta3). In this case the tests are bundled as war files and executed
in a remote JBoss AS7 instance:
$ mvn clean test -Dincontainer
In this mode the tests will run against the Hibernate Validator version bundled with AS 7 (currently 4.1.0.Final) which
will lead to test errors. You can place the latest Hibernate Validator instance into your AS 7 instance or you can
bundle the Hibernate Validator jar with the deployed war files:
$ mvn test -Dincontainer -Dbundled-dependencies
Alternatively you can run against the TCK version is in sync with Hibernate Validator 4.1.0.Final:
$ mvn test -Dincontainer -Djsr303.tck.version=1.0.4.GA
You can find more information about the Bean Validation TCK [here](http://docs.jboss.org/hibernate/stable/beanvalidation/tck/reference/html_single/).
hibernate-validator-4.2.1.Final/hibernate-validator-tck-runner/src/ 0000775 0000000 0000000 00000000000 12364444513 0025301 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-tck-runner/src/main/ 0000775 0000000 0000000 00000000000 12364444513 0026225 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-tck-runner/src/main/resources/ 0000775 0000000 0000000 00000000000 12364444513 0030237 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-tck-runner/src/main/resources/META-INF/ 0000775 0000000 0000000 00000000000 12364444513 0031377 5 ustar 00root root 0000000 0000000 jboss-test-harness.properties 0000664 0000000 0000000 00000000245 12364444513 0037175 0 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-tck-runner/src/main/resources/META-INF org.jboss.testharness.api.TestLauncher=org.jboss.testharness.impl.runner.servlet.ServletTestLauncher
org.jboss.testharness.testPackage=org.hibernate.jsr303.tck.tests hibernate-validator-4.2.1.Final/hibernate-validator-tck-runner/src/test/ 0000775 0000000 0000000 00000000000 12364444513 0026260 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-tck-runner/src/test/resources/ 0000775 0000000 0000000 00000000000 12364444513 0030272 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator-tck-runner/src/test/resources/log4j.xml 0000664 0000000 0000000 00000002673 12364444513 0032043 0 ustar 00root root 0000000 0000000
hibernate-validator-4.2.1.Final/hibernate-validator/ 0000775 0000000 0000000 00000000000 12364444513 0022424 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator/pom.xml 0000664 0000000 0000000 00000040125 12364444513 0023743 0 ustar 00root root 0000000 0000000
hibernate-validator-parentorg.hibernate4.2.1.Final../pom.xml4.0.0org.hibernatehibernate-validatorHibernate Validator
Hibernate's Bean Validation (JSR-303) reference implementation.
sitehttp://validator.hibernate.orgjavax.validationvalidation-apiorg.slf4jslf4j-apicom.googlecode.jtypejtypeorg.jsoupjsouptruejavax.xml.bindjaxb-apiprovidedcom.sun.xml.bindjaxb-implprovidedorg.hibernate.javax.persistencehibernate-jpa-2.0-apitruejoda-timejoda-timetrueorg.testngtestngtestorg.easymockeasymocktestorg.hibernatehibernate-entitymanagertestcom.h2databaseh2testorg.slf4jslf4j-log4j12testorg.hibernate.dialect.H2Dialectorg.h2.Driverjdbc:h2:mem:db1;DB_CLOSE_DELAY=-1satestsrc/main/resourcestruesrc/main/xsdMETA-INFtruesrc/test/resources**/*.properties**/*.xmlorg.apache.maven.pluginsmaven-source-pluginorg.codehaus.mojojaxb2-maven-pluginxjcorg.hibernate.validator.xml${basedir}/target/generated-sourcestrueorg.apache.maven.pluginsmaven-jar-plugin${project.build.outputDirectory}/META-INF/MANIFEST.MForg.apache.felixmaven-bundle-plugintrue
javax.persistence.*;version="[2.0.0,3.0.0)";resolution:=optional,
javax.validation.*;version="[1.0.0,2.0.0)",
javax.xml.*;version="0",
org.xml.sax.*;version="0",
org.slf4j.*;version="[1.5.6,2.0.0)",
org.joda.time.*;version="[1.6.0,2.0.0)";resolution:=optional,
org.jsoup.*;version="[1.5.2,2.0.0)";resolution:=optional
org.hibernate.validator;version="${project.version}",
org.hibernate.validator.constraints;version="${project.version}",
org.hibernate.validator.cfg;version="${project.version}",
org.hibernate.validator.cfg.context;version="${project.version}",
org.hibernate.validator.cfg.defs;version="${project.version}",
org.hibernate.validator.group;version="${project.version}",
org.hibernate.validator.messageinterpolation;version="${project.version}",
org.hibernate.validator.method;version="${project.version}",
org.hibernate.validator.method.metadata;version="${project.version}",
org.hibernate.validator.resourceloading;version="${project.version}"
bundle-manifestprocess-classesmanifestorg.apache.maven.pluginsmaven-surefire-plugin${basedir}/src/test/suite/unit-tests.xmlorg.apache.maven.pluginsmaven-surefire-report-pluginorg.apache.maven.pluginsmaven-shade-pluginpackageshadecom.googlecode.jtype:jtypecom.googlecode.jtypeorg.hibernate.validator.jtypeorg.apache.maven.pluginsmaven-javadoc-plugin
http://java.sun.com/j2se/1.5.0/docs/api/
http://docs.jboss.org/hibernate/stable/beanvalidation/api/
Hibernate Validator PackagesHibernate Validator ${project.version}Hibernate Validator ${project.version}attach-javadocsdeployjarorg.jboss.maven.pluginsmaven-jdocbook-plugintrueorg.hibernatehibernate-jdocbook-style2.0.1jdocbook-stylemaster.xml${basedir}/src/main/docbooken-USzh-CN${jdocbook.ignoreTranslations}${basedir}/src/main/docbook/en-US/imagespdfclasspath:/xslt/org/hibernate/jdocbook/xslt/pdf.xslhibernate_validator_reference.pdfhtml_singleclasspath:/xslt/org/hibernate/jdocbook/xslt/xhtml-single.xsl
index.htmlhtmlclasspath:/xslt/org/hibernate/jdocbook/xslt/xhtml.xsl
index.htmltruesaxon1.72.0-truemake-docdeployresourcestranslategenerateorg.jboss.maven.pluginsmaven-jdocbook-style-pluginorg.apache.maven.pluginsmaven-release-pluginorg.jboss.maven.pluginsmaven-injection-plugincompilebytecode${project.version}org.hibernate.validator.util.VersiongetVersionString
hibernate-validator-4.2.1.Final/hibernate-validator/src/ 0000775 0000000 0000000 00000000000 12364444513 0023213 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator/src/main/ 0000775 0000000 0000000 00000000000 12364444513 0024137 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator/src/main/docbook/ 0000775 0000000 0000000 00000000000 12364444513 0025557 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator/src/main/docbook/en-US/ 0000775 0000000 0000000 00000000000 12364444513 0026506 5 ustar 00root root 0000000 0000000 hibernate-validator-4.2.1.Final/hibernate-validator/src/main/docbook/en-US/hv.ent 0000664 0000000 0000000 00000000267 12364444513 0027640 0 ustar 00root root 0000000 0000000