Hibernate SVN: r19608 - in validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator: engine and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2010-05-25 16:30:50 -0400 (Tue, 25 May 2010)
New Revision: 19608
Added:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintDefAccessor.java
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintDef.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintMapping.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/ValidatorFactoryImpl.java
Log:
HV-274 added an additional indirection in order to only have configuration methods in the XYZDef classes
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintDef.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintDef.java 2010-05-25 19:07:43 UTC (rev 19607)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintDef.java 2010-05-25 20:30:50 UTC (rev 19608)
@@ -30,14 +30,18 @@
* @author Hardy Ferentschik
*/
public class ConstraintDef<A extends Annotation> {
- private final Class<A> constraintType;
- private final Map<String, Object> parameters;
- private final Class<?> beanType;
- private final ElementType elementType;
- private final String property;
- private final ConstraintMapping mapping;
+ protected final Class<A> constraintType;
+ protected final Map<String, Object> parameters;
+ protected final Class<?> beanType;
+ protected final ElementType elementType;
+ protected final String property;
+ protected final ConstraintMapping mapping;
public ConstraintDef(Class<?> beanType, Class<A> constraintType, String property, ElementType elementType, ConstraintMapping mapping) {
+ this( beanType, constraintType, property, elementType, new HashMap<String, Object>(), mapping );
+ }
+
+ protected ConstraintDef(Class<?> beanType, Class<A> constraintType, String property, ElementType elementType, Map<String, Object> parameters, ConstraintMapping mapping) {
if ( beanType == null ) {
throw new ValidationException( "Null is not a valid bean type" );
}
@@ -65,7 +69,7 @@
this.beanType = beanType;
this.constraintType = constraintType;
- this.parameters = new HashMap<String, Object>();
+ this.parameters = parameters;
this.property = property;
this.elementType = elementType;
this.mapping = mapping;
@@ -77,7 +81,6 @@
}
public <A extends Annotation, T extends ConstraintDef<A>> T constraint(Class<T> definition) {
-
final Constructor<T> constructor = ReflectionHelper.getConstructor(
definition, Class.class, String.class, ElementType.class, ConstraintMapping.class
);
@@ -103,30 +106,10 @@
return new ConstraintsForType( beanType, mapping );
}
- public Class<A> getConstraintType() {
- return constraintType;
- }
-
- public Map<String, Object> getParameters() {
- return parameters;
- }
-
- public ElementType getElementType() {
- return elementType;
- }
-
- public Class<?> getBeanType() {
- return beanType;
- }
-
- public String getProperty() {
- return property;
- }
-
@Override
public String toString() {
final StringBuilder sb = new StringBuilder();
- sb.append( "ConstraintDefinition" );
+ sb.append( this.getClass().getName() );
sb.append( "{beanType=" ).append( beanType );
sb.append( ", constraintType=" ).append( constraintType );
sb.append( ", parameters=" ).append( parameters );
Copied: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintDefAccessor.java (from rev 19606, validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintDef.java)
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintDefAccessor.java (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintDefAccessor.java 2010-05-25 20:30:50 UTC (rev 19608)
@@ -0,0 +1,52 @@
+// $Id$
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.cfg;
+
+import java.lang.annotation.Annotation;
+import java.lang.annotation.ElementType;
+import java.util.Map;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class ConstraintDefAccessor<A extends Annotation> extends ConstraintDef<A> {
+
+ public ConstraintDefAccessor(Class<?> beanType, Class<A> constraintType, String property, ElementType elementType, Map<String, Object> parameters, ConstraintMapping mapping) {
+ super( beanType, constraintType, property, elementType, parameters, mapping );
+ }
+
+ public Class<A> getConstraintType() {
+ return constraintType;
+ }
+
+ public Map<String, Object> getParameters() {
+ return this.parameters;
+ }
+
+ public ElementType getElementType() {
+ return elementType;
+ }
+
+ public Class<?> getBeanType() {
+ return beanType;
+ }
+
+ public String getProperty() {
+ return property;
+ }
+}
\ No newline at end of file
Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintDefAccessor.java
___________________________________________________________________
Name: svn:keywords
+ Id
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintMapping.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintMapping.java 2010-05-25 19:07:43 UTC (rev 19607)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintMapping.java 2010-05-25 20:30:50 UTC (rev 19608)
@@ -17,6 +17,7 @@
*/
package org.hibernate.validator.cfg;
+import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -32,13 +33,13 @@
* @author Hardy Ferentschik
*/
public class ConstraintMapping {
- private final Map<Class<?>, List<ConstraintDef<?>>> constraintConfig;
+ private final Map<Class<?>, List<ConstraintDefAccessor<?>>> constraintConfig;
private final Map<Class<?>, List<CascadeDef>> cascadeConfig;
private final Set<Class<?>> configuredClasses;
private final Map<Class<?>, List<Class<?>>> defaultGroupSequences;
public ConstraintMapping() {
- this.constraintConfig = new HashMap<Class<?>, List<ConstraintDef<?>>>();
+ this.constraintConfig = new HashMap<Class<?>, List<ConstraintDefAccessor<?>>>();
this.cascadeConfig = new HashMap<Class<?>, List<CascadeDef>>();
this.configuredClasses = new HashSet<Class<?>>();
this.defaultGroupSequences = new HashMap<Class<?>, List<Class<?>>>();
@@ -48,15 +49,24 @@
return new ConstraintsForType( beanClass, this );
}
- protected void addConstraintConfig(ConstraintDef<?> definition) {
- Class<?> beanClass = definition.getBeanType();
+ protected <A extends Annotation> void addConstraintConfig(ConstraintDef<?> definition) {
+ Class<?> beanClass = definition.beanType;
+ ConstraintDefAccessor<A> defAccessor = new ConstraintDefAccessor<A>(
+ beanClass,
+ ( Class<A> ) definition.constraintType,
+ definition.property,
+ definition.elementType,
+ definition.parameters,
+ this
+ );
+
configuredClasses.add( beanClass );
if ( constraintConfig.containsKey( beanClass ) ) {
- constraintConfig.get( beanClass ).add( definition );
+ constraintConfig.get( beanClass ).add( defAccessor );
}
else {
- List<ConstraintDef<?>> definitionList = new ArrayList<ConstraintDef<?>>();
- definitionList.add( definition );
+ List<ConstraintDefAccessor<?>> definitionList = new ArrayList<ConstraintDefAccessor<?>>();
+ definitionList.add( defAccessor );
constraintConfig.put( beanClass, definitionList );
}
}
@@ -78,7 +88,7 @@
defaultGroupSequences.put( beanClass, defaultGroupSequence );
}
- public Map<Class<?>, List<ConstraintDef<?>>> getConstraintConfig() {
+ public Map<Class<?>, List<ConstraintDefAccessor<?>>> getConstraintConfig() {
return constraintConfig;
}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/ValidatorFactoryImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/ValidatorFactoryImpl.java 2010-05-25 19:07:43 UTC (rev 19607)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/ValidatorFactoryImpl.java 2010-05-25 20:30:50 UTC (rev 19608)
@@ -35,7 +35,7 @@
import javax.validation.spi.ConfigurationState;
import org.hibernate.validator.cfg.CascadeDef;
-import org.hibernate.validator.cfg.ConstraintDef;
+import org.hibernate.validator.cfg.ConstraintDefAccessor;
import org.hibernate.validator.cfg.ConstraintMapping;
import org.hibernate.validator.metadata.AnnotationIgnores;
import org.hibernate.validator.metadata.BeanMetaDataCache;
@@ -228,10 +228,10 @@
}
@SuppressWarnings("unchecked")
- private <T, A extends Annotation> void addProgrammaticConfiguredConstraints(List<ConstraintDef<?>> definitions,
+ private <T, A extends Annotation> void addProgrammaticConfiguredConstraints(List<ConstraintDefAccessor<?>> definitions,
Class<T> rootClass, Class<?> hierarchyClass,
Map<Class<?>, List<MetaConstraint<T, ?>>> constraints) {
- for ( ConstraintDef<?> config : definitions ) {
+ for ( ConstraintDefAccessor<?> config : definitions ) {
A annotation = ( A ) createAnnotationProxy( config );
ConstraintOrigin definedIn = definedIn( rootClass, hierarchyClass );
ConstraintDescriptorImpl<A> constraintDescriptor = new ConstraintDescriptorImpl<A>(
@@ -299,7 +299,7 @@
}
@SuppressWarnings("unchecked")
- private <A extends Annotation> Annotation createAnnotationProxy(ConstraintDef<?> config) {
+ private <A extends Annotation> Annotation createAnnotationProxy(ConstraintDefAccessor<?> config) {
Class<A> constraintType = ( Class<A> ) config.getConstraintType();
AnnotationDescriptor<A> annotationDescriptor = new AnnotationDescriptor<A>( constraintType );
for ( Map.Entry<String, Object> parameter : config.getParameters().entrySet() ) {
14 years, 7 months
Hibernate SVN: r19607 - core/trunk/documentation/manual/src/main/docbook/en-US/content.
by hibernate-commits@lists.jboss.org
Author: steve.ebersole(a)jboss.com
Date: 2010-05-25 15:07:43 -0400 (Tue, 25 May 2010)
New Revision: 19607
Added:
core/trunk/documentation/manual/src/main/docbook/en-US/content/type.xml
Log:
Added: core/trunk/documentation/manual/src/main/docbook/en-US/content/type.xml
===================================================================
--- core/trunk/documentation/manual/src/main/docbook/en-US/content/type.xml (rev 0)
+++ core/trunk/documentation/manual/src/main/docbook/en-US/content/type.xml 2010-05-25 19:07:43 UTC (rev 19607)
@@ -0,0 +1,990 @@
+<!--
+ ~ Hibernate, Relational Persistence for Idiomatic Java
+ ~
+ ~ Copyright (c) 2010, Red Hat Inc. or third-party contributors as
+ ~ indicated by the @author tags or express copyright attribution
+ ~ statements applied by the authors. All third-party contributions are
+ ~ distributed under license by Red Hat Inc.
+ ~
+ ~ This copyrighted material is made available to anyone wishing to use, modify,
+ ~ copy, or redistribute it subject to the terms and conditions of the GNU
+ ~ Lesser General Public License, as published by the Free Software Foundation.
+ ~
+ ~ This program is distributed in the hope that it will be useful,
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ ~ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+ ~ for more details.
+ ~
+ ~ You should have received a copy of the GNU Lesser General Public License
+ ~ along with this distribution; if not, write to:
+ ~ Free Software Foundation, Inc.
+ ~ 51 Franklin Street, Fifth Floor
+ ~ Boston, MA 02110-1301 USA
+ -->
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+
+<chapter id="types">
+ <title>Types</title>
+
+ <para>
+ As an Object/Relational Mapping solution, Hibernate deals with both the Java and JDBC representations of
+ application data. An online catalog application, for example, most likely has <classname>Product</classname>
+ object with a number of attributes such as a <literal>sku</literal>, <literal>name</literal>, etc. For these
+ individual attributes, Hibernate must be able to read the values out of the database and write them back. This
+ 'marshalling' is the function of a <emphasis>Hibernate type</emphasis>, which is an implementation of the
+ <interfacename>org.hibernate.type.Type</interfacename> interface. In addition, a
+ <emphasis>Hibernate type</emphasis> describes various aspects of behavior of the Java type such as "how is
+ equality checked?" or "how are values cloned?".
+ </para>
+
+ <important>
+ <para>
+ A Hibernate type is neither a Java type nor a SQL datatype; it provides a information about both.
+ </para>
+ <para>
+ When you encounter the term <emphasis>type</emphasis> in regards to Hibernate be aware that usage might
+ refer to the Java type, the SQL/JDBC type or the Hibernate type.
+ </para>
+ </important>
+
+ <para>
+ Hibernate categorizes types into two high-level groups: value types (see <xref linkend="types.value"/>) and
+ entity types (see <xref linkend="types.entity"/>).
+ </para>
+
+ <section id="types.value">
+ <title>Value types</title>
+
+ <para>
+ The main distinguishing characteristic of a value type is the fact that they do not define their own
+ lifecycle. We say that they are "owned" by something else (specifically an entity, as we will see later)
+ which defines their lifecycle. Value types are further classified into 3 sub-categories: basic types (see
+ <xref linkend="types.value.basic"/>), composite types (see <xref linkend="types.value.composite"/>)
+ amd collection types (see <xref linkend="types.value.collection"/>).
+ </para>
+
+ <section id="types.value.basic">
+ <title>Basic value types</title>
+ <para>
+ The norm for basic value types is that they map a single database value (column) to a single,
+ non-aggregated Java type. Hibernate provides a number of built-in basic types, which we will present
+ in the following sections by the Java type. Mainly these follow the natural mappings recommended in the
+ JDBC specification. We will later cover how to override these mapping and how to provide and use
+ alternative type mappings.
+ </para>
+ <section id="types.value.basic.string">
+ <title>java.lang.String</title>
+ <variablelist>
+ <varlistentry>
+ <term><classname>org.hibernate.type.StringType</classname></term>
+ <listitem>
+ <para>
+ Maps a string to the JDBC VARCHAR type. This is the standard mapping for a string if
+ no Hibernate type is specified.
+ </para>
+ <para>
+ Registered under <literal>string</literal> and <literal>java.lang.String</literal>
+ in the type registry (see <xref linkend="types.registry"/>).
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><classname>org.hibernate.type.MaterializedClob</classname></term>
+ <listitem>
+ <para>
+ Maps a string to a JDBC CLOB type
+ </para>
+ <para>
+ Registered under <literal>materialized_clob</literal> in the type registry (see
+ <xref linkend="types.registry"/>).
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><classname>org.hibernate.type.TextType</classname></term>
+ <listitem>
+ <para>
+ Maps a string to a JDBC LONGVARCHAR type
+ </para>
+ <para>
+ Registered under <literal>text</literal> in the type registry (see
+ <xref linkend="types.registry"/>).
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="types.basic.value.character">
+ <title><classname>java.lang.Character</classname> (or char primitive)</title>
+ <variablelist>
+ <varlistentry>
+ <term><classname>org.hibernate.type.CharacterType</classname></term>
+ <listitem>
+ <para>
+ Maps a char or <classname>java.lang.Character</classname> to a JDBC CHAR
+ </para>
+ <para>
+ Registered under <literal>char</literal> and <literal>java.lang.Character</literal> in the
+ type registry (see <xref linkend="types.registry"/>).
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="types.value.basic.boolean">
+ <title><classname>java.lang.Boolean</classname> (or boolean primitive)</title>
+ <variablelist>
+ <varlistentry>
+ <term><classname>org.hibernate.type.BooleanType</classname></term>
+ <listitem>
+ <para>
+ Maps a boolean to a JDBC BIT type
+ </para>
+ <para>
+ Registered under <literal>boolean</literal> and <literal>java.lang.Boolean</literal> in
+ the type registry (see <xref linkend="types.registry"/>).
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><classname>org.hibernate.type.NumericBooleanType</classname></term>
+ <listitem>
+ <para>
+ Maps a boolean to a JDBC INTEGER type as 0 = false, 1 = true
+ </para>
+ <para>
+ Registered under <literal>numeric_boolean</literal> in the type registry (see
+ <xref linkend="types.registry"/>).
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><classname>org.hibernate.type.YesNoType</classname></term>
+ <listitem>
+ <para>
+ Maps a boolean to a JDBC CHAR type as ('N' | 'n') = false, ( 'Y' | 'y' ) = true
+ </para>
+ <para>
+ Registered under <literal>yes_no</literal> in the type registry (see
+ <xref linkend="types.registry"/>).
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><classname>org.hibernate.type.TrueFalseType</classname></term>
+ <listitem>
+ <para>
+ Maps a boolean to a JDBC CHAR type as ('F' | 'f') = false, ( 'T' | 't' ) = true
+ </para>
+ <para>
+ Registered under <literal>true_false</literal> in the type registry (see
+ <xref linkend="types.registry"/>).
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="types.basic.value.byte">
+ <title><classname>java.lang.Byte</classname> (or byte primitive)</title>
+ <variablelist>
+ <varlistentry>
+ <term><classname>org.hibernate.type.ByteType</classname></term>
+ <listitem>
+ <para>
+ Maps a byte or <classname>java.lang.Byte</classname> to a JDBC TINYINT
+ </para>
+ <para>
+ Registered under <literal>byte</literal> and <literal>java.lang.Byte</literal> in the
+ type registry (see <xref linkend="types.registry"/>).
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="types.basic.value.short">
+ <title><classname>java.lang.Short</classname> (or short primitive)</title>
+ <variablelist>
+ <varlistentry>
+ <term><classname>org.hibernate.type.ShortType</classname></term>
+ <listitem>
+ <para>
+ Maps a short or <classname>java.lang.Short</classname> to a JDBC SMALLINT
+ </para>
+ <para>
+ Registered under <literal>short</literal> and <literal>java.lang.Short</literal> in the
+ type registry (see <xref linkend="types.registry"/>).
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="types.basic.value.int">
+ <title><classname>java.lang.Integer</classname> (or int primitive)</title>
+ <variablelist>
+ <varlistentry>
+ <term><classname>org.hibernate.type.IntegerTypes</classname></term>
+ <listitem>
+ <para>
+ Maps an int or <classname>java.lang.Integer</classname> to a JDBC INTEGER
+ </para>
+ <para>
+ Registered under <literal>int</literal> and <literal>java.lang.Integer</literal>in the
+ type registry (see <xref linkend="types.registry"/>).
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="types.basic.value.long">
+ <title><classname>java.lang.Long</classname> (or long primitive)</title>
+ <variablelist>
+ <varlistentry>
+ <term><classname>org.hibernate.type.LongType</classname></term>
+ <listitem>
+ <para>
+ Maps a long or <classname>java.lang.Long</classname> to a JDBC BIGINT
+ </para>
+ <para>
+ Registered under <literal>long</literal> and <literal>java.lang.Long</literal> in the
+ type registry (see <xref linkend="types.registry"/>).
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="types.basic.value.float">
+ <title><classname>java.lang.Float</classname> (or float primitive)</title>
+ <variablelist>
+ <varlistentry>
+ <term><classname>org.hibernate.type.FloatType</classname></term>
+ <listitem>
+ <para>
+ Maps a float or <classname>java.lang.Float</classname> to a JDBC FLOAT
+ </para>
+ <para>
+ Registered under <literal>float</literal> and <literal>java.lang.Float</literal> in the
+ type registry (see <xref linkend="types.registry"/>).
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="types.basic.value.double">
+ <title><classname>java.lang.Double</classname> (or double primitive)</title>
+ <variablelist>
+ <varlistentry>
+ <term><classname>org.hibernate.type.DoubleType</classname></term>
+ <listitem>
+ <para>
+ Maps a double or <classname>java.lang.Double</classname> to a JDBC DOUBLE
+ </para>
+ <para>
+ Registered under <literal>double</literal> and <literal>java.lang.Double</literal> in the
+ type registry (see <xref linkend="types.registry"/>).
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="types.basic.value.biginteger">
+ <title><classname>java.math.BigInteger</classname></title>
+ <variablelist>
+ <varlistentry>
+ <term><classname>org.hibernate.type.BigIntegerType</classname></term>
+ <listitem>
+ <para>
+ Maps a <classname>java.math.BigInteger</classname> to a JDBC NUMERIC
+ </para>
+ <para>
+ Registered under <literal>big_integer</literal> and <literal>java.math.BigInteger</literal> in the
+ type registry (see <xref linkend="types.registry"/>).
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="types.basic.value.bigdecimal">
+ <title><classname>java.math.BigDecimal</classname></title>
+ <variablelist>
+ <varlistentry>
+ <term><classname>org.hibernate.type.BigDecimalType</classname></term>
+ <listitem>
+ <para>
+ Maps a <classname>java.math.BigDecimal</classname> to a JDBC NUMERIC
+ </para>
+ <para>
+ Registered under <literal>big_decimal</literal> and <literal>java.math.BigDecimal</literal> in the
+ type registry (see <xref linkend="types.registry"/>).
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="types.basic.value.timestamp">
+ <title><classname>java.util.Date</classname> or <classname>java.sql.Timestamp</classname></title>
+ <variablelist>
+ <varlistentry>
+ <term><classname>org.hibernate.type.TimestampType</classname></term>
+ <listitem>
+ <para>
+ Maps a <classname>java.sql.Timestamp</classname> to a JDBC TIMESTAMP
+ </para>
+ <para>
+ Registered under <literal>timestamp</literal>, <literal>java.sql.Timestamp</literal> and
+ <literal>java.util.Date</literal> in the type registry (see <xref linkend="types.registry"/>).
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="types.basic.value.time">
+ <title><classname>java.sql.Time</classname></title>
+ <variablelist>
+ <varlistentry>
+ <term><classname>org.hibernate.type.TimeType</classname></term>
+ <listitem>
+ <para>
+ Maps a <classname>java.sql.Time</classname> to a JDBC TIME
+ </para>
+ <para>
+ Registered under <literal>time</literal> and <literal>java.sql.Time</literal> in the
+ type registry (see <xref linkend="types.registry"/>).
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="types.basic.value.date">
+ <title><classname>java.sql.Date</classname></title>
+ <variablelist>
+ <varlistentry>
+ <term><classname>org.hibernate.type.DateType</classname></term>
+ <listitem>
+ <para>
+ Maps a <classname>java.sql.Date</classname> to a JDBC DATE
+ </para>
+ <para>
+ Registered under <literal>date</literal> and <literal>java.sql.Date</literal> in the
+ type registry (see <xref linkend="types.registry"/>).
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="types.basic.value.calendar">
+ <title><classname>java.util.Calendar</classname></title>
+ <variablelist>
+ <varlistentry>
+ <term><classname>org.hibernate.type.CalendarType</classname></term>
+ <listitem>
+ <para>
+ Maps a <classname>java.util.Calendar</classname> to a JDBC TIMESTAMP
+ </para>
+ <para>
+ Registered under <literal>calendar</literal>, <literal>java.util.Calendar</literal> and
+ <literal>java.util.GregorianCalendar</literal> in the type registry (see
+ <xref linkend="types.registry"/>).
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><classname>org.hibernate.type.CalendarDateType</classname></term>
+ <listitem>
+ <para>
+ Maps a <classname>java.util.Calendar</classname> to a JDBC DATE
+ </para>
+ <para>
+ Registered under <literal>calendar_date</literal> in the type registry (see
+ <xref linkend="types.registry"/>).
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="types.basic.value.currency">
+ <title><classname>java.util.Currency</classname></title>
+ <variablelist>
+ <varlistentry>
+ <term><classname>org.hibernate.type.CurrencyType</classname></term>
+ <listitem>
+ <para>
+ Maps a <classname>java.util.Currency</classname> to a JDBC VARCHAR (using the Currency code)
+ </para>
+ <para>
+ Registered under <literal>currency</literal> and <literal>java.util.Currency</literal> in the
+ type registry (see <xref linkend="types.registry"/>).
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="types.basic.value.locale">
+ <title><classname>java.util.Locale</classname></title>
+ <variablelist>
+ <varlistentry>
+ <term><classname>org.hibernate.type.LocaleType</classname></term>
+ <listitem>
+ <para>
+ Maps a <classname>java.util.Locale</classname> to a JDBC VARCHAR (using the Locale code)
+ </para>
+ <para>
+ Registered under <literal>locale</literal> and <literal>java.util.Locale</literal> in the
+ type registry (see <xref linkend="types.registry"/>).
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="types.basic.value.timezone">
+ <title><classname>java.util.TimeZone</classname></title>
+ <variablelist>
+ <varlistentry>
+ <term><classname>org.hibernate.type.TimeZoneType</classname></term>
+ <listitem>
+ <para>
+ Maps a <classname>java.util.TimeZone</classname> to a JDBC VARCHAR (using the TimeZone ID)
+ </para>
+ <para>
+ Registered under <literal>timezone</literal> and <literal>java.util.TimeZone</literal> in the
+ type registry (see <xref linkend="types.registry"/>).
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="types.basic.value.class">
+ <title><classname>java.lang.Class</classname></title>
+ <variablelist>
+ <varlistentry>
+ <term><classname>org.hibernate.type.ClassType</classname></term>
+ <listitem>
+ <para>
+ Maps a <classname>java.lang.Class</classname> to a JDBC VARCHAR (using the Class name)
+ </para>
+ <para>
+ Registered under <literal>class</literal> and <literal>java.lang.Class</literal> in the
+ type registry (see <xref linkend="types.registry"/>).
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="types.basic.value.blob">
+ <title><classname>java.sql.Blob</classname></title>
+ <variablelist>
+ <varlistentry>
+ <term><classname>org.hibernate.type.BlobType</classname></term>
+ <listitem>
+ <para>
+ Maps a <classname>java.sql.Blob</classname> to a JDBC BLOB
+ </para>
+ <para>
+ Registered under <literal>blob</literal> and <literal>java.sql.Blob</literal> in the
+ type registry (see <xref linkend="types.registry"/>).
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="types.basic.value.clob">
+ <title><classname>java.sql.Clob</classname></title>
+ <variablelist>
+ <varlistentry>
+ <term><classname>org.hibernate.type.ClobType</classname></term>
+ <listitem>
+ <para>
+ Maps a <classname>java.sql.Clob</classname> to a JDBC CLOB
+ </para>
+ <para>
+ Registered under <literal>clob</literal> and <literal>java.sql.Clob</literal> in the
+ type registry (see <xref linkend="types.registry"/>).
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="types.basic.value.binary">
+ <title>byte[]</title>
+ <variablelist>
+ <varlistentry>
+ <term><classname>org.hibernate.type.BinaryType</classname></term>
+ <listitem>
+ <para>
+ Maps a primitive byte[] to a JDBC VARBINARY
+ </para>
+ <para>
+ Registered under <literal>binary</literal> and <literal>byte[]</literal> in the
+ type registry (see <xref linkend="types.registry"/>).
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><classname>org.hibernate.type.MaterializedBlobType</classname></term>
+ <listitem>
+ <para>
+ Maps a primitive byte[] to a JDBC BLOB
+ </para>
+ <para>
+ Registered under <literal>materialized_blob</literal> in the type registry (see
+ <xref linkend="types.registry"/>).
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="types.basic.value.wrapperbinary">
+ <title>byte[]</title>
+ <variablelist>
+ <varlistentry>
+ <term><classname>org.hibernate.type.BinaryType</classname></term>
+ <listitem>
+ <para>
+ Maps a java.lang.Byte[] to a JDBC VARBINARY
+ </para>
+ <para>
+ Registered under <literal>wrapper-binary</literal>, <literal>Byte[]</literal> and
+ <literal>java.lang.Byte[]</literal> in the type registry (see <xref linkend="types.registry"/>).
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="types.basic.value.chararray">
+ <title>char[]</title>
+ <variablelist>
+ <varlistentry>
+ <term><classname>org.hibernate.type.CharArrayType</classname></term>
+ <listitem>
+ <para>
+ Maps a char[] to a JDBC VARCHAR
+ </para>
+ <para>
+ Registered under <literal>characters</literal> and <literal>char[]</literal>
+ in the type registry (see <xref linkend="types.registry"/>).
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="types.basic.value.characterarray">
+ <title>char[]</title>
+ <variablelist>
+ <varlistentry>
+ <term><classname>org.hibernate.type.CharacterArrayType</classname></term>
+ <listitem>
+ <para>
+ Maps a java.lang.Character[] to a JDBC VARCHAR
+ </para>
+ <para>
+ Registered under <literal>wrapper-characters</literal>, <literal>Character[]</literal>
+ and <literal>java.lang.Character[]</literal> in the type registry (see <xref linkend="types.registry"/>).
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ <section id="types.basic.value.serializable">
+ <title>java.io.Serializable</title>
+ <variablelist>
+ <varlistentry>
+ <term><classname>org.hibernate.type.SerializableType</classname></term>
+ <listitem>
+ <para>
+ Maps implementors of java.lang.Serializable to a JDBC VARBINARY
+ </para>
+ <para>
+ Unlike the other value types, there are multiple instances of this type. It
+ gets registered once under <literal>java.io.Serializable</literal>. Additionally it
+ gets registered under the specific <interfacename>java.io.Serializable</interfacename>
+ implementation class names.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </section>
+ </section>
+
+ <section id="types.value.composite">
+ <title>Composite types</title>
+ <note>
+ <para>
+ The Java Persistence API calls these embedded types, while Hibernate traditionally called them
+ components. Just be aware that both terms are used and mean the same thing in the scope of
+ discussing Hibernate.
+ </para>
+ </note>
+ <para>
+ Components represent aggregations of values into a single Java type. For example, you might have
+ an Address class that aggregates street, city, state, etc information or a Name class that
+ aggregates the parts of a person's Name. In many ways a component looks exactly like an entity. They
+ are both (generally speaking) classes written specifically for the application. They both might have
+ references to other application-specific classes, as well as to collections and simple JDK types. As
+ discussed before, the only distinguishing factory is the fact that a component does not own its own
+ lifecycle.
+ </para>
+ </section>
+
+ <section id="types.value.collection">
+ <title>Collection types</title>
+ <important>
+ <para>
+ It is critical understand that we mean the collection itself, not its contents.
+ The contents of the collection can in turn be basic, component or entity types (though not
+ collections), but the collection itself is owned.
+ </para>
+ </important>
+ <para>
+ Collections are covered in <xref linkend="collections"/>.
+ </para>
+ </section>
+
+ </section>
+
+ <section id="types.entity">
+ <title>Entity types</title>
+ <para>
+ The definition of entities is covered in detail in <xref linkend="persistent-classes"/>. For the purpose of
+ this discussion, it is enough to say that entities are (generally application-specific) classes which
+ correlate to rows in a table. Specifically they correlate to the row by means of a unique identifier.
+ Because of this unique identifier, entities exist independently and define their own lifecycle. As an example,
+ when we delete a <classname>Membership</classname>, both the <classname>User</classname> and
+ <classname>Group</classname> entities remain.
+ <note>
+ <para>
+ This notion of entity independence can be modified by the application developer using the concept of
+ cascades. Cascades allow certain operations to continue (or "cascade") across an association from
+ one entity to another. Cascades are covered in detail in <xref linkend="associations"/>.
+ </para>
+ </note>
+ </para>
+ </section>
+
+ <section id="types.category.significance">
+ <title>Significance of type categories</title>
+ <para>
+ Why do we spend so much time categorizing the various types of types? What is the significance of the
+ distinction?
+ </para>
+ <para>
+ The main categorization was between entity types and value types. To review we said that entities, by
+ nature of their unique identifier, exist independently of other objects whereas values do not. An
+ application cannot "delete" a Product sku; instead, the sku is removed when the Product itself is
+ deleted (obviously you can <emphasis>update</emphasis> the sku of that Product to null to maker it
+ "go away", but even there the access is done through the Product).
+ </para>
+ <para>
+ Nor can you define an association <emphasis>to</emphasis> that Product sku. You <emphasis>can</emphasis>
+ define an association to Product <emphasis>based on</emphasis> its sku, assuming sku is unique but that
+ is totally different.
+
+
+ entity types define
+ data that maintains its own lifecycle, while value types define data that only exists dependently. Essentially it defines it own unique identifier. In turn that means
+ that it can be used to share references to that data from other entities (or components or collections).
+ This dependence/independence has a few important ramifications:
+ <itemizedlist>
+ <listitem>
+ <para>
+ First, entities can be looked up and referenced (as in foreign keys). The same is not true of
+ a value type. For example, a <classname>Product</classname> entity can be looked up by its
+ unique identifier. The sku of that Product
+ </para>
+ </listitem>
+ </itemizedlist>
+ </para>
+ </section>
+
+ <section id="types.custom">
+ <title>Custom types</title>
+ <para>
+ Hibernate makes it relatively easy for developers to create their own <emphasis>value</emphasis> types. For
+ example, you might want to persist properties of type <classname>java.lang.BigInteger</classname> to
+ <literal>VARCHAR</literal> columns. Custom types are not limited to mapping values to a single table
+ column. So, for example, you might want to concatenate together <literal>FIRST_NAME</literal>,
+ <literal>INITIAL</literal> and <literal>SURNAME</literal> columsn into a <classname>java,lang.String</classname>.
+ </para>
+
+ <para>
+ There are 3 approaches to developing a custom Hibernate type. As a means of illustrating the different
+ approaches, lets consider a use case where we need to compose a <classname>java.math.BigDecimal</classname>
+ and <classname>java.util.Currency</classname> together into a custom <classname>Money</classname> class.
+ </para>
+
+ <section id="types.custom.type">
+ <title>Custom types using <interfacename>org.hibernate.type.Type</interfacename></title>
+ <para>
+ The first approach is to directly implement the <interfacename>org.hibernate.type.Type</interfacename>
+ interface (or one of its derivatives). Probably, you will be more interested in the more specific
+ <interfacename>org.hibernate.type.BasicType</interfacename> contract which would allow registration of
+ the type (see <xref linkend="types.registry"/>). The benefit of this registration is that whenever
+ the metadata for a particular property does not specify the Hibernate type to use, Hibernate will
+ consult the registry for the exposed property type. In our example, the property type would be
+ <classname>Money</classname>, which is the key we would use to register our type in the registry:
+ <example id="types.custom.type.ex.definition">
+ <title>Defining and registering the custom Type</title>
+ <programlisting role="JAVA"><![CDATA[public class MoneyType implements BasicType {
+ public String[] getRegistrationKeys() {
+ return new String[] { Money.class.getName() };
+ }
+
+ public int[] sqlTypes(Mapping mapping) {
+ // We will simply use delegation to the standard basic types for BigDecimal and Currency for many of the
+ // Type methods...
+ return new int[] {
+ BigDecimalType.INSTANCE.sqlType(),
+ CurrencyType.INSTANCE.sqlType(),
+ };
+ // we could also have honored any registry overrides via...
+ //return new int[] {
+ // mappings.getTypeResolver().basic( BigDecimal.class.getName() ).sqlTypes( mappings )[0],
+ // mappings.getTypeResolver().basic( Currency.class.getName() ).sqlTypes( mappings )[0]
+ //};
+ }
+
+ public Class getReturnedClass() {
+ return Money.class;
+ }
+
+ public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws SQLException {
+ assert names.length == 2;
+ BigDecimal amount = BigDecimalType.INSTANCE.get( names[0] ); // already handles null check
+ Currency currency = CurrencyType.INSTANCE.get( names[1] ); // already handles null check
+ return amount == null && currency == null
+ ? null
+ : new Money( amount, currency );
+ }
+
+ public void nullSafeSet(PreparedStatement st, Object value, int index, boolean[] settable, SessionImplementor session)
+ throws SQLException {
+ if ( value == null ) {
+ BigDecimalType.INSTANCE.set( st, null, index );
+ CurrencyType.INSTANCE.set( st, null, index+1 );
+ }
+ else {
+ final Money money = (Money) value;
+ BigDecimalType.INSTANCE.set( st, money.getAmount(), index );
+ CurrencyType.INSTANCE.set( st, money.getCurrency(), index+1 );
+ }
+ }
+
+ ...
+}]]></programlisting>
+ <programlisting role="JAVA">
+ Configuration cfg = new Configuration();
+ cfg.registerTypeOverride( new MoneyType() );
+ cfg...;
+ </programlisting>
+ </example>
+ <important>
+ <para>
+ It is important that we registered the type <emphasis>before</emphasis> adding mappings.
+ </para>
+ </important>
+ </para>
+ </section>
+
+ <section id="types.custom.ut">
+ <title>Custom types using <interfacename>org.hibernate.usertype.UserType</interfacename></title>
+ <note>
+ <para>
+ Both <interfacename>org.hibernate.usertype.UserType</interfacename> and
+ <interfacename>org.hibernate.usertype.CompositeUserType</interfacename> were originally
+ added to isolate user code from internal changes to the <interfacename>org.hibernate.type.Type</interfacename>
+ interfaces.
+ </para>
+ </note>
+ <para>
+ The second approach is the use the <interfacename>org.hibernate.usertype.UserType</interfacename>
+ interface, which presents a somewhat simplified view of the <interfacename>org.hibernate.type.Type</interfacename>
+ interface. Using a <interfacename>org.hibernate.usertype.UserType</interfacename>, our
+ <classname>Money</classname> custom type would look as follows:
+ </para>
+ <example id="types.custom.ut.ex.definition">
+ <title>Defining the custom UserType</title>
+ <programlisting role="JAVA"><![CDATA[public class MoneyType implements UserType {
+ public int[] sqlTypes() {
+ return new int[] {
+ BigDecimalType.INSTANCE.sqlType(),
+ CurrencyType.INSTANCE.sqlType(),
+ };
+ }
+
+ public Class getReturnedClass() {
+ return Money.class;
+ }
+
+ public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws SQLException {
+ assert names.length == 2;
+ BigDecimal amount = BigDecimalType.INSTANCE.get( names[0] ); // already handles null check
+ Currency currency = CurrencyType.INSTANCE.get( names[1] ); // already handles null check
+ return amount == null && currency == null
+ ? null
+ : new Money( amount, currency );
+ }
+
+ public void nullSafeSet(PreparedStatement st, Object value, int index) throws SQLException {
+ if ( value == null ) {
+ BigDecimalType.INSTANCE.set( st, null, index );
+ CurrencyType.INSTANCE.set( st, null, index+1 );
+ }
+ else {
+ final Money money = (Money) value;
+ BigDecimalType.INSTANCE.set( st, money.getAmount(), index );
+ CurrencyType.INSTANCE.set( st, money.getCurrency(), index+1 );
+ }
+ }
+
+ ...
+}]]></programlisting>
+ </example>
+ <para>
+ There is not much difference between the <interfacename>org.hibernate.type.Type</interfacename> example
+ and the <interfacename>org.hibernate.usertype.UserType</interfacename> example, but that is only because
+ of the snippets shown. If you choose the <interfacename>org.hibernate.type.Type</interfacename> approach
+ there are quite a few more methods you would need to implement as compared to the
+ <interfacename>org.hibernate.usertype.UserType</interfacename>.
+ </para>
+ </section>
+
+ <section id="types.custom.cut">
+ <title>Custom types using <interfacename>org.hibernate.usertype.CompositeUserType</interfacename></title>
+ <para>
+ The third and final approach is the use the <interfacename>org.hibernate.usertype.CompositeUserType</interfacename>
+ interface, which differs from <interfacename>org.hibernate.usertype.UserType</interfacename> in that it
+ gives us the ability to provide Hibernate the information to handle the composition within the
+ <classname>Money</classname> class (specifically the 2 attributes). THis would give us the capability,
+ for example, to reference the <literal>amount</literal> attribute in an HQL query. Using a
+ <interfacename>org.hibernate.usertype.UserType</interfacename>, our <classname>Money</classname> custom
+ type would look as follows:
+ </para>
+
+ <example id="types.custom.cut.ex.definition">
+ <title>Defining the custom CompositeUserType</title>
+ <programlisting role="JAVA"><![CDATA[public class MoneyType implements CompositeUserType {
+ public String[] getPropertyNames() {
+ // ORDER IS IMPORTANT! it must match the order the columns are defined in the property mapping
+ return new String[] { "amount", "currency" };
+ }
+
+ public Type[] getPropertyTypes() {
+ return new Type[] { BigDecimalType.INSTANCE, CurrencyType.INSTANCE };
+ }
+
+ public Class getReturnedClass() {
+ return Money.class;
+ }
+
+ public Object getPropertyValue(Object component, int propertyIndex) {
+ if ( component == null ) {
+ return null;
+ }
+
+ final Money money = (Money) component;
+ switch ( propertyIndex ) {
+ case 0: {
+ return money.getAmount();
+ }
+ case 1: {
+ return money.getCurrency();
+ }
+ default: {
+ throw new HibernateException( "Invalid property index [" + propertyIndex + "]" );
+ }
+ }
+ }
+
+ public void setPropertyValue(Object component, int propertyIndex, Object value) throws HibernateException {
+ if ( component == null ) {
+ return;
+ }
+
+ final Money money = (Money) component;
+ switch ( propertyIndex ) {
+ case 0: {
+ money.setAmount( (BigDecimal) value );
+ break;
+ }
+ case 1: {
+ money.setCurrency( (Currency) value );
+ break;
+ }
+ default: {
+ throw new HibernateException( "Invalid property index [" + propertyIndex + "]" );
+ }
+ }
+ }
+
+ public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws SQLException {
+ assert names.length == 2;
+ BigDecimal amount = BigDecimalType.INSTANCE.get( names[0] ); // already handles null check
+ Currency currency = CurrencyType.INSTANCE.get( names[1] ); // already handles null check
+ return amount == null && currency == null
+ ? null
+ : new Money( amount, currency );
+ }
+
+ public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws SQLException {
+ if ( value == null ) {
+ BigDecimalType.INSTANCE.set( st, null, index );
+ CurrencyType.INSTANCE.set( st, null, index+1 );
+ }
+ else {
+ final Money money = (Money) value;
+ BigDecimalType.INSTANCE.set( st, money.getAmount(), index );
+ CurrencyType.INSTANCE.set( st, money.getCurrency(), index+1 );
+ }
+ }
+
+ ...
+}]]></programlisting>
+ </example>
+ </section>
+
+ </section>
+
+ <section id="types.registry">
+ <title>Type registry</title>
+ <para>
+ Internally Hibernate uses a registry of basic types (see <xref linkend="types.value.basic"/>) when
+ it needs to resolve the specific <interfacename>org.hibernate.type.Type</interfacename> to use in certain
+ situations. It also provides a way for applications to add extra basic type registrations as well as
+ override the standard basic type registrations.
+ </para>
+ <para>
+ To register a new type or to override an existing type registration, applications would make use of the
+ <methodname>registerTypeOverride</methodname> method of the <classname>org.hibernate.cfg.Configuration</classname>
+ class when bootstrapping Hibernate. For example, lets say you want Hibernate to use your custom
+ <classname>SuperDuperStringType</classname>; during bootstrap you would call:
+ <example id="type.registry.override.ex">
+ <title>Overriding the standard <classname>StringType</classname></title>
+ <programlisting role="JAVA"><![CDATA[Configuration cfg = ...;
+ cfg.registerTypeOverride( new SuperDuperStringType() );]]></programlisting>
+ </example>
+ </para>
+ <para>
+ The argument to <methodname>registerTypeOverride</methodname> is a <interfacename>org.hibernate.type.BasicType</interfacename>
+ which is a specialization of the <interfacename>org.hibernate.type.Type</interfacename> we saw before. It
+ adds a single method:
+ <example>
+ <title>Snippet from BasicType.java</title>
+ <programlisting role="JAVA" >
+ /**
+ * Get the names under which this type should be registered in the type registry.
+ *
+ * @return The keys under which to register this type.
+ */
+ public String[] getRegistrationKeys();
+ </programlisting>
+ </example>
+ One approach is to use inheritance (<classname>SuperDuperStringType</classname> extends
+ <classname>org.hibernate.typeStringType</classname>). Another approach is to use delegation.
+ </para>
+ <important>
+ <para>
+ Currently UserType and CompositeUserType cannot be registered with the registry. See
+ <ulink url="http://opensource.atlassian.com/projects/hibernate/browse/HHH-5262"/> for details.
+ </para>
+ </important>
+ </section>
+
+</chapter>
14 years, 7 months
Hibernate SVN: r19606 - in validator/trunk/hibernate-validator/src: main/java/org/hibernate/validator/cfg/defs and 3 other directories.
by hibernate-commits@lists.jboss.org
Author: hardy.ferentschik
Date: 2010-05-25 14:21:27 -0400 (Tue, 25 May 2010)
New Revision: 19606
Added:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/CascadeDef.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintDef.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/AssertFalseDef.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/AssertTrueDef.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/CreditCardNumberDef.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/DecimalMaxDef.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/DecimalMinDef.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/DigitsDef.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/EmailDef.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/FutureDef.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/LengthDef.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/MaxDef.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/MinDef.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/NotBlankDef.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/NotEmptyDef.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/NotNullDef.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/NullDef.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/PastDef.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/PatternDef.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/RangeDef.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/ScriptAssertDef.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/SizeDef.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/URLDef.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/package.html
Removed:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/AssertFalseDefinition.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/AssertTrueDefinition.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/CascadeDefinition.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintDefinition.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/CreditCardNumberDefinition.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/DecimalMaxDefinition.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/DecimalMinDefinition.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/DigitsDefinition.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/EmailDefinition.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/FutureDefinition.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/LengthDefinition.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/MaxDefinition.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/MinDefinition.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/NotBlankDefinition.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/NotEmptyDefinition.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/NotNullDefinition.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/NullDefinition.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/PastDefinition.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/PatternDefinition.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/RangeDefinition.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ScriptAssertDefinition.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/SizeDefinition.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/URLDefinition.java
Modified:
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintMapping.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintsForType.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/package.html
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/ValidatorFactoryImpl.java
validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/util/privilegedactions/LoadClass.java
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/test/cfg/ConstraintMappingTest.java
Log:
HV-274 Renamed classes and created additional defs package
Deleted: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/AssertFalseDefinition.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/AssertFalseDefinition.java 2010-05-25 16:52:25 UTC (rev 19605)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/AssertFalseDefinition.java 2010-05-25 18:21:27 UTC (rev 19606)
@@ -1,47 +0,0 @@
-// $Id$
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, 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.cfg;
-
-import java.lang.annotation.ElementType;
-import javax.validation.Payload;
-import javax.validation.constraints.AssertFalse;
-import javax.validation.constraints.AssertTrue;
-
-/**
- * @author Hardy Ferentschik
- */
-public class AssertFalseDefinition extends ConstraintDefinition<AssertFalse> {
- public AssertFalseDefinition(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
- super( beanType, AssertFalse.class, property, elementType, mapping );
- }
-
- public AssertFalseDefinition message(String message) {
- addParameter( "message", message );
- return this;
- }
-
- public AssertFalseDefinition groups(Class<?>... groups) {
- addParameter( "groups", groups );
- return this;
- }
-
- public AssertFalseDefinition payload(Class<? extends Payload>... payload) {
- addParameter( "payload", payload );
- return this;
- }
-}
\ No newline at end of file
Deleted: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/AssertTrueDefinition.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/AssertTrueDefinition.java 2010-05-25 16:52:25 UTC (rev 19605)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/AssertTrueDefinition.java 2010-05-25 18:21:27 UTC (rev 19606)
@@ -1,47 +0,0 @@
-// $Id$
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, 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.cfg;
-
-import java.lang.annotation.ElementType;
-import javax.validation.Payload;
-import javax.validation.constraints.AssertTrue;
-import javax.validation.constraints.NotNull;
-
-/**
- * @author Hardy Ferentschik
- */
-public class AssertTrueDefinition extends ConstraintDefinition<AssertTrue> {
- public AssertTrueDefinition(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
- super( beanType, AssertTrue.class, property, elementType, mapping );
- }
-
- public AssertTrueDefinition message(String message) {
- addParameter( "message", message );
- return this;
- }
-
- public AssertTrueDefinition groups(Class<?>... groups) {
- addParameter( "groups", groups );
- return this;
- }
-
- public AssertTrueDefinition payload(Class<? extends Payload>... payload) {
- addParameter( "payload", payload );
- return this;
- }
-}
\ No newline at end of file
Copied: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/CascadeDef.java (from rev 19582, validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/CascadeDefinition.java)
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/CascadeDef.java (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/CascadeDef.java 2010-05-25 18:21:27 UTC (rev 19606)
@@ -0,0 +1,78 @@
+// $Id$
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.cfg;
+
+import java.lang.annotation.ElementType;
+import javax.validation.ValidationException;
+
+import org.hibernate.validator.util.ReflectionHelper;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class CascadeDef {
+ private final Class<?> beanType;
+ private final ElementType elementType;
+ private final String property;
+
+ public CascadeDef(Class<?> beanType, String property, ElementType elementType) {
+ if ( beanType == null ) {
+ throw new ValidationException( "Null is not a valid bean type" );
+ }
+
+ if ( ElementType.FIELD.equals( elementType ) || ElementType.METHOD.equals( elementType ) ) {
+ if ( property == null || property.length() == 0 ) {
+ throw new ValidationException( "A valid property name has to be specified" );
+ }
+
+ if ( !ReflectionHelper.propertyExists( beanType, property, elementType ) ) {
+ throw new ValidationException(
+ "The class " + beanType + " does not have a property '"
+ + property + "' with access " + elementType
+ );
+ }
+ }
+
+ this.beanType = beanType;
+ this.property = property;
+ this.elementType = elementType;
+ }
+
+ public ElementType getElementType() {
+ return elementType;
+ }
+
+ public Class<?> getBeanType() {
+ return beanType;
+ }
+
+ public String getProperty() {
+ return property;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append( "CascadeDefinition" );
+ sb.append( "{beanType=" ).append( beanType );
+ sb.append( ", elementType=" ).append( elementType );
+ sb.append( ", property='" ).append( property ).append( '\'' );
+ sb.append( '}' );
+ return sb.toString();
+ }
+}
\ No newline at end of file
Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/CascadeDef.java
___________________________________________________________________
Name: svn:keywords
+ Id
Deleted: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/CascadeDefinition.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/CascadeDefinition.java 2010-05-25 16:52:25 UTC (rev 19605)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/CascadeDefinition.java 2010-05-25 18:21:27 UTC (rev 19606)
@@ -1,78 +0,0 @@
-// $Id$
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, 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.cfg;
-
-import java.lang.annotation.ElementType;
-import javax.validation.ValidationException;
-
-import org.hibernate.validator.util.ReflectionHelper;
-
-/**
- * @author Hardy Ferentschik
- */
-public class CascadeDefinition {
- private final Class<?> beanType;
- private final ElementType elementType;
- private final String property;
-
- public CascadeDefinition(Class<?> beanType, String property, ElementType elementType) {
- if ( beanType == null ) {
- throw new ValidationException( "Null is not a valid bean type" );
- }
-
- if ( ElementType.FIELD.equals( elementType ) || ElementType.METHOD.equals( elementType ) ) {
- if ( property == null || property.length() == 0 ) {
- throw new ValidationException( "A valid property name has to be specified" );
- }
-
- if ( !ReflectionHelper.propertyExists( beanType, property, elementType ) ) {
- throw new ValidationException(
- "The class " + beanType + " does not have a property '"
- + property + "' with access " + elementType
- );
- }
- }
-
- this.beanType = beanType;
- this.property = property;
- this.elementType = elementType;
- }
-
- public ElementType getElementType() {
- return elementType;
- }
-
- public Class<?> getBeanType() {
- return beanType;
- }
-
- public String getProperty() {
- return property;
- }
-
- @Override
- public String toString() {
- final StringBuilder sb = new StringBuilder();
- sb.append( "CascadeDefinition" );
- sb.append( "{beanType=" ).append( beanType );
- sb.append( ", elementType=" ).append( elementType );
- sb.append( ", property='" ).append( property ).append( '\'' );
- sb.append( '}' );
- return sb.toString();
- }
-}
\ No newline at end of file
Copied: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintDef.java (from rev 19582, validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintDefinition.java)
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintDef.java (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintDef.java 2010-05-25 18:21:27 UTC (rev 19606)
@@ -0,0 +1,138 @@
+// $Id$
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.cfg;
+
+import java.lang.annotation.Annotation;
+import java.lang.annotation.ElementType;
+import java.lang.reflect.Constructor;
+import java.util.HashMap;
+import java.util.Map;
+import javax.validation.ValidationException;
+
+import org.hibernate.validator.util.ReflectionHelper;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class ConstraintDef<A extends Annotation> {
+ private final Class<A> constraintType;
+ private final Map<String, Object> parameters;
+ private final Class<?> beanType;
+ private final ElementType elementType;
+ private final String property;
+ private final ConstraintMapping mapping;
+
+ public ConstraintDef(Class<?> beanType, Class<A> constraintType, String property, ElementType elementType, ConstraintMapping mapping) {
+ if ( beanType == null ) {
+ throw new ValidationException( "Null is not a valid bean type" );
+ }
+
+ if ( constraintType == null ) {
+ throw new ValidationException( "Null is not a valid constraint type" );
+ }
+
+ if ( mapping == null ) {
+ throw new ValidationException( "ConstraintMapping cannot be null" );
+ }
+
+ if ( ElementType.FIELD.equals( elementType ) || ElementType.METHOD.equals( elementType ) ) {
+ if ( property == null || property.length() == 0 ) {
+ throw new ValidationException( "A property level constraint cannot have a null or empty property name" );
+ }
+
+ if ( !ReflectionHelper.propertyExists( beanType, property, elementType ) ) {
+ throw new ValidationException(
+ "The class " + beanType + " does not have a property '"
+ + property + "' with access " + elementType
+ );
+ }
+ }
+
+ this.beanType = beanType;
+ this.constraintType = constraintType;
+ this.parameters = new HashMap<String, Object>();
+ this.property = property;
+ this.elementType = elementType;
+ this.mapping = mapping;
+ }
+
+ protected ConstraintDef addParameter(String key, Object value) {
+ parameters.put( key, value );
+ return this;
+ }
+
+ public <A extends Annotation, T extends ConstraintDef<A>> T constraint(Class<T> definition) {
+
+ final Constructor<T> constructor = ReflectionHelper.getConstructor(
+ definition, Class.class, String.class, ElementType.class, ConstraintMapping.class
+ );
+
+ final T constraintDefinition = ReflectionHelper.newConstructorInstance(
+ constructor, beanType, property, elementType, mapping
+ );
+
+ mapping.addConstraintConfig( constraintDefinition );
+ return constraintDefinition;
+ }
+
+ public ConstraintsForType property(String property, ElementType type) {
+ return new ConstraintsForType( beanType, property, type, mapping );
+ }
+
+ public ConstraintsForType type(Class<?> type) {
+ return new ConstraintsForType( type, mapping );
+ }
+
+ public ConstraintsForType valid(String property, ElementType type) {
+ mapping.addCascadeConfig( new CascadeDef( beanType, property, type ) );
+ return new ConstraintsForType( beanType, mapping );
+ }
+
+ public Class<A> getConstraintType() {
+ return constraintType;
+ }
+
+ public Map<String, Object> getParameters() {
+ return parameters;
+ }
+
+ public ElementType getElementType() {
+ return elementType;
+ }
+
+ public Class<?> getBeanType() {
+ return beanType;
+ }
+
+ public String getProperty() {
+ return property;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append( "ConstraintDefinition" );
+ sb.append( "{beanType=" ).append( beanType );
+ sb.append( ", constraintType=" ).append( constraintType );
+ sb.append( ", parameters=" ).append( parameters );
+ sb.append( ", elementType=" ).append( elementType );
+ sb.append( ", property='" ).append( property ).append( '\'' );
+ sb.append( '}' );
+ return sb.toString();
+ }
+}
Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintDef.java
___________________________________________________________________
Name: svn:keywords
+ Id
Deleted: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintDefinition.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintDefinition.java 2010-05-25 16:52:25 UTC (rev 19605)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintDefinition.java 2010-05-25 18:21:27 UTC (rev 19606)
@@ -1,138 +0,0 @@
-// $Id$
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, 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.cfg;
-
-import java.lang.annotation.Annotation;
-import java.lang.annotation.ElementType;
-import java.lang.reflect.Constructor;
-import java.util.HashMap;
-import java.util.Map;
-import javax.validation.ValidationException;
-
-import org.hibernate.validator.util.ReflectionHelper;
-
-/**
- * @author Hardy Ferentschik
- */
-public class ConstraintDefinition<A extends Annotation> {
- private final Class<A> constraintType;
- private final Map<String, Object> parameters;
- private final Class<?> beanType;
- private final ElementType elementType;
- private final String property;
- private final ConstraintMapping mapping;
-
- public ConstraintDefinition(Class<?> beanType, Class<A> constraintType, String property, ElementType elementType, ConstraintMapping mapping) {
- if ( beanType == null ) {
- throw new ValidationException( "Null is not a valid bean type" );
- }
-
- if ( constraintType == null ) {
- throw new ValidationException( "Null is not a valid constraint type" );
- }
-
- if ( mapping == null ) {
- throw new ValidationException( "ConstraintMapping cannot be null" );
- }
-
- if ( ElementType.FIELD.equals( elementType ) || ElementType.METHOD.equals( elementType ) ) {
- if ( property == null || property.length() == 0 ) {
- throw new ValidationException( "A property level constraint cannot have a null or empty property name" );
- }
-
- if ( !ReflectionHelper.propertyExists( beanType, property, elementType ) ) {
- throw new ValidationException(
- "The class " + beanType + " does not have a property '"
- + property + "' with access " + elementType
- );
- }
- }
-
- this.beanType = beanType;
- this.constraintType = constraintType;
- this.parameters = new HashMap<String, Object>();
- this.property = property;
- this.elementType = elementType;
- this.mapping = mapping;
- }
-
- protected ConstraintDefinition addParameter(String key, Object value) {
- parameters.put( key, value );
- return this;
- }
-
- public <A extends Annotation, T extends ConstraintDefinition<A>> T constraint(Class<T> definition) {
-
- final Constructor<T> constructor = ReflectionHelper.getConstructor(
- definition, Class.class, String.class, ElementType.class, ConstraintMapping.class
- );
-
- final T constraintDefinition = ReflectionHelper.newConstructorInstance(
- constructor, beanType, property, elementType, mapping
- );
-
- mapping.addConstraintConfig( constraintDefinition );
- return constraintDefinition;
- }
-
- public ConstraintsForType property(String property, ElementType type) {
- return new ConstraintsForType( beanType, property, type, mapping );
- }
-
- public ConstraintsForType type(Class<?> type) {
- return new ConstraintsForType( type, mapping );
- }
-
- public ConstraintsForType valid(String property, ElementType type) {
- mapping.addCascadeConfig( new CascadeDefinition( beanType, property, type ) );
- return new ConstraintsForType( beanType, mapping );
- }
-
- public Class<A> getConstraintType() {
- return constraintType;
- }
-
- public Map<String, Object> getParameters() {
- return parameters;
- }
-
- public ElementType getElementType() {
- return elementType;
- }
-
- public Class<?> getBeanType() {
- return beanType;
- }
-
- public String getProperty() {
- return property;
- }
-
- @Override
- public String toString() {
- final StringBuilder sb = new StringBuilder();
- sb.append( "ConstraintDefinition" );
- sb.append( "{beanType=" ).append( beanType );
- sb.append( ", constraintType=" ).append( constraintType );
- sb.append( ", parameters=" ).append( parameters );
- sb.append( ", elementType=" ).append( elementType );
- sb.append( ", property='" ).append( property ).append( '\'' );
- sb.append( '}' );
- return sb.toString();
- }
-}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintMapping.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintMapping.java 2010-05-25 16:52:25 UTC (rev 19605)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintMapping.java 2010-05-25 18:21:27 UTC (rev 19606)
@@ -32,14 +32,14 @@
* @author Hardy Ferentschik
*/
public class ConstraintMapping {
- private final Map<Class<?>, List<ConstraintDefinition<?>>> constraintConfig;
- private final Map<Class<?>, List<CascadeDefinition>> cascadeConfig;
+ private final Map<Class<?>, List<ConstraintDef<?>>> constraintConfig;
+ private final Map<Class<?>, List<CascadeDef>> cascadeConfig;
private final Set<Class<?>> configuredClasses;
private final Map<Class<?>, List<Class<?>>> defaultGroupSequences;
public ConstraintMapping() {
- this.constraintConfig = new HashMap<Class<?>, List<ConstraintDefinition<?>>>();
- this.cascadeConfig = new HashMap<Class<?>, List<CascadeDefinition>>();
+ this.constraintConfig = new HashMap<Class<?>, List<ConstraintDef<?>>>();
+ this.cascadeConfig = new HashMap<Class<?>, List<CascadeDef>>();
this.configuredClasses = new HashSet<Class<?>>();
this.defaultGroupSequences = new HashMap<Class<?>, List<Class<?>>>();
}
@@ -48,27 +48,27 @@
return new ConstraintsForType( beanClass, this );
}
- protected void addConstraintConfig(ConstraintDefinition<?> definition) {
+ protected void addConstraintConfig(ConstraintDef<?> definition) {
Class<?> beanClass = definition.getBeanType();
configuredClasses.add( beanClass );
if ( constraintConfig.containsKey( beanClass ) ) {
constraintConfig.get( beanClass ).add( definition );
}
else {
- List<ConstraintDefinition<?>> definitionList = new ArrayList<ConstraintDefinition<?>>();
+ List<ConstraintDef<?>> definitionList = new ArrayList<ConstraintDef<?>>();
definitionList.add( definition );
constraintConfig.put( beanClass, definitionList );
}
}
- protected void addCascadeConfig(CascadeDefinition cascade) {
+ protected void addCascadeConfig(CascadeDef cascade) {
Class<?> beanClass = cascade.getBeanType();
configuredClasses.add( beanClass );
if ( cascadeConfig.containsKey( beanClass ) ) {
cascadeConfig.get( beanClass ).add( cascade );
}
else {
- List<CascadeDefinition> cascadeList = new ArrayList<CascadeDefinition>();
+ List<CascadeDef> cascadeList = new ArrayList<CascadeDef>();
cascadeList.add( cascade );
cascadeConfig.put( beanClass, cascadeList );
}
@@ -78,11 +78,11 @@
defaultGroupSequences.put( beanClass, defaultGroupSequence );
}
- public Map<Class<?>, List<ConstraintDefinition<?>>> getConstraintConfig() {
+ public Map<Class<?>, List<ConstraintDef<?>>> getConstraintConfig() {
return constraintConfig;
}
- public Map<Class<?>, List<CascadeDefinition>> getCascadeConfig() {
+ public Map<Class<?>, List<CascadeDef>> getCascadeConfig() {
return cascadeConfig;
}
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintsForType.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintsForType.java 2010-05-25 16:52:25 UTC (rev 19605)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ConstraintsForType.java 2010-05-25 18:21:27 UTC (rev 19606)
@@ -48,7 +48,7 @@
this.elementType = type;
}
- public <A extends Annotation, T extends ConstraintDefinition<A>> T constraint(Class<T> definition) {
+ public <A extends Annotation, T extends ConstraintDef<A>> T constraint(Class<T> definition) {
final Constructor<T> constructor = ReflectionHelper.getConstructor(
definition, Class.class, String.class, ElementType.class, ConstraintMapping.class
);
@@ -65,7 +65,7 @@
}
public ConstraintsForType valid(String property, ElementType type) {
- mapping.addCascadeConfig( new CascadeDefinition( beanClass, property, type ) );
+ mapping.addCascadeConfig( new CascadeDef( beanClass, property, type ) );
return this;
}
Deleted: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/CreditCardNumberDefinition.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/CreditCardNumberDefinition.java 2010-05-25 16:52:25 UTC (rev 19605)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/CreditCardNumberDefinition.java 2010-05-25 18:21:27 UTC (rev 19606)
@@ -1,48 +0,0 @@
-// $Id$
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, 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.cfg;
-
-import java.lang.annotation.ElementType;
-import javax.validation.Payload;
-
-import org.hibernate.validator.constraints.CreditCardNumber;
-
-/**
- * @author Hardy Ferentschik
- */
-public class CreditCardNumberDefinition extends ConstraintDefinition<CreditCardNumber> {
- public CreditCardNumberDefinition(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
- super( beanType, CreditCardNumber.class, property, elementType, mapping );
- }
-
- public CreditCardNumberDefinition message(String message) {
- addParameter( "message", message );
- return this;
- }
-
- public CreditCardNumberDefinition groups(Class<?>... groups) {
- addParameter( "groups", groups );
- return this;
- }
-
- public CreditCardNumberDefinition payload(Class<? extends Payload>... payload) {
- addParameter( "payload", payload );
- return this;
- }
-}
\ No newline at end of file
Deleted: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/DecimalMaxDefinition.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/DecimalMaxDefinition.java 2010-05-25 16:52:25 UTC (rev 19605)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/DecimalMaxDefinition.java 2010-05-25 18:21:27 UTC (rev 19606)
@@ -1,53 +0,0 @@
-// $Id$
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, 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.cfg;
-
-import java.lang.annotation.ElementType;
-import javax.validation.Payload;
-import javax.validation.constraints.DecimalMax;
-
-/**
- * @author Hardy Ferentschik
- */
-public class DecimalMaxDefinition extends ConstraintDefinition<DecimalMax> {
-
- public DecimalMaxDefinition(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
- super( beanType, DecimalMax.class, property, elementType, mapping );
- }
-
- public DecimalMaxDefinition message(String message) {
- addParameter( "message", message );
- return this;
- }
-
- public DecimalMaxDefinition groups(Class<?>... groups) {
- addParameter( "groups", groups );
- return this;
- }
-
- public DecimalMaxDefinition payload(Class<? extends Payload>... payload) {
- addParameter( "payload", payload );
- return this;
- }
-
- public DecimalMaxDefinition value(String max) {
- addParameter( "value", max );
- return this;
- }
-}
\ No newline at end of file
Deleted: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/DecimalMinDefinition.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/DecimalMinDefinition.java 2010-05-25 16:52:25 UTC (rev 19605)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/DecimalMinDefinition.java 2010-05-25 18:21:27 UTC (rev 19606)
@@ -1,52 +0,0 @@
-// $Id$
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, 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.cfg;
-
-import java.lang.annotation.ElementType;
-import javax.validation.Payload;
-import javax.validation.constraints.DecimalMin;
-
-/**
- * @author Hardy Ferentschik
- */
-public class DecimalMinDefinition extends ConstraintDefinition<DecimalMin> {
-
- public DecimalMinDefinition(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
- super( beanType, DecimalMin.class, property, elementType, mapping );
- }
-
- public DecimalMinDefinition message(String message) {
- addParameter( "message", message );
- return this;
- }
-
- public DecimalMinDefinition groups(Class<?>... groups) {
- addParameter( "groups", groups );
- return this;
- }
-
- public DecimalMinDefinition payload(Class<? extends Payload>... payload) {
- addParameter( "payload", payload );
- return this;
- }
-
- public DecimalMinDefinition value(String min) {
- addParameter( "value", min );
- return this;
- }
-}
\ No newline at end of file
Deleted: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/DigitsDefinition.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/DigitsDefinition.java 2010-05-25 16:52:25 UTC (rev 19605)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/DigitsDefinition.java 2010-05-25 18:21:27 UTC (rev 19606)
@@ -1,58 +0,0 @@
-// $Id$
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, 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.cfg;
-
-import java.lang.annotation.ElementType;
-import javax.validation.Payload;
-import javax.validation.constraints.Digits;
-
-
-/**
- * @author Hardy Ferentschik
- */
-public class DigitsDefinition extends ConstraintDefinition<Digits> {
-
- public DigitsDefinition(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
- super( beanType, Digits.class, property, elementType, mapping );
- }
-
- public DigitsDefinition message(String message) {
- addParameter( "message", message );
- return this;
- }
-
- public DigitsDefinition groups(Class<?>... groups) {
- addParameter( "groups", groups );
- return this;
- }
-
- public DigitsDefinition payload(Class<? extends Payload>... payload) {
- addParameter( "payload", payload );
- return this;
- }
-
- public DigitsDefinition integer(int integer) {
- addParameter( "integer", integer );
- return this;
- }
-
- public DigitsDefinition fraction(int fraction) {
- addParameter( "fraction", fraction );
- return this;
- }
-}
\ No newline at end of file
Deleted: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/EmailDefinition.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/EmailDefinition.java 2010-05-25 16:52:25 UTC (rev 19605)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/EmailDefinition.java 2010-05-25 18:21:27 UTC (rev 19606)
@@ -1,48 +0,0 @@
-// $Id$
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, 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.cfg;
-
-import java.lang.annotation.ElementType;
-import javax.validation.Payload;
-
-import org.hibernate.validator.constraints.Email;
-
-/**
- * @author Hardy Ferentschik
- */
-public class EmailDefinition extends ConstraintDefinition<Email> {
- public EmailDefinition(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
- super( beanType, Email.class, property, elementType, mapping );
- }
-
- public EmailDefinition message(String message) {
- addParameter( "message", message );
- return this;
- }
-
- public EmailDefinition groups(Class<?>... groups) {
- addParameter( "groups", groups );
- return this;
- }
-
- public EmailDefinition payload(Class<? extends Payload>... payload) {
- addParameter( "payload", payload );
- return this;
- }
-}
\ No newline at end of file
Deleted: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/FutureDefinition.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/FutureDefinition.java 2010-05-25 16:52:25 UTC (rev 19605)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/FutureDefinition.java 2010-05-25 18:21:27 UTC (rev 19606)
@@ -1,46 +0,0 @@
-// $Id$
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, 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.cfg;
-
-import java.lang.annotation.ElementType;
-import javax.validation.Payload;
-import javax.validation.constraints.Future;
-
-/**
- * @author Hardy Ferentschik
- */
-public class FutureDefinition extends ConstraintDefinition<Future> {
- public FutureDefinition(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
- super( beanType, Future.class, property, elementType, mapping );
- }
-
- public FutureDefinition message(String message) {
- addParameter( "message", message );
- return this;
- }
-
- public FutureDefinition groups(Class<?>... groups) {
- addParameter( "groups", groups );
- return this;
- }
-
- public FutureDefinition payload(Class<? extends Payload>... payload) {
- addParameter( "payload", payload );
- return this;
- }
-}
\ No newline at end of file
Deleted: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/LengthDefinition.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/LengthDefinition.java 2010-05-25 16:52:25 UTC (rev 19605)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/LengthDefinition.java 2010-05-25 18:21:27 UTC (rev 19606)
@@ -1,60 +0,0 @@
-// $Id$
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, 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.cfg;
-
-import java.lang.annotation.ElementType;
-import javax.validation.Payload;
-
-import org.hibernate.validator.constraints.Length;
-
-
-/**
- * @author Hardy Ferentschik
- */
-public class LengthDefinition extends ConstraintDefinition<Length> {
-
- public LengthDefinition(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
- super( beanType, Length.class, property, elementType, mapping );
- }
-
- public LengthDefinition message(String message) {
- addParameter( "message", message );
- return this;
- }
-
- public LengthDefinition groups(Class<?>... groups) {
- addParameter( "groups", groups );
- return this;
- }
-
- public LengthDefinition payload(Class<? extends Payload>... payload) {
- addParameter( "payload", payload );
- return this;
- }
-
- public LengthDefinition min(int min) {
- addParameter( "min", min );
- return this;
- }
-
- public LengthDefinition max(int max) {
- addParameter( "max", max );
- return this;
- }
-}
\ No newline at end of file
Deleted: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/MaxDefinition.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/MaxDefinition.java 2010-05-25 16:52:25 UTC (rev 19605)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/MaxDefinition.java 2010-05-25 18:21:27 UTC (rev 19606)
@@ -1,52 +0,0 @@
-// $Id$
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, 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.cfg;
-
-import java.lang.annotation.ElementType;
-import javax.validation.Payload;
-import javax.validation.constraints.Max;
-
-/**
- * @author Hardy Ferentschik
- */
-public class MaxDefinition extends ConstraintDefinition<Max> {
-
- public MaxDefinition(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
- super( beanType, Max.class, property, elementType, mapping );
- }
-
- public MaxDefinition message(String message) {
- addParameter( "message", message );
- return this;
- }
-
- public MaxDefinition groups(Class<?>... groups) {
- addParameter( "groups", groups );
- return this;
- }
-
- public MaxDefinition payload(Class<? extends Payload>... payload) {
- addParameter( "payload", payload );
- return this;
- }
-
- public MaxDefinition value(long max) {
- addParameter( "value", max );
- return this;
- }
-}
\ No newline at end of file
Deleted: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/MinDefinition.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/MinDefinition.java 2010-05-25 16:52:25 UTC (rev 19605)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/MinDefinition.java 2010-05-25 18:21:27 UTC (rev 19606)
@@ -1,52 +0,0 @@
-// $Id:$
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, 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.cfg;
-
-import java.lang.annotation.ElementType;
-import javax.validation.Payload;
-import javax.validation.constraints.Min;
-
-/**
- * @author Hardy Ferentschik
- */
-public class MinDefinition extends ConstraintDefinition<Min> {
-
- public MinDefinition(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
- super( beanType, Min.class, property, elementType, mapping );
- }
-
- public MinDefinition message(String message) {
- addParameter( "message", message );
- return this;
- }
-
- public MinDefinition groups(Class<?>... groups) {
- addParameter( "groups", groups );
- return this;
- }
-
- public MinDefinition payload(Class<? extends Payload>... payload) {
- addParameter( "payload", payload );
- return this;
- }
-
- public MinDefinition value(long min) {
- addParameter( "value", min );
- return this;
- }
-}
\ No newline at end of file
Deleted: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/NotBlankDefinition.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/NotBlankDefinition.java 2010-05-25 16:52:25 UTC (rev 19605)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/NotBlankDefinition.java 2010-05-25 18:21:27 UTC (rev 19606)
@@ -1,47 +0,0 @@
-// $Id$
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, 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.cfg;
-
-import java.lang.annotation.ElementType;
-import javax.validation.Payload;
-
-import org.hibernate.validator.constraints.NotBlank;
-
-/**
- * @author Hardy Ferentschik
- */
-public class NotBlankDefinition extends ConstraintDefinition<NotBlank> {
- public NotBlankDefinition(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
- super( beanType, NotBlank.class, property, elementType, mapping );
- }
-
- public NotBlankDefinition message(String message) {
- addParameter( "message", message );
- return this;
- }
-
- public NotBlankDefinition groups(Class<?>... groups) {
- addParameter( "groups", groups );
- return this;
- }
-
- public NotBlankDefinition payload(Class<? extends Payload>... payload) {
- addParameter( "payload", payload );
- return this;
- }
-}
\ No newline at end of file
Deleted: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/NotEmptyDefinition.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/NotEmptyDefinition.java 2010-05-25 16:52:25 UTC (rev 19605)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/NotEmptyDefinition.java 2010-05-25 18:21:27 UTC (rev 19606)
@@ -1,47 +0,0 @@
-// $Id$
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, 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.cfg;
-
-import java.lang.annotation.ElementType;
-import javax.validation.Payload;
-
-import org.hibernate.validator.constraints.NotEmpty;
-
-/**
- * @author Hardy Ferentschik
- */
-public class NotEmptyDefinition extends ConstraintDefinition<NotEmpty> {
- public NotEmptyDefinition(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
- super( beanType, NotEmpty.class, property, elementType, mapping );
- }
-
- public NotEmptyDefinition message(String message) {
- addParameter( "message", message );
- return this;
- }
-
- public NotEmptyDefinition groups(Class<?>... groups) {
- addParameter( "groups", groups );
- return this;
- }
-
- public NotEmptyDefinition payload(Class<? extends Payload>... payload) {
- addParameter( "payload", payload );
- return this;
- }
-}
\ No newline at end of file
Deleted: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/NotNullDefinition.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/NotNullDefinition.java 2010-05-25 16:52:25 UTC (rev 19605)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/NotNullDefinition.java 2010-05-25 18:21:27 UTC (rev 19606)
@@ -1,46 +0,0 @@
-// $Id:$
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, 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.cfg;
-
-import java.lang.annotation.ElementType;
-import javax.validation.Payload;
-import javax.validation.constraints.NotNull;
-
-/**
- * @author Hardy Ferentschik
- */
-public class NotNullDefinition extends ConstraintDefinition<NotNull> {
- public NotNullDefinition(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
- super( beanType, NotNull.class, property, elementType, mapping );
- }
-
- public NotNullDefinition message(String message) {
- addParameter( "message", message );
- return this;
- }
-
- public NotNullDefinition groups(Class<?>... groups) {
- addParameter( "groups", groups );
- return this;
- }
-
- public NotNullDefinition payload(Class<? extends Payload>... payload) {
- addParameter( "payload", payload );
- return this;
- }
-}
\ No newline at end of file
Deleted: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/NullDefinition.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/NullDefinition.java 2010-05-25 16:52:25 UTC (rev 19605)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/NullDefinition.java 2010-05-25 18:21:27 UTC (rev 19606)
@@ -1,46 +0,0 @@
-// $Id$
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, 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.cfg;
-
-import java.lang.annotation.ElementType;
-import javax.validation.Payload;
-import javax.validation.constraints.Null;
-
-/**
- * @author Hardy Ferentschik
- */
-public class NullDefinition extends ConstraintDefinition<Null> {
- public NullDefinition(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
- super( beanType, Null.class, property, elementType, mapping );
- }
-
- public NullDefinition message(String message) {
- addParameter( "message", message );
- return this;
- }
-
- public NullDefinition groups(Class<?>... groups) {
- addParameter( "groups", groups );
- return this;
- }
-
- public NullDefinition payload(Class<? extends Payload>... payload) {
- addParameter( "payload", payload );
- return this;
- }
-}
\ No newline at end of file
Deleted: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/PastDefinition.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/PastDefinition.java 2010-05-25 16:52:25 UTC (rev 19605)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/PastDefinition.java 2010-05-25 18:21:27 UTC (rev 19606)
@@ -1,47 +0,0 @@
-// $Id$
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, 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.cfg;
-
-import java.lang.annotation.ElementType;
-import javax.validation.Payload;
-import javax.validation.constraints.Future;
-import javax.validation.constraints.Past;
-
-/**
- * @author Hardy Ferentschik
- */
-public class PastDefinition extends ConstraintDefinition<Past> {
- public PastDefinition(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
- super( beanType, Past.class, property, elementType, mapping );
- }
-
- public PastDefinition message(String message) {
- addParameter( "message", message );
- return this;
- }
-
- public PastDefinition groups(Class<?>... groups) {
- addParameter( "groups", groups );
- return this;
- }
-
- public PastDefinition payload(Class<? extends Payload>... payload) {
- addParameter( "payload", payload );
- return this;
- }
-}
\ No newline at end of file
Deleted: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/PatternDefinition.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/PatternDefinition.java 2010-05-25 16:52:25 UTC (rev 19605)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/PatternDefinition.java 2010-05-25 18:21:27 UTC (rev 19606)
@@ -1,58 +0,0 @@
-// $Id:$
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, 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.cfg;
-
-import java.lang.annotation.ElementType;
-import javax.validation.Payload;
-import javax.validation.constraints.Pattern;
-
-
-/**
- * @author Hardy Ferentschik
- */
-public class PatternDefinition extends ConstraintDefinition<Pattern> {
-
- public PatternDefinition(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
- super( beanType, Pattern.class, property, elementType, mapping );
- }
-
- public PatternDefinition message(String message) {
- addParameter( "message", message );
- return this;
- }
-
- public PatternDefinition groups(Class<?>... groups) {
- addParameter( "groups", groups );
- return this;
- }
-
- public PatternDefinition payload(Class<? extends Payload>... payload) {
- addParameter( "payload", payload );
- return this;
- }
-
- public PatternDefinition flags(Pattern.Flag[] flags) {
- addParameter( "flags", flags );
- return this;
- }
-
- public PatternDefinition regexp(String regexp) {
- addParameter( "regexp", regexp );
- return this;
- }
-}
\ No newline at end of file
Deleted: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/RangeDefinition.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/RangeDefinition.java 2010-05-25 16:52:25 UTC (rev 19605)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/RangeDefinition.java 2010-05-25 18:21:27 UTC (rev 19606)
@@ -1,58 +0,0 @@
-// $Id$
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, 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.cfg;
-
-import java.lang.annotation.ElementType;
-import javax.validation.Payload;
-
-import org.hibernate.validator.constraints.Range;
-
-/**
- * @author Hardy Ferentschik
- */
-public class RangeDefinition extends ConstraintDefinition<Range> {
-
- public RangeDefinition(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
- super( beanType, Range.class, property, elementType, mapping );
- }
-
- public RangeDefinition message(String message) {
- addParameter( "message", message );
- return this;
- }
-
- public RangeDefinition groups(Class<?>... groups) {
- addParameter( "groups", groups );
- return this;
- }
-
- public RangeDefinition payload(Class<? extends Payload>... payload) {
- addParameter( "payload", payload );
- return this;
- }
-
- public RangeDefinition min(long min) {
- addParameter( "value", min );
- return this;
- }
-
- public RangeDefinition max(long max) {
- addParameter( "value", max );
- return this;
- }
-}
\ No newline at end of file
Deleted: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ScriptAssertDefinition.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ScriptAssertDefinition.java 2010-05-25 16:52:25 UTC (rev 19605)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ScriptAssertDefinition.java 2010-05-25 18:21:27 UTC (rev 19606)
@@ -1,63 +0,0 @@
-// $Id$
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, 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.cfg;
-
-import java.lang.annotation.ElementType;
-import javax.validation.Payload;
-
-import org.hibernate.validator.constraints.ScriptAssert;
-
-/**
- * @author Hardy Ferentschik
- */
-public class ScriptAssertDefinition extends ConstraintDefinition<ScriptAssert> {
-
- public ScriptAssertDefinition(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
- super( beanType, ScriptAssert.class, property, elementType, mapping );
- }
-
- public ScriptAssertDefinition message(String message) {
- addParameter( "message", message );
- return this;
- }
-
- public ScriptAssertDefinition groups(Class<?>... groups) {
- addParameter( "groups", groups );
- return this;
- }
-
- public ScriptAssertDefinition payload(Class<? extends Payload>... payload) {
- addParameter( "payload", payload );
- return this;
- }
-
- public ScriptAssertDefinition lang(String lang) {
- addParameter( "lang", lang );
- return this;
- }
-
- public ScriptAssertDefinition script(String script) {
- addParameter( "script", script );
- return this;
- }
-
- public ScriptAssertDefinition alias(String alias) {
- addParameter( "alias", alias );
- return this;
- }
-}
\ No newline at end of file
Deleted: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/SizeDefinition.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/SizeDefinition.java 2010-05-25 16:52:25 UTC (rev 19605)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/SizeDefinition.java 2010-05-25 18:21:27 UTC (rev 19606)
@@ -1,60 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, 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.
- */
-
-// $Id:$
-package org.hibernate.validator.cfg;
-
-import java.lang.annotation.ElementType;
-import javax.validation.Payload;
-import javax.validation.constraints.Size;
-
-/**
- * @author Hardy Ferentschik
- */
-public class SizeDefinition extends ConstraintDefinition<Size> {
-
- public SizeDefinition(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
- super( beanType, Size.class, property, elementType, mapping );
- }
-
- public SizeDefinition message(String message) {
- addParameter( "message", message );
- return this;
- }
-
- public SizeDefinition groups(Class<?>... groups) {
- addParameter( "groups", groups );
- return this;
- }
-
- public SizeDefinition payload(Class<? extends Payload>... payload) {
- addParameter( "payload", payload );
- return this;
- }
-
- public SizeDefinition min(int min) {
- addParameter( "min", min );
- return this;
- }
-
- public SizeDefinition max(int max) {
- addParameter( "max", max );
- return this;
- }
-}
-
-
Deleted: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/URLDefinition.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/URLDefinition.java 2010-05-25 16:52:25 UTC (rev 19605)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/URLDefinition.java 2010-05-25 18:21:27 UTC (rev 19606)
@@ -1,62 +0,0 @@
-// $Id$
-/* JBoss, Home of Professional Open Source
- * Copyright 2010, 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.cfg;
-
-import java.lang.annotation.ElementType;
-import javax.validation.Payload;
-
-import org.hibernate.validator.constraints.URL;
-
-/**
- * @author Hardy Ferentschik
- */
-public class URLDefinition extends ConstraintDefinition<URL> {
-
- public URLDefinition(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
- super( beanType, URL.class, property, elementType, mapping );
- }
-
- public URLDefinition message(String message) {
- addParameter( "message", message );
- return this;
- }
-
- public URLDefinition groups(Class<?>... groups) {
- addParameter( "groups", groups );
- return this;
- }
-
- public URLDefinition payload(Class<? extends Payload>... payload) {
- addParameter( "payload", payload );
- return this;
- }
-
- public URLDefinition protocol(String protocol) {
- addParameter( "protocol", protocol );
- return this;
- }
-
- public URLDefinition host(String host) {
- addParameter( "host", host );
- return this;
- }
-
- public URLDefinition port(int port) {
- addParameter( "port", port );
- return this;
- }
-}
\ No newline at end of file
Copied: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/AssertFalseDef.java (from rev 19596, validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/AssertFalseDefinition.java)
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/AssertFalseDef.java (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/AssertFalseDef.java 2010-05-25 18:21:27 UTC (rev 19606)
@@ -0,0 +1,49 @@
+// $Id$
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.cfg.defs;
+
+import java.lang.annotation.ElementType;
+import javax.validation.Payload;
+import javax.validation.constraints.AssertFalse;
+
+import org.hibernate.validator.cfg.ConstraintDef;
+import org.hibernate.validator.cfg.ConstraintMapping;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class AssertFalseDef extends ConstraintDef<AssertFalse> {
+ public AssertFalseDef(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
+ super( beanType, AssertFalse.class, property, elementType, mapping );
+ }
+
+ public AssertFalseDef message(String message) {
+ addParameter( "message", message );
+ return this;
+ }
+
+ public AssertFalseDef groups(Class<?>... groups) {
+ addParameter( "groups", groups );
+ return this;
+ }
+
+ public AssertFalseDef payload(Class<? extends Payload>... payload) {
+ addParameter( "payload", payload );
+ return this;
+ }
+}
\ No newline at end of file
Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/AssertFalseDef.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/AssertTrueDef.java (from rev 19582, validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/AssertTrueDefinition.java)
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/AssertTrueDef.java (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/AssertTrueDef.java 2010-05-25 18:21:27 UTC (rev 19606)
@@ -0,0 +1,49 @@
+// $Id$
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.cfg.defs;
+
+import java.lang.annotation.ElementType;
+import javax.validation.Payload;
+import javax.validation.constraints.AssertTrue;
+
+import org.hibernate.validator.cfg.ConstraintDef;
+import org.hibernate.validator.cfg.ConstraintMapping;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class AssertTrueDef extends ConstraintDef<AssertTrue> {
+ public AssertTrueDef(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
+ super( beanType, AssertTrue.class, property, elementType, mapping );
+ }
+
+ public AssertTrueDef message(String message) {
+ addParameter( "message", message );
+ return this;
+ }
+
+ public AssertTrueDef groups(Class<?>... groups) {
+ addParameter( "groups", groups );
+ return this;
+ }
+
+ public AssertTrueDef payload(Class<? extends Payload>... payload) {
+ addParameter( "payload", payload );
+ return this;
+ }
+}
\ No newline at end of file
Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/AssertTrueDef.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/CreditCardNumberDef.java (from rev 19596, validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/CreditCardNumberDefinition.java)
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/CreditCardNumberDef.java (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/CreditCardNumberDef.java 2010-05-25 18:21:27 UTC (rev 19606)
@@ -0,0 +1,50 @@
+// $Id$
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.cfg.defs;
+
+import java.lang.annotation.ElementType;
+import javax.validation.Payload;
+
+import org.hibernate.validator.cfg.ConstraintDef;
+import org.hibernate.validator.cfg.ConstraintMapping;
+import org.hibernate.validator.constraints.CreditCardNumber;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class CreditCardNumberDef extends ConstraintDef<CreditCardNumber> {
+ public CreditCardNumberDef(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
+ super( beanType, CreditCardNumber.class, property, elementType, mapping );
+ }
+
+ public CreditCardNumberDef message(String message) {
+ addParameter( "message", message );
+ return this;
+ }
+
+ public CreditCardNumberDef groups(Class<?>... groups) {
+ addParameter( "groups", groups );
+ return this;
+ }
+
+ public CreditCardNumberDef payload(Class<? extends Payload>... payload) {
+ addParameter( "payload", payload );
+ return this;
+ }
+}
\ No newline at end of file
Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/CreditCardNumberDef.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/DecimalMaxDef.java (from rev 19596, validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/DecimalMaxDefinition.java)
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/DecimalMaxDef.java (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/DecimalMaxDef.java 2010-05-25 18:21:27 UTC (rev 19606)
@@ -0,0 +1,56 @@
+// $Id$
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.cfg.defs;
+
+import java.lang.annotation.ElementType;
+import javax.validation.Payload;
+import javax.validation.constraints.DecimalMax;
+
+import org.hibernate.validator.cfg.ConstraintDef;
+import org.hibernate.validator.cfg.ConstraintMapping;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class DecimalMaxDef extends ConstraintDef<DecimalMax> {
+
+ public DecimalMaxDef(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
+ super( beanType, DecimalMax.class, property, elementType, mapping );
+ }
+
+ public DecimalMaxDef message(String message) {
+ addParameter( "message", message );
+ return this;
+ }
+
+ public DecimalMaxDef groups(Class<?>... groups) {
+ addParameter( "groups", groups );
+ return this;
+ }
+
+ public DecimalMaxDef payload(Class<? extends Payload>... payload) {
+ addParameter( "payload", payload );
+ return this;
+ }
+
+ public DecimalMaxDef value(String max) {
+ addParameter( "value", max );
+ return this;
+ }
+}
\ No newline at end of file
Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/DecimalMaxDef.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/DecimalMinDef.java (from rev 19596, validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/DecimalMinDefinition.java)
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/DecimalMinDef.java (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/DecimalMinDef.java 2010-05-25 18:21:27 UTC (rev 19606)
@@ -0,0 +1,55 @@
+// $Id$
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.cfg.defs;
+
+import java.lang.annotation.ElementType;
+import javax.validation.Payload;
+import javax.validation.constraints.DecimalMin;
+
+import org.hibernate.validator.cfg.ConstraintDef;
+import org.hibernate.validator.cfg.ConstraintMapping;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class DecimalMinDef extends ConstraintDef<DecimalMin> {
+
+ public DecimalMinDef(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
+ super( beanType, DecimalMin.class, property, elementType, mapping );
+ }
+
+ public DecimalMinDef message(String message) {
+ addParameter( "message", message );
+ return this;
+ }
+
+ public DecimalMinDef groups(Class<?>... groups) {
+ addParameter( "groups", groups );
+ return this;
+ }
+
+ public DecimalMinDef payload(Class<? extends Payload>... payload) {
+ addParameter( "payload", payload );
+ return this;
+ }
+
+ public DecimalMinDef value(String min) {
+ addParameter( "value", min );
+ return this;
+ }
+}
\ No newline at end of file
Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/DecimalMinDef.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/DigitsDef.java (from rev 19596, validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/DigitsDefinition.java)
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/DigitsDef.java (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/DigitsDef.java 2010-05-25 18:21:27 UTC (rev 19606)
@@ -0,0 +1,61 @@
+// $Id$
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.cfg.defs;
+
+import java.lang.annotation.ElementType;
+import javax.validation.Payload;
+import javax.validation.constraints.Digits;
+
+import org.hibernate.validator.cfg.ConstraintDef;
+import org.hibernate.validator.cfg.ConstraintMapping;
+
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class DigitsDef extends ConstraintDef<Digits> {
+
+ public DigitsDef(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
+ super( beanType, Digits.class, property, elementType, mapping );
+ }
+
+ public DigitsDef message(String message) {
+ addParameter( "message", message );
+ return this;
+ }
+
+ public DigitsDef groups(Class<?>... groups) {
+ addParameter( "groups", groups );
+ return this;
+ }
+
+ public DigitsDef payload(Class<? extends Payload>... payload) {
+ addParameter( "payload", payload );
+ return this;
+ }
+
+ public DigitsDef integer(int integer) {
+ addParameter( "integer", integer );
+ return this;
+ }
+
+ public DigitsDef fraction(int fraction) {
+ addParameter( "fraction", fraction );
+ return this;
+ }
+}
\ No newline at end of file
Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/DigitsDef.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/EmailDef.java (from rev 19596, validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/EmailDefinition.java)
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/EmailDef.java (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/EmailDef.java 2010-05-25 18:21:27 UTC (rev 19606)
@@ -0,0 +1,50 @@
+// $Id$
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.cfg.defs;
+
+import java.lang.annotation.ElementType;
+import javax.validation.Payload;
+
+import org.hibernate.validator.cfg.ConstraintDef;
+import org.hibernate.validator.cfg.ConstraintMapping;
+import org.hibernate.validator.constraints.Email;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class EmailDef extends ConstraintDef<Email> {
+ public EmailDef(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
+ super( beanType, Email.class, property, elementType, mapping );
+ }
+
+ public EmailDef message(String message) {
+ addParameter( "message", message );
+ return this;
+ }
+
+ public EmailDef groups(Class<?>... groups) {
+ addParameter( "groups", groups );
+ return this;
+ }
+
+ public EmailDef payload(Class<? extends Payload>... payload) {
+ addParameter( "payload", payload );
+ return this;
+ }
+}
\ No newline at end of file
Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/EmailDef.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/FutureDef.java (from rev 19566, validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/FutureDefinition.java)
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/FutureDef.java (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/FutureDef.java 2010-05-25 18:21:27 UTC (rev 19606)
@@ -0,0 +1,49 @@
+// $Id$
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.cfg.defs;
+
+import java.lang.annotation.ElementType;
+import javax.validation.Payload;
+import javax.validation.constraints.Future;
+
+import org.hibernate.validator.cfg.ConstraintDef;
+import org.hibernate.validator.cfg.ConstraintMapping;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class FutureDef extends ConstraintDef<Future> {
+ public FutureDef(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
+ super( beanType, Future.class, property, elementType, mapping );
+ }
+
+ public FutureDef message(String message) {
+ addParameter( "message", message );
+ return this;
+ }
+
+ public FutureDef groups(Class<?>... groups) {
+ addParameter( "groups", groups );
+ return this;
+ }
+
+ public FutureDef payload(Class<? extends Payload>... payload) {
+ addParameter( "payload", payload );
+ return this;
+ }
+}
\ No newline at end of file
Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/FutureDef.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/LengthDef.java (from rev 19596, validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/LengthDefinition.java)
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/LengthDef.java (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/LengthDef.java 2010-05-25 18:21:27 UTC (rev 19606)
@@ -0,0 +1,62 @@
+// $Id$
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.cfg.defs;
+
+import java.lang.annotation.ElementType;
+import javax.validation.Payload;
+
+import org.hibernate.validator.cfg.ConstraintDef;
+import org.hibernate.validator.cfg.ConstraintMapping;
+import org.hibernate.validator.constraints.Length;
+
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class LengthDef extends ConstraintDef<Length> {
+
+ public LengthDef(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
+ super( beanType, Length.class, property, elementType, mapping );
+ }
+
+ public LengthDef message(String message) {
+ addParameter( "message", message );
+ return this;
+ }
+
+ public LengthDef groups(Class<?>... groups) {
+ addParameter( "groups", groups );
+ return this;
+ }
+
+ public LengthDef payload(Class<? extends Payload>... payload) {
+ addParameter( "payload", payload );
+ return this;
+ }
+
+ public LengthDef min(int min) {
+ addParameter( "min", min );
+ return this;
+ }
+
+ public LengthDef max(int max) {
+ addParameter( "max", max );
+ return this;
+ }
+}
\ No newline at end of file
Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/LengthDef.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/MaxDef.java (from rev 19596, validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/MaxDefinition.java)
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/MaxDef.java (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/MaxDef.java 2010-05-25 18:21:27 UTC (rev 19606)
@@ -0,0 +1,55 @@
+// $Id$
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.cfg.defs;
+
+import java.lang.annotation.ElementType;
+import javax.validation.Payload;
+import javax.validation.constraints.Max;
+
+import org.hibernate.validator.cfg.ConstraintDef;
+import org.hibernate.validator.cfg.ConstraintMapping;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class MaxDef extends ConstraintDef<Max> {
+
+ public MaxDef(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
+ super( beanType, Max.class, property, elementType, mapping );
+ }
+
+ public MaxDef message(String message) {
+ addParameter( "message", message );
+ return this;
+ }
+
+ public MaxDef groups(Class<?>... groups) {
+ addParameter( "groups", groups );
+ return this;
+ }
+
+ public MaxDef payload(Class<? extends Payload>... payload) {
+ addParameter( "payload", payload );
+ return this;
+ }
+
+ public MaxDef value(long max) {
+ addParameter( "value", max );
+ return this;
+ }
+}
\ No newline at end of file
Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/MaxDef.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/MinDef.java (from rev 19559, validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/MinDefinition.java)
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/MinDef.java (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/MinDef.java 2010-05-25 18:21:27 UTC (rev 19606)
@@ -0,0 +1,55 @@
+// $Id$
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.cfg.defs;
+
+import java.lang.annotation.ElementType;
+import javax.validation.Payload;
+import javax.validation.constraints.Min;
+
+import org.hibernate.validator.cfg.ConstraintDef;
+import org.hibernate.validator.cfg.ConstraintMapping;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class MinDef extends ConstraintDef<Min> {
+
+ public MinDef(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
+ super( beanType, Min.class, property, elementType, mapping );
+ }
+
+ public MinDef message(String message) {
+ addParameter( "message", message );
+ return this;
+ }
+
+ public MinDef groups(Class<?>... groups) {
+ addParameter( "groups", groups );
+ return this;
+ }
+
+ public MinDef payload(Class<? extends Payload>... payload) {
+ addParameter( "payload", payload );
+ return this;
+ }
+
+ public MinDef value(long min) {
+ addParameter( "value", min );
+ return this;
+ }
+}
\ No newline at end of file
Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/MinDef.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/NotBlankDef.java (from rev 19596, validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/NotBlankDefinition.java)
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/NotBlankDef.java (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/NotBlankDef.java 2010-05-25 18:21:27 UTC (rev 19606)
@@ -0,0 +1,49 @@
+// $Id$
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.cfg.defs;
+
+import java.lang.annotation.ElementType;
+import javax.validation.Payload;
+
+import org.hibernate.validator.cfg.ConstraintDef;
+import org.hibernate.validator.cfg.ConstraintMapping;
+import org.hibernate.validator.constraints.NotBlank;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class NotBlankDef extends ConstraintDef<NotBlank> {
+ public NotBlankDef(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
+ super( beanType, NotBlank.class, property, elementType, mapping );
+ }
+
+ public NotBlankDef message(String message) {
+ addParameter( "message", message );
+ return this;
+ }
+
+ public NotBlankDef groups(Class<?>... groups) {
+ addParameter( "groups", groups );
+ return this;
+ }
+
+ public NotBlankDef payload(Class<? extends Payload>... payload) {
+ addParameter( "payload", payload );
+ return this;
+ }
+}
\ No newline at end of file
Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/NotBlankDef.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/NotEmptyDef.java (from rev 19596, validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/NotEmptyDefinition.java)
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/NotEmptyDef.java (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/NotEmptyDef.java 2010-05-25 18:21:27 UTC (rev 19606)
@@ -0,0 +1,49 @@
+// $Id$
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.cfg.defs;
+
+import java.lang.annotation.ElementType;
+import javax.validation.Payload;
+
+import org.hibernate.validator.cfg.ConstraintDef;
+import org.hibernate.validator.cfg.ConstraintMapping;
+import org.hibernate.validator.constraints.NotEmpty;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class NotEmptyDef extends ConstraintDef<NotEmpty> {
+ public NotEmptyDef(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
+ super( beanType, NotEmpty.class, property, elementType, mapping );
+ }
+
+ public NotEmptyDef message(String message) {
+ addParameter( "message", message );
+ return this;
+ }
+
+ public NotEmptyDef groups(Class<?>... groups) {
+ addParameter( "groups", groups );
+ return this;
+ }
+
+ public NotEmptyDef payload(Class<? extends Payload>... payload) {
+ addParameter( "payload", payload );
+ return this;
+ }
+}
\ No newline at end of file
Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/NotEmptyDef.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/NotNullDef.java (from rev 19559, validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/NotNullDefinition.java)
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/NotNullDef.java (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/NotNullDef.java 2010-05-25 18:21:27 UTC (rev 19606)
@@ -0,0 +1,49 @@
+// $Id$
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.cfg.defs;
+
+import java.lang.annotation.ElementType;
+import javax.validation.Payload;
+import javax.validation.constraints.NotNull;
+
+import org.hibernate.validator.cfg.ConstraintDef;
+import org.hibernate.validator.cfg.ConstraintMapping;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class NotNullDef extends ConstraintDef<NotNull> {
+ public NotNullDef(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
+ super( beanType, NotNull.class, property, elementType, mapping );
+ }
+
+ public NotNullDef message(String message) {
+ addParameter( "message", message );
+ return this;
+ }
+
+ public NotNullDef groups(Class<?>... groups) {
+ addParameter( "groups", groups );
+ return this;
+ }
+
+ public NotNullDef payload(Class<? extends Payload>... payload) {
+ addParameter( "payload", payload );
+ return this;
+ }
+}
\ No newline at end of file
Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/NotNullDef.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/NullDef.java (from rev 19596, validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/NullDefinition.java)
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/NullDef.java (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/NullDef.java 2010-05-25 18:21:27 UTC (rev 19606)
@@ -0,0 +1,49 @@
+// $Id$
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.cfg.defs;
+
+import java.lang.annotation.ElementType;
+import javax.validation.Payload;
+import javax.validation.constraints.Null;
+
+import org.hibernate.validator.cfg.ConstraintDef;
+import org.hibernate.validator.cfg.ConstraintMapping;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class NullDef extends ConstraintDef<Null> {
+ public NullDef(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
+ super( beanType, Null.class, property, elementType, mapping );
+ }
+
+ public NullDef message(String message) {
+ addParameter( "message", message );
+ return this;
+ }
+
+ public NullDef groups(Class<?>... groups) {
+ addParameter( "groups", groups );
+ return this;
+ }
+
+ public NullDef payload(Class<? extends Payload>... payload) {
+ addParameter( "payload", payload );
+ return this;
+ }
+}
\ No newline at end of file
Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/NullDef.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/PastDef.java (from rev 19596, validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/PastDefinition.java)
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/PastDef.java (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/PastDef.java 2010-05-25 18:21:27 UTC (rev 19606)
@@ -0,0 +1,49 @@
+// $Id$
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.cfg.defs;
+
+import java.lang.annotation.ElementType;
+import javax.validation.Payload;
+import javax.validation.constraints.Past;
+
+import org.hibernate.validator.cfg.ConstraintDef;
+import org.hibernate.validator.cfg.ConstraintMapping;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class PastDef extends ConstraintDef<Past> {
+ public PastDef(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
+ super( beanType, Past.class, property, elementType, mapping );
+ }
+
+ public PastDef message(String message) {
+ addParameter( "message", message );
+ return this;
+ }
+
+ public PastDef groups(Class<?>... groups) {
+ addParameter( "groups", groups );
+ return this;
+ }
+
+ public PastDef payload(Class<? extends Payload>... payload) {
+ addParameter( "payload", payload );
+ return this;
+ }
+}
\ No newline at end of file
Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/PastDef.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/PatternDef.java (from rev 19559, validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/PatternDefinition.java)
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/PatternDef.java (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/PatternDef.java 2010-05-25 18:21:27 UTC (rev 19606)
@@ -0,0 +1,61 @@
+// $Id$
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.cfg.defs;
+
+import java.lang.annotation.ElementType;
+import javax.validation.Payload;
+import javax.validation.constraints.Pattern;
+
+import org.hibernate.validator.cfg.ConstraintDef;
+import org.hibernate.validator.cfg.ConstraintMapping;
+
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class PatternDef extends ConstraintDef<Pattern> {
+
+ public PatternDef(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
+ super( beanType, Pattern.class, property, elementType, mapping );
+ }
+
+ public PatternDef message(String message) {
+ addParameter( "message", message );
+ return this;
+ }
+
+ public PatternDef groups(Class<?>... groups) {
+ addParameter( "groups", groups );
+ return this;
+ }
+
+ public PatternDef payload(Class<? extends Payload>... payload) {
+ addParameter( "payload", payload );
+ return this;
+ }
+
+ public PatternDef flags(Pattern.Flag[] flags) {
+ addParameter( "flags", flags );
+ return this;
+ }
+
+ public PatternDef regexp(String regexp) {
+ addParameter( "regexp", regexp );
+ return this;
+ }
+}
\ No newline at end of file
Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/PatternDef.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/RangeDef.java (from rev 19596, validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/RangeDefinition.java)
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/RangeDef.java (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/RangeDef.java 2010-05-25 18:21:27 UTC (rev 19606)
@@ -0,0 +1,60 @@
+// $Id$
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.cfg.defs;
+
+import java.lang.annotation.ElementType;
+import javax.validation.Payload;
+
+import org.hibernate.validator.cfg.ConstraintDef;
+import org.hibernate.validator.cfg.ConstraintMapping;
+import org.hibernate.validator.constraints.Range;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class RangeDef extends ConstraintDef<Range> {
+
+ public RangeDef(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
+ super( beanType, Range.class, property, elementType, mapping );
+ }
+
+ public RangeDef message(String message) {
+ addParameter( "message", message );
+ return this;
+ }
+
+ public RangeDef groups(Class<?>... groups) {
+ addParameter( "groups", groups );
+ return this;
+ }
+
+ public RangeDef payload(Class<? extends Payload>... payload) {
+ addParameter( "payload", payload );
+ return this;
+ }
+
+ public RangeDef min(long min) {
+ addParameter( "value", min );
+ return this;
+ }
+
+ public RangeDef max(long max) {
+ addParameter( "value", max );
+ return this;
+ }
+}
\ No newline at end of file
Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/RangeDef.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/ScriptAssertDef.java (from rev 19596, validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/ScriptAssertDefinition.java)
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/ScriptAssertDef.java (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/ScriptAssertDef.java 2010-05-25 18:21:27 UTC (rev 19606)
@@ -0,0 +1,65 @@
+// $Id$
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.cfg.defs;
+
+import java.lang.annotation.ElementType;
+import javax.validation.Payload;
+
+import org.hibernate.validator.cfg.ConstraintDef;
+import org.hibernate.validator.cfg.ConstraintMapping;
+import org.hibernate.validator.constraints.ScriptAssert;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class ScriptAssertDef extends ConstraintDef<ScriptAssert> {
+
+ public ScriptAssertDef(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
+ super( beanType, ScriptAssert.class, property, elementType, mapping );
+ }
+
+ public ScriptAssertDef message(String message) {
+ addParameter( "message", message );
+ return this;
+ }
+
+ public ScriptAssertDef groups(Class<?>... groups) {
+ addParameter( "groups", groups );
+ return this;
+ }
+
+ public ScriptAssertDef payload(Class<? extends Payload>... payload) {
+ addParameter( "payload", payload );
+ return this;
+ }
+
+ public ScriptAssertDef lang(String lang) {
+ addParameter( "lang", lang );
+ return this;
+ }
+
+ public ScriptAssertDef script(String script) {
+ addParameter( "script", script );
+ return this;
+ }
+
+ public ScriptAssertDef alias(String alias) {
+ addParameter( "alias", alias );
+ return this;
+ }
+}
\ No newline at end of file
Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/ScriptAssertDef.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/SizeDef.java (from rev 19559, validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/SizeDefinition.java)
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/SizeDef.java (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/SizeDef.java 2010-05-25 18:21:27 UTC (rev 19606)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.
+ */
+
+// $Id$
+package org.hibernate.validator.cfg.defs;
+
+import java.lang.annotation.ElementType;
+import javax.validation.Payload;
+import javax.validation.constraints.Size;
+
+import org.hibernate.validator.cfg.ConstraintDef;
+import org.hibernate.validator.cfg.ConstraintMapping;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class SizeDef extends ConstraintDef<Size> {
+
+ public SizeDef(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
+ super( beanType, Size.class, property, elementType, mapping );
+ }
+
+ public SizeDef message(String message) {
+ addParameter( "message", message );
+ return this;
+ }
+
+ public SizeDef groups(Class<?>... groups) {
+ addParameter( "groups", groups );
+ return this;
+ }
+
+ public SizeDef payload(Class<? extends Payload>... payload) {
+ addParameter( "payload", payload );
+ return this;
+ }
+
+ public SizeDef min(int min) {
+ addParameter( "min", min );
+ return this;
+ }
+
+ public SizeDef max(int max) {
+ addParameter( "max", max );
+ return this;
+ }
+}
+
+
Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/SizeDef.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/URLDef.java (from rev 19596, validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/URLDefinition.java)
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/URLDef.java (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/URLDef.java 2010-05-25 18:21:27 UTC (rev 19606)
@@ -0,0 +1,64 @@
+// $Id$
+/* JBoss, Home of Professional Open Source
+ * Copyright 2010, 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.cfg.defs;
+
+import java.lang.annotation.ElementType;
+import javax.validation.Payload;
+
+import org.hibernate.validator.cfg.ConstraintDef;
+import org.hibernate.validator.cfg.ConstraintMapping;
+import org.hibernate.validator.constraints.URL;
+
+/**
+ * @author Hardy Ferentschik
+ */
+public class URLDef extends ConstraintDef<URL> {
+
+ public URLDef(Class<?> beanType, String property, ElementType elementType, ConstraintMapping mapping) {
+ super( beanType, URL.class, property, elementType, mapping );
+ }
+
+ public URLDef message(String message) {
+ addParameter( "message", message );
+ return this;
+ }
+
+ public URLDef groups(Class<?>... groups) {
+ addParameter( "groups", groups );
+ return this;
+ }
+
+ public URLDef payload(Class<? extends Payload>... payload) {
+ addParameter( "payload", payload );
+ return this;
+ }
+
+ public URLDef protocol(String protocol) {
+ addParameter( "protocol", protocol );
+ return this;
+ }
+
+ public URLDef host(String host) {
+ addParameter( "host", host );
+ return this;
+ }
+
+ public URLDef port(int port) {
+ addParameter( "port", port );
+ return this;
+ }
+}
\ No newline at end of file
Property changes on: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/URLDef.java
___________________________________________________________________
Name: svn:keywords
+ Id
Copied: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/package.html (from rev 19596, validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/package.html)
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/package.html (rev 0)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/defs/package.html 2010-05-25 18:21:27 UTC (rev 19606)
@@ -0,0 +1,24 @@
+<!--
+ ~ JBoss, Home of Professional Open Source
+ ~ Copyright 2010, 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.
+ -->
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html>
+<head>
+</head>
+<body>
+Helper classes for programmatic constraint definition API.
+</body>
+</html>
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/package.html
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/package.html 2010-05-25 16:52:25 UTC (rev 19605)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/cfg/package.html 2010-05-25 18:21:27 UTC (rev 19606)
@@ -1,5 +1,5 @@
<!--
- ~ $Id:$
+ ~ $Id$
~
~ JBoss, Home of Professional Open Source
~ Copyright 2010, Red Hat, Inc. and/or its affiliates, and individual contributors
@@ -21,6 +21,6 @@
<head>
</head>
<body>
-Programmatic constraint definition API with required helper classes.
+Programmatic constraint definition API.
</body>
</html>
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/ValidatorFactoryImpl.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/ValidatorFactoryImpl.java 2010-05-25 16:52:25 UTC (rev 19605)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/engine/ValidatorFactoryImpl.java 2010-05-25 18:21:27 UTC (rev 19606)
@@ -34,8 +34,8 @@
import javax.validation.ValidatorFactory;
import javax.validation.spi.ConfigurationState;
-import org.hibernate.validator.cfg.CascadeDefinition;
-import org.hibernate.validator.cfg.ConstraintDefinition;
+import org.hibernate.validator.cfg.CascadeDef;
+import org.hibernate.validator.cfg.ConstraintDef;
import org.hibernate.validator.cfg.ConstraintMapping;
import org.hibernate.validator.metadata.AnnotationIgnores;
import org.hibernate.validator.metadata.BeanMetaDataCache;
@@ -228,10 +228,10 @@
}
@SuppressWarnings("unchecked")
- private <T, A extends Annotation> void addProgrammaticConfiguredConstraints(List<ConstraintDefinition<?>> definitions,
+ private <T, A extends Annotation> void addProgrammaticConfiguredConstraints(List<ConstraintDef<?>> definitions,
Class<T> rootClass, Class<?> hierarchyClass,
Map<Class<?>, List<MetaConstraint<T, ?>>> constraints) {
- for ( ConstraintDefinition<?> config : definitions ) {
+ for ( ConstraintDef<?> config : definitions ) {
A annotation = ( A ) createAnnotationProxy( config );
ConstraintOrigin definedIn = definedIn( rootClass, hierarchyClass );
ConstraintDescriptorImpl<A> constraintDescriptor = new ConstraintDescriptorImpl<A>(
@@ -269,12 +269,12 @@
}
}
- private void addProgrammaticConfiguredCascade(List<CascadeDefinition> cascades,
+ private void addProgrammaticConfiguredCascade(List<CascadeDef> cascades,
List<Member> cascadedMembers) {
if ( cascades == null ) {
return;
}
- for ( CascadeDefinition cascade : cascades ) {
+ for ( CascadeDef cascade : cascades ) {
Member m = ReflectionHelper.getMember(
cascade.getBeanType(), cascade.getProperty(), cascade.getElementType()
);
@@ -299,7 +299,7 @@
}
@SuppressWarnings("unchecked")
- private <A extends Annotation> Annotation createAnnotationProxy(ConstraintDefinition<?> config) {
+ private <A extends Annotation> Annotation createAnnotationProxy(ConstraintDef<?> config) {
Class<A> constraintType = ( Class<A> ) config.getConstraintType();
AnnotationDescriptor<A> annotationDescriptor = new AnnotationDescriptor<A>( constraintType );
for ( Map.Entry<String, Object> parameter : config.getParameters().entrySet() ) {
Modified: validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/util/privilegedactions/LoadClass.java
===================================================================
--- validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/util/privilegedactions/LoadClass.java 2010-05-25 16:52:25 UTC (rev 19605)
+++ validator/trunk/hibernate-validator/src/main/java/org/hibernate/validator/util/privilegedactions/LoadClass.java 2010-05-25 18:21:27 UTC (rev 19606)
@@ -43,14 +43,17 @@
return contextClassLoader.loadClass( className );
}
}
- catch ( Throwable e ) {
+ catch ( ClassNotFoundException e ) {
+ // ignore - try using the classloader of the caller first
+ }
+ catch ( RuntimeException e ) {
// ignore
}
try {
return Class.forName( className, true, caller.getClassLoader() );
}
catch ( ClassNotFoundException e ) {
- throw new ValidationException("Unable to load class: " + className, e);
+ throw new ValidationException( "Unable to load class: " + className, e );
}
}
}
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/test/cfg/ConstraintMappingTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/test/cfg/ConstraintMappingTest.java 2010-05-25 16:52:25 UTC (rev 19605)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/test/cfg/ConstraintMappingTest.java 2010-05-25 18:21:27 UTC (rev 19606)
@@ -30,12 +30,13 @@
import org.hibernate.validator.HibernateValidator;
import org.hibernate.validator.HibernateValidatorConfiguration;
-import org.hibernate.validator.cfg.AssertTrueDefinition;
+import org.hibernate.validator.cfg.defs.AssertTrueDef;
import org.hibernate.validator.cfg.ConstraintMapping;
-import org.hibernate.validator.cfg.FutureDefinition;
-import org.hibernate.validator.cfg.MinDefinition;
-import org.hibernate.validator.cfg.NotEmptyDefinition;
-import org.hibernate.validator.cfg.NotNullDefinition;
+import org.hibernate.validator.cfg.defs.FutureDef;
+import org.hibernate.validator.cfg.defs.MinDef;
+import org.hibernate.validator.cfg.defs.NotEmptyDef;
+import org.hibernate.validator.cfg.defs.NotNullDef;
+import org.hibernate.validator.cfg.defs.SizeDef;
import org.hibernate.validator.test.util.TestUtil;
import org.hibernate.validator.util.LoggerFactory;
@@ -57,9 +58,9 @@
ConstraintMapping mapping = new ConstraintMapping();
mapping.type( Marathon.class )
.property( "name", METHOD )
- .constraint( NotNullDefinition.class )
+ .constraint( NotNullDef.class )
.property( "numberOfRunners", FIELD )
- .constraint( MinDefinition.class ).value( 1 );
+ .constraint( MinDef.class ).value( 1 );
assertTrue( mapping.getConstraintConfig().containsKey( Marathon.class ) );
assertTrue( mapping.getConstraintConfig().get( Marathon.class ).size() == 2 );
@@ -82,7 +83,7 @@
ConstraintMapping mapping = new ConstraintMapping();
mapping.type( Marathon.class )
.property( "name", METHOD )
- .constraint( NotNullDefinition.class );
+ .constraint( NotNullDef.class );
config.addMapping( mapping );
@@ -102,10 +103,10 @@
mapping
.type( Marathon.class )
.property( "name", METHOD )
- .constraint( NotNullDefinition.class )
+ .constraint( NotNullDef.class )
.type( Tournament.class )
.property( "tournamentDate", METHOD )
- .constraint( FutureDefinition.class );
+ .constraint( FutureDef.class );
config.addMapping( mapping );
@@ -132,7 +133,7 @@
.valid( "runners", METHOD )
.type( Runner.class )
.property( "paidEntryFee", FIELD )
- .constraint( AssertTrueDefinition.class );
+ .constraint( AssertTrueDef.class );
config.addMapping( mapping );
@@ -158,7 +159,7 @@
mapping
.type( Marathon.class )
.property( "numberOfRunners", METHOD )
- .constraint( NotNullDefinition.class );
+ .constraint( NotNullDef.class );
fail();
}
catch ( ValidationException e ) {
@@ -175,9 +176,9 @@
.type( Marathon.class )
.defaultGroupSequence( Foo.class, Marathon.class )
.property( "name", METHOD )
- .constraint( NotNullDefinition.class ).groups( Foo.class )
+ .constraint( NotNullDef.class ).groups( Foo.class )
.property( "runners", METHOD )
- .constraint( NotEmptyDefinition.class );
+ .constraint( NotEmptyDef.class );
config.addMapping( mapping );
@@ -196,6 +197,36 @@
assertConstraintViolation( violations.iterator().next(), "may not be empty" );
}
+ @Test
+ public void testMultipleConstraintOfTheSameType() {
+ HibernateValidatorConfiguration config = TestUtil.getConfiguration( HibernateValidator.class );
+
+ ConstraintMapping mapping = new ConstraintMapping();
+ mapping.type( Marathon.class )
+ .property( "name", METHOD )
+ .constraint( SizeDef.class ).min( 5 )
+ .constraint( SizeDef.class ).min( 10 );
+
+ config.addMapping( mapping );
+
+ ValidatorFactory factory = config.buildValidatorFactory();
+ Validator validator = factory.getValidator();
+
+ Marathon marathon = new Marathon();
+ marathon.setName( "Foo" );
+
+ Set<ConstraintViolation<Marathon>> violations = validator.validate( marathon );
+ assertNumberOfViolations( violations, 2 );
+
+ marathon.setName( "Foobar" );
+ violations = validator.validate( marathon );
+ assertNumberOfViolations( violations, 1 );
+
+ marathon.setName( "Stockholm Marathon" );
+ violations = validator.validate( marathon );
+ assertNumberOfViolations( violations, 0 );
+ }
+
public interface Foo {
}
}
14 years, 7 months
Hibernate SVN: r19605 - validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/test/cfg.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2010-05-25 12:52:25 -0400 (Tue, 25 May 2010)
New Revision: 19605
Modified:
validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/test/cfg/ConstraintMappingTest.java
Log:
HV-274 Add better indentation on programmatic mapping API
Modified: validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/test/cfg/ConstraintMappingTest.java
===================================================================
--- validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/test/cfg/ConstraintMappingTest.java 2010-05-25 13:31:50 UTC (rev 19604)
+++ validator/trunk/hibernate-validator/src/test/java/org/hibernate/validator/test/cfg/ConstraintMappingTest.java 2010-05-25 16:52:25 UTC (rev 19605)
@@ -57,9 +57,9 @@
ConstraintMapping mapping = new ConstraintMapping();
mapping.type( Marathon.class )
.property( "name", METHOD )
- .constraint( NotNullDefinition.class )
+ .constraint( NotNullDefinition.class )
.property( "numberOfRunners", FIELD )
- .constraint( MinDefinition.class ).value( 1 );
+ .constraint( MinDefinition.class ).value( 1 );
assertTrue( mapping.getConstraintConfig().containsKey( Marathon.class ) );
assertTrue( mapping.getConstraintConfig().get( Marathon.class ).size() == 2 );
@@ -82,7 +82,7 @@
ConstraintMapping mapping = new ConstraintMapping();
mapping.type( Marathon.class )
.property( "name", METHOD )
- .constraint( NotNullDefinition.class );
+ .constraint( NotNullDefinition.class );
config.addMapping( mapping );
@@ -99,12 +99,13 @@
HibernateValidatorConfiguration config = TestUtil.getConfiguration( HibernateValidator.class );
ConstraintMapping mapping = new ConstraintMapping();
- mapping.type( Marathon.class )
+ mapping
+ .type( Marathon.class )
.property( "name", METHOD )
- .constraint( NotNullDefinition.class )
- .type( Tournament.class )
+ .constraint( NotNullDefinition.class )
+ .type( Tournament.class )
.property( "tournamentDate", METHOD )
- .constraint( FutureDefinition.class );
+ .constraint( FutureDefinition.class );
config.addMapping( mapping );
@@ -128,10 +129,10 @@
ConstraintMapping mapping = new ConstraintMapping();
mapping.type( Marathon.class )
- .valid( "runners", METHOD )
+ .valid( "runners", METHOD )
.type( Runner.class )
- .property( "paidEntryFee", FIELD )
- .constraint( AssertTrueDefinition.class );
+ .property( "paidEntryFee", FIELD )
+ .constraint( AssertTrueDefinition.class );
config.addMapping( mapping );
@@ -154,9 +155,10 @@
public void testSingleConstraintWrongAccessType() {
ConstraintMapping mapping = new ConstraintMapping();
try {
- mapping.type( Marathon.class )
+ mapping
+ .type( Marathon.class )
.property( "numberOfRunners", METHOD )
- .constraint( NotNullDefinition.class );
+ .constraint( NotNullDefinition.class );
fail();
}
catch ( ValidationException e ) {
@@ -169,12 +171,13 @@
HibernateValidatorConfiguration config = TestUtil.getConfiguration( HibernateValidator.class );
ConstraintMapping mapping = new ConstraintMapping();
- mapping.type( Marathon.class )
+ mapping
+ .type( Marathon.class )
.defaultGroupSequence( Foo.class, Marathon.class )
.property( "name", METHOD )
- .constraint( NotNullDefinition.class ).groups( Foo.class )
+ .constraint( NotNullDefinition.class ).groups( Foo.class )
.property( "runners", METHOD )
- .constraint( NotEmptyDefinition.class );
+ .constraint( NotEmptyDefinition.class );
config.addMapping( mapping );
14 years, 7 months
Hibernate SVN: r19604 - in core/branches/Branch_3_5/entitymanager/src/main/java/org/hibernate/ejb: util and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2010-05-25 09:31:50 -0400 (Tue, 25 May 2010)
New Revision: 19604
Modified:
core/branches/Branch_3_5/entitymanager/src/main/java/org/hibernate/ejb/EntityManagerFactoryImpl.java
core/branches/Branch_3_5/entitymanager/src/main/java/org/hibernate/ejb/HibernatePersistence.java
core/branches/Branch_3_5/entitymanager/src/main/java/org/hibernate/ejb/util/PersistenceUtilHelper.java
Log:
HHH-5258 isLoaded and superclasses and private properties now works
Use getDeclaredField and getDeclaredMethod, use the whole class hierarchy
and use a cache to speed up both class hierarchy
and property to Member computation
Modified: core/branches/Branch_3_5/entitymanager/src/main/java/org/hibernate/ejb/EntityManagerFactoryImpl.java
===================================================================
--- core/branches/Branch_3_5/entitymanager/src/main/java/org/hibernate/ejb/EntityManagerFactoryImpl.java 2010-05-25 13:31:08 UTC (rev 19603)
+++ core/branches/Branch_3_5/entitymanager/src/main/java/org/hibernate/ejb/EntityManagerFactoryImpl.java 2010-05-25 13:31:50 UTC (rev 19604)
@@ -65,6 +65,7 @@
private final Metamodel metamodel;
private final HibernatePersistenceUnitUtil util;
private final Map<String,Object> properties;
+ private final PersistenceUtilHelper.MetadataCache cache = new PersistenceUtilHelper.MetadataCache();
@SuppressWarnings( "unchecked" )
public EntityManagerFactoryImpl(
@@ -182,13 +183,15 @@
private static class HibernatePersistenceUnitUtil implements PersistenceUnitUtil, Serializable {
private final HibernateEntityManagerFactory emf;
+ private transient PersistenceUtilHelper.MetadataCache cache;
private HibernatePersistenceUnitUtil(EntityManagerFactoryImpl emf) {
this.emf = emf;
+ this.cache = emf.cache;
}
public boolean isLoaded(Object entity, String attributeName) {
- LoadState state = PersistenceUtilHelper.isLoadedWithoutReference( entity, attributeName );
+ LoadState state = PersistenceUtilHelper.isLoadedWithoutReference( entity, attributeName, cache );
if (state == LoadState.LOADED) {
return true;
}
@@ -196,7 +199,7 @@
return false;
}
else {
- return PersistenceUtilHelper.isLoadedWithReference( entity, attributeName ) != LoadState.NOT_LOADED;
+ return PersistenceUtilHelper.isLoadedWithReference( entity, attributeName, cache ) != LoadState.NOT_LOADED;
}
}
Modified: core/branches/Branch_3_5/entitymanager/src/main/java/org/hibernate/ejb/HibernatePersistence.java
===================================================================
--- core/branches/Branch_3_5/entitymanager/src/main/java/org/hibernate/ejb/HibernatePersistence.java 2010-05-25 13:31:08 UTC (rev 19603)
+++ core/branches/Branch_3_5/entitymanager/src/main/java/org/hibernate/ejb/HibernatePersistence.java 2010-05-25 13:31:50 UTC (rev 19604)
@@ -38,6 +38,7 @@
* @author Gavin King
*/
public class HibernatePersistence extends AvailableSettings implements PersistenceProvider {
+ private final PersistenceUtilHelper.MetadataCache cache = new PersistenceUtilHelper.MetadataCache();
/**
* Get an entity manager factory by its entity manager name, using the specified
@@ -85,11 +86,11 @@
private final ProviderUtil providerUtil = new ProviderUtil() {
public LoadState isLoadedWithoutReference(Object proxy, String property) {
- return PersistenceUtilHelper.isLoadedWithoutReference( proxy, property );
+ return PersistenceUtilHelper.isLoadedWithoutReference( proxy, property, cache );
}
public LoadState isLoadedWithReference(Object proxy, String property) {
- return PersistenceUtilHelper.isLoadedWithReference( proxy, property );
+ return PersistenceUtilHelper.isLoadedWithReference( proxy, property, cache );
}
public LoadState isLoaded(Object o) {
Modified: core/branches/Branch_3_5/entitymanager/src/main/java/org/hibernate/ejb/util/PersistenceUtilHelper.java
===================================================================
--- core/branches/Branch_3_5/entitymanager/src/main/java/org/hibernate/ejb/util/PersistenceUtilHelper.java 2010-05-25 13:31:08 UTC (rev 19603)
+++ core/branches/Branch_3_5/entitymanager/src/main/java/org/hibernate/ejb/util/PersistenceUtilHelper.java 2010-05-25 13:31:50 UTC (rev 19604)
@@ -1,14 +1,21 @@
package org.hibernate.ejb.util;
+import java.io.Serializable;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Member;
import java.lang.reflect.Modifier;
import java.lang.reflect.AccessibleObject;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.WeakHashMap;
import javax.persistence.spi.LoadState;
import javax.persistence.PersistenceException;
+import org.hibernate.AssertionFailure;
import org.hibernate.proxy.HibernateProxy;
import org.hibernate.proxy.LazyInitializer;
import org.hibernate.intercept.FieldInterceptionHelper;
@@ -19,7 +26,7 @@
* @author Emmanuel Bernard
*/
public class PersistenceUtilHelper {
- public static LoadState isLoadedWithoutReference(Object proxy, String property) {
+ public static LoadState isLoadedWithoutReference(Object proxy, String property, MetadataCache cache) {
Object entity;
boolean sureFromUs = false;
if ( proxy instanceof HibernateProxy ) {
@@ -44,7 +51,7 @@
if (isInitialized && interceptor != null) {
//property is loaded according to bytecode enhancement, but is it loaded as far as association?
//it's ours, we can read
- state = isLoaded( get( entity, property ) );
+ state = isLoaded( get( entity, property, cache ) );
//it's ours so we know it's loaded
if (state == LoadState.UNKNOWN) state = LoadState.LOADED;
}
@@ -54,7 +61,7 @@
else if ( sureFromUs ) { //interceptor == null
//property is loaded according to bytecode enhancement, but is it loaded as far as association?
//it's ours, we can read
- state = isLoaded( get( entity, property ) );
+ state = isLoaded( get( entity, property, cache ) );
//it's ours so we know it's loaded
if (state == LoadState.UNKNOWN) state = LoadState.LOADED;
}
@@ -71,32 +78,26 @@
}
}
- public static LoadState isLoadedWithReference(Object proxy, String property) {
+ public static LoadState isLoadedWithReference(Object proxy, String property, MetadataCache cache) {
//for sure we don't instrument and for sure it's not a lazy proxy
- Object object = get(proxy, property);
+ Object object = get(proxy, property, cache);
return isLoaded( object );
}
- private static Object get(Object proxy, String property) {
+ private static Object get(Object proxy, String property, MetadataCache cache) {
final Class<?> clazz = proxy.getClass();
+
try {
- try {
- final Field field = clazz.getField( property );
- setAccessibility( field );
- return field.get( proxy );
+ Member member = cache.getMember( clazz, property );
+ if (member instanceof Field) {
+ return ( (Field) member ).get( proxy );
}
- catch ( NoSuchFieldException e ) {
- final Method method = getMethod( clazz, property );
- if (method != null) {
- setAccessibility( method );
- return method.invoke( proxy );
- }
- else {
- throw new PersistenceException( "Unable to find field or method: "
- + clazz + "#"
- + property);
- }
+ else if (member instanceof Method) {
+ return ( (Method) member ).invoke( proxy );
}
+ else {
+ throw new AssertionFailure( "Member object neither Field nor Method: " + member);
+ }
}
catch ( IllegalAccessException e ) {
throw new PersistenceException( "Unable to access field or method: "
@@ -110,6 +111,27 @@
}
}
+ private static void setAccessibility(Member member) {
+ if ( !Modifier.isPublic( member.getModifiers() ) ) {
+ //Sun's ease of use, sigh...
+ ( ( AccessibleObject ) member ).setAccessible( true );
+ }
+ }
+
+ public static LoadState isLoaded(Object o) {
+ if ( o instanceof HibernateProxy ) {
+ final boolean isInitialized = !( ( HibernateProxy ) o ).getHibernateLazyInitializer().isUninitialized();
+ return isInitialized ? LoadState.LOADED : LoadState.NOT_LOADED;
+ }
+ else if ( o instanceof PersistentCollection ) {
+ final boolean isInitialized = ( ( PersistentCollection ) o ).wasInitialized();
+ return isInitialized ? LoadState.LOADED : LoadState.NOT_LOADED;
+ }
+ else {
+ return LoadState.UNKNOWN;
+ }
+ }
+
/**
* Returns the method with the specified name or <code>null</code> if it does not exist.
*
@@ -135,25 +157,84 @@
}
}
- private static void setAccessibility(Member member) {
- if ( !Modifier.isPublic( member.getModifiers() ) ) {
- //Sun's ease of use, sigh...
- ( ( AccessibleObject ) member ).setAccessible( true );
+ /**
+ * Cache hierarchy and member resolution in a weak hash map
+ */
+ //TODO not really thread-safe
+ public static class MetadataCache implements Serializable {
+ private transient Map<Class<?>, ClassCache> classCache = new WeakHashMap<Class<?>, ClassCache>();
+
+
+ private void readObject(java.io.ObjectInputStream stream) {
+ classCache = new WeakHashMap<Class<?>, ClassCache>();
}
- }
- public static LoadState isLoaded(Object o) {
- if ( o instanceof HibernateProxy ) {
- final boolean isInitialized = !( ( HibernateProxy ) o ).getHibernateLazyInitializer().isUninitialized();
- return isInitialized ? LoadState.LOADED : LoadState.NOT_LOADED;
+ Member getMember(Class<?> clazz, String property) {
+ ClassCache cache = classCache.get( clazz );
+ if (cache == null) {
+ cache = new ClassCache(clazz);
+ classCache.put( clazz, cache );
+ }
+ Member member = cache.members.get( property );
+ if ( member == null ) {
+ member = findMember( clazz, property );
+ cache.members.put( property, member );
+ }
+ return member;
}
- else if ( o instanceof PersistentCollection ) {
- final boolean isInitialized = ( ( PersistentCollection ) o ).wasInitialized();
- return isInitialized ? LoadState.LOADED : LoadState.NOT_LOADED;
+
+ private Member findMember(Class<?> clazz, String property) {
+ final List<Class<?>> classes = getClassHierarchy( clazz );
+
+ for (Class current : classes) {
+ final Field field;
+ try {
+ field = current.getDeclaredField( property );
+ setAccessibility( field );
+ return field;
+ }
+ catch ( NoSuchFieldException e ) {
+ final Method method = getMethod( clazz, property );
+ if (method != null) {
+ setAccessibility( method );
+ return method;
+ }
+ }
+ }
+ //we could not find any match
+ throw new PersistenceException( "Unable to find field or method: "
+ + clazz + "#"
+ + property);
}
- else {
- return LoadState.UNKNOWN;
+
+ private List<Class<?>> getClassHierarchy(Class<?> clazz) {
+ ClassCache cache = classCache.get( clazz );
+ if (cache == null) {
+ cache = new ClassCache(clazz);
+ classCache.put( clazz, cache );
+ }
+ return cache.classHierarchy;
}
+
+ private static List<Class<?>> findClassHierarchy(Class<?> clazz) {
+ List<Class<?>> classes = new ArrayList<Class<?>>();
+ Class<?> current = clazz;
+ do {
+ classes.add( current );
+ current = current.getSuperclass();
+ }
+ while ( current != null );
+ return classes;
+ }
+
+ private static class ClassCache {
+ List<Class<?>> classHierarchy;
+ Map<String, Member> members = new HashMap<String, Member>();
+
+ public ClassCache(Class<?> clazz) {
+ classHierarchy = findClassHierarchy( clazz );
+ }
+ }
}
}
14 years, 7 months
Hibernate SVN: r19603 - core/branches/Branch_3_5/entitymanager/src/test/java/org/hibernate/ejb/test/util.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2010-05-25 09:31:08 -0400 (Tue, 25 May 2010)
New Revision: 19603
Added:
core/branches/Branch_3_5/entitymanager/src/test/java/org/hibernate/ejb/test/util/Author.java
core/branches/Branch_3_5/entitymanager/src/test/java/org/hibernate/ejb/test/util/CopyrightableContent.java
core/branches/Branch_3_5/entitymanager/src/test/java/org/hibernate/ejb/test/util/IsLoadedTest.java
Modified:
core/branches/Branch_3_5/entitymanager/src/test/java/org/hibernate/ejb/test/util/Book.java
core/branches/Branch_3_5/entitymanager/src/test/java/org/hibernate/ejb/test/util/GetIdentifierTest.java
Log:
HHH-5258 add tests on isLoaded and superclasses and private properties
Copied: core/branches/Branch_3_5/entitymanager/src/test/java/org/hibernate/ejb/test/util/Author.java (from rev 19602, core/branches/Branch_3_5/entitymanager/src/test/java/org/hibernate/ejb/test/util/Book.java)
===================================================================
--- core/branches/Branch_3_5/entitymanager/src/test/java/org/hibernate/ejb/test/util/Author.java (rev 0)
+++ core/branches/Branch_3_5/entitymanager/src/test/java/org/hibernate/ejb/test/util/Author.java 2010-05-25 13:31:08 UTC (rev 19603)
@@ -0,0 +1,24 @@
+package org.hibernate.ejb.test.util;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity @Table(name="tbl_Author")
+public class Author {
+ @Id
+ @GeneratedValue
+ private Integer id;
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+}
Modified: core/branches/Branch_3_5/entitymanager/src/test/java/org/hibernate/ejb/test/util/Book.java
===================================================================
--- core/branches/Branch_3_5/entitymanager/src/test/java/org/hibernate/ejb/test/util/Book.java 2010-05-25 13:30:22 UTC (rev 19602)
+++ core/branches/Branch_3_5/entitymanager/src/test/java/org/hibernate/ejb/test/util/Book.java 2010-05-25 13:31:08 UTC (rev 19603)
@@ -8,10 +8,18 @@
* @author Emmanuel Bernard
*/
@Entity
-public class Book {
+public class Book extends CopyrightableContent {
private Long id;
private String name;
+ public Book() {
+ super();
+ }
+
+ public Book(Author a) {
+ super(a);
+ }
+
@Id
@GeneratedValue
public Long getId() {
Added: core/branches/Branch_3_5/entitymanager/src/test/java/org/hibernate/ejb/test/util/CopyrightableContent.java
===================================================================
--- core/branches/Branch_3_5/entitymanager/src/test/java/org/hibernate/ejb/test/util/CopyrightableContent.java (rev 0)
+++ core/branches/Branch_3_5/entitymanager/src/test/java/org/hibernate/ejb/test/util/CopyrightableContent.java 2010-05-25 13:31:08 UTC (rev 19603)
@@ -0,0 +1,31 @@
+package org.hibernate.ejb.test.util;
+
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.ManyToOne;
+import javax.persistence.MappedSuperclass;
+
+
+/**
+ * @author Emmanuel Bernard
+ */
+@MappedSuperclass
+public abstract class CopyrightableContent {
+ private Author author;
+
+ public CopyrightableContent() {
+ }
+
+ public CopyrightableContent(Author author) {
+ this.author = author;
+ }
+
+ @ManyToOne(fetch = FetchType.LAZY)
+ private Author getAuthor() {
+ return author;
+ }
+
+ private void setAuthor(Author author) {
+ this.author = author;
+ }
+}
Modified: core/branches/Branch_3_5/entitymanager/src/test/java/org/hibernate/ejb/test/util/GetIdentifierTest.java
===================================================================
--- core/branches/Branch_3_5/entitymanager/src/test/java/org/hibernate/ejb/test/util/GetIdentifierTest.java 2010-05-25 13:30:22 UTC (rev 19602)
+++ core/branches/Branch_3_5/entitymanager/src/test/java/org/hibernate/ejb/test/util/GetIdentifierTest.java 2010-05-25 13:31:08 UTC (rev 19603)
@@ -56,7 +56,8 @@
return new Class[] {
Book.class,
Umbrella.class,
- Sickness.class
+ Sickness.class,
+ Author.class
};
}
}
Added: core/branches/Branch_3_5/entitymanager/src/test/java/org/hibernate/ejb/test/util/IsLoadedTest.java
===================================================================
--- core/branches/Branch_3_5/entitymanager/src/test/java/org/hibernate/ejb/test/util/IsLoadedTest.java (rev 0)
+++ core/branches/Branch_3_5/entitymanager/src/test/java/org/hibernate/ejb/test/util/IsLoadedTest.java 2010-05-25 13:31:08 UTC (rev 19603)
@@ -0,0 +1,36 @@
+package org.hibernate.ejb.test.util;
+
+import javax.persistence.EntityManager;
+
+import org.hibernate.ejb.test.TestCase;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class IsLoadedTest extends TestCase {
+
+ public void testIsLoadedOnPrivateSuperclassProperty() {
+ EntityManager em = factory.createEntityManager();
+ em.getTransaction().begin();
+ Author a = new Author();
+ Book book = new Book(a);
+ em.persist( a );
+ em.persist( book );
+ em.flush();
+ em.clear();
+ book = em.find( Book.class, book.getId() );
+ assertTrue( em.getEntityManagerFactory().getPersistenceUnitUtil().isLoaded( book ) );
+ assertFalse( em.getEntityManagerFactory().getPersistenceUnitUtil().isLoaded( book, "author" ) );
+ em.getTransaction().rollback();
+ em.close();
+ }
+
+ @Override
+ protected Class<?>[] getAnnotatedClasses() {
+ return new Class<?>[] {
+ Author.class,
+ Book.class,
+ CopyrightableContent.class
+ };
+ }
+}
14 years, 7 months
Hibernate SVN: r19602 - core/branches/Branch_3_5/entitymanager/src/test/java/org/hibernate/ejb/test/ejb3configuration.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2010-05-25 09:30:22 -0400 (Tue, 25 May 2010)
New Revision: 19602
Modified:
core/branches/Branch_3_5/entitymanager/src/test/java/org/hibernate/ejb/test/ejb3configuration/EntityManagerSerializationTest.java
Log:
Typo in test
Modified: core/branches/Branch_3_5/entitymanager/src/test/java/org/hibernate/ejb/test/ejb3configuration/EntityManagerSerializationTest.java
===================================================================
--- core/branches/Branch_3_5/entitymanager/src/test/java/org/hibernate/ejb/test/ejb3configuration/EntityManagerSerializationTest.java 2010-05-25 13:08:22 UTC (rev 19601)
+++ core/branches/Branch_3_5/entitymanager/src/test/java/org/hibernate/ejb/test/ejb3configuration/EntityManagerSerializationTest.java 2010-05-25 13:30:22 UTC (rev 19602)
@@ -32,10 +32,10 @@
stream.close();
ByteArrayInputStream byteIn = new ByteArrayInputStream( serialized );
ObjectInputStream in = new ObjectInputStream( byteIn );
- EntityManagerFactory seriallizedFactory = (EntityManagerFactory) in.readObject();
+ EntityManagerFactory serializedFactory = (EntityManagerFactory) in.readObject();
in.close();
byteIn.close();
- EntityManager em = seriallizedFactory.createEntityManager();
+ EntityManager em = serializedFactory.createEntityManager();
//em.getTransaction().begin();
//em.setFlushMode( FlushModeType.NEVER );
Cat cat = new Cat();
14 years, 7 months
Hibernate SVN: r19601 - in core/trunk/entitymanager/src/main/java/org/hibernate/ejb: util and 1 other directory.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2010-05-25 09:08:22 -0400 (Tue, 25 May 2010)
New Revision: 19601
Modified:
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/EntityManagerFactoryImpl.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/HibernatePersistence.java
core/trunk/entitymanager/src/main/java/org/hibernate/ejb/util/PersistenceUtilHelper.java
Log:
HHH-5258 isLoaded and superclasses and private properties now works
Use getDeclaredField and getDeclaredMethod, use the whole class hierarchy
and use a cache to speed up both class hierarchy
and property to Member computation
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/EntityManagerFactoryImpl.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/EntityManagerFactoryImpl.java 2010-05-25 13:07:42 UTC (rev 19600)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/EntityManagerFactoryImpl.java 2010-05-25 13:08:22 UTC (rev 19601)
@@ -65,6 +65,7 @@
private final Metamodel metamodel;
private final HibernatePersistenceUnitUtil util;
private final Map<String,Object> properties;
+ private final PersistenceUtilHelper.MetadataCache cache = new PersistenceUtilHelper.MetadataCache();
@SuppressWarnings( "unchecked" )
public EntityManagerFactoryImpl(
@@ -182,13 +183,15 @@
private static class HibernatePersistenceUnitUtil implements PersistenceUnitUtil, Serializable {
private final HibernateEntityManagerFactory emf;
+ private transient PersistenceUtilHelper.MetadataCache cache;
private HibernatePersistenceUnitUtil(EntityManagerFactoryImpl emf) {
this.emf = emf;
+ this.cache = emf.cache;
}
public boolean isLoaded(Object entity, String attributeName) {
- LoadState state = PersistenceUtilHelper.isLoadedWithoutReference( entity, attributeName );
+ LoadState state = PersistenceUtilHelper.isLoadedWithoutReference( entity, attributeName, cache );
if (state == LoadState.LOADED) {
return true;
}
@@ -196,7 +199,7 @@
return false;
}
else {
- return PersistenceUtilHelper.isLoadedWithReference( entity, attributeName ) != LoadState.NOT_LOADED;
+ return PersistenceUtilHelper.isLoadedWithReference( entity, attributeName, cache ) != LoadState.NOT_LOADED;
}
}
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/HibernatePersistence.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/HibernatePersistence.java 2010-05-25 13:07:42 UTC (rev 19600)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/HibernatePersistence.java 2010-05-25 13:08:22 UTC (rev 19601)
@@ -38,6 +38,7 @@
* @author Gavin King
*/
public class HibernatePersistence extends AvailableSettings implements PersistenceProvider {
+ private final PersistenceUtilHelper.MetadataCache cache = new PersistenceUtilHelper.MetadataCache();
/**
* Get an entity manager factory by its entity manager name, using the specified
@@ -85,11 +86,11 @@
private final ProviderUtil providerUtil = new ProviderUtil() {
public LoadState isLoadedWithoutReference(Object proxy, String property) {
- return PersistenceUtilHelper.isLoadedWithoutReference( proxy, property );
+ return PersistenceUtilHelper.isLoadedWithoutReference( proxy, property, cache );
}
public LoadState isLoadedWithReference(Object proxy, String property) {
- return PersistenceUtilHelper.isLoadedWithReference( proxy, property );
+ return PersistenceUtilHelper.isLoadedWithReference( proxy, property, cache );
}
public LoadState isLoaded(Object o) {
Modified: core/trunk/entitymanager/src/main/java/org/hibernate/ejb/util/PersistenceUtilHelper.java
===================================================================
--- core/trunk/entitymanager/src/main/java/org/hibernate/ejb/util/PersistenceUtilHelper.java 2010-05-25 13:07:42 UTC (rev 19600)
+++ core/trunk/entitymanager/src/main/java/org/hibernate/ejb/util/PersistenceUtilHelper.java 2010-05-25 13:08:22 UTC (rev 19601)
@@ -1,14 +1,21 @@
package org.hibernate.ejb.util;
+import java.io.Serializable;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Member;
import java.lang.reflect.Modifier;
import java.lang.reflect.AccessibleObject;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.WeakHashMap;
import javax.persistence.spi.LoadState;
import javax.persistence.PersistenceException;
+import org.hibernate.AssertionFailure;
import org.hibernate.proxy.HibernateProxy;
import org.hibernate.proxy.LazyInitializer;
import org.hibernate.intercept.FieldInterceptionHelper;
@@ -19,7 +26,7 @@
* @author Emmanuel Bernard
*/
public class PersistenceUtilHelper {
- public static LoadState isLoadedWithoutReference(Object proxy, String property) {
+ public static LoadState isLoadedWithoutReference(Object proxy, String property, MetadataCache cache) {
Object entity;
boolean sureFromUs = false;
if ( proxy instanceof HibernateProxy ) {
@@ -44,7 +51,7 @@
if (isInitialized && interceptor != null) {
//property is loaded according to bytecode enhancement, but is it loaded as far as association?
//it's ours, we can read
- state = isLoaded( get( entity, property ) );
+ state = isLoaded( get( entity, property, cache ) );
//it's ours so we know it's loaded
if (state == LoadState.UNKNOWN) state = LoadState.LOADED;
}
@@ -54,7 +61,7 @@
else if ( sureFromUs ) { //interceptor == null
//property is loaded according to bytecode enhancement, but is it loaded as far as association?
//it's ours, we can read
- state = isLoaded( get( entity, property ) );
+ state = isLoaded( get( entity, property, cache ) );
//it's ours so we know it's loaded
if (state == LoadState.UNKNOWN) state = LoadState.LOADED;
}
@@ -71,32 +78,26 @@
}
}
- public static LoadState isLoadedWithReference(Object proxy, String property) {
+ public static LoadState isLoadedWithReference(Object proxy, String property, MetadataCache cache) {
//for sure we don't instrument and for sure it's not a lazy proxy
- Object object = get(proxy, property);
+ Object object = get(proxy, property, cache);
return isLoaded( object );
}
- private static Object get(Object proxy, String property) {
+ private static Object get(Object proxy, String property, MetadataCache cache) {
final Class<?> clazz = proxy.getClass();
+
try {
- try {
- final Field field = clazz.getField( property );
- setAccessibility( field );
- return field.get( proxy );
+ Member member = cache.getMember( clazz, property );
+ if (member instanceof Field) {
+ return ( (Field) member ).get( proxy );
}
- catch ( NoSuchFieldException e ) {
- final Method method = getMethod( clazz, property );
- if (method != null) {
- setAccessibility( method );
- return method.invoke( proxy );
- }
- else {
- throw new PersistenceException( "Unable to find field or method: "
- + clazz + "#"
- + property);
- }
+ else if (member instanceof Method) {
+ return ( (Method) member ).invoke( proxy );
}
+ else {
+ throw new AssertionFailure( "Member object neither Field nor Method: " + member);
+ }
}
catch ( IllegalAccessException e ) {
throw new PersistenceException( "Unable to access field or method: "
@@ -110,6 +111,27 @@
}
}
+ private static void setAccessibility(Member member) {
+ if ( !Modifier.isPublic( member.getModifiers() ) ) {
+ //Sun's ease of use, sigh...
+ ( ( AccessibleObject ) member ).setAccessible( true );
+ }
+ }
+
+ public static LoadState isLoaded(Object o) {
+ if ( o instanceof HibernateProxy ) {
+ final boolean isInitialized = !( ( HibernateProxy ) o ).getHibernateLazyInitializer().isUninitialized();
+ return isInitialized ? LoadState.LOADED : LoadState.NOT_LOADED;
+ }
+ else if ( o instanceof PersistentCollection ) {
+ final boolean isInitialized = ( ( PersistentCollection ) o ).wasInitialized();
+ return isInitialized ? LoadState.LOADED : LoadState.NOT_LOADED;
+ }
+ else {
+ return LoadState.UNKNOWN;
+ }
+ }
+
/**
* Returns the method with the specified name or <code>null</code> if it does not exist.
*
@@ -135,25 +157,84 @@
}
}
- private static void setAccessibility(Member member) {
- if ( !Modifier.isPublic( member.getModifiers() ) ) {
- //Sun's ease of use, sigh...
- ( ( AccessibleObject ) member ).setAccessible( true );
+ /**
+ * Cache hierarchy and member resolution in a weak hash map
+ */
+ //TODO not really thread-safe
+ public static class MetadataCache implements Serializable {
+ private transient Map<Class<?>, ClassCache> classCache = new WeakHashMap<Class<?>, ClassCache>();
+
+
+ private void readObject(java.io.ObjectInputStream stream) {
+ classCache = new WeakHashMap<Class<?>, ClassCache>();
}
- }
- public static LoadState isLoaded(Object o) {
- if ( o instanceof HibernateProxy ) {
- final boolean isInitialized = !( ( HibernateProxy ) o ).getHibernateLazyInitializer().isUninitialized();
- return isInitialized ? LoadState.LOADED : LoadState.NOT_LOADED;
+ Member getMember(Class<?> clazz, String property) {
+ ClassCache cache = classCache.get( clazz );
+ if (cache == null) {
+ cache = new ClassCache(clazz);
+ classCache.put( clazz, cache );
+ }
+ Member member = cache.members.get( property );
+ if ( member == null ) {
+ member = findMember( clazz, property );
+ cache.members.put( property, member );
+ }
+ return member;
}
- else if ( o instanceof PersistentCollection ) {
- final boolean isInitialized = ( ( PersistentCollection ) o ).wasInitialized();
- return isInitialized ? LoadState.LOADED : LoadState.NOT_LOADED;
+
+ private Member findMember(Class<?> clazz, String property) {
+ final List<Class<?>> classes = getClassHierarchy( clazz );
+
+ for (Class current : classes) {
+ final Field field;
+ try {
+ field = current.getDeclaredField( property );
+ setAccessibility( field );
+ return field;
+ }
+ catch ( NoSuchFieldException e ) {
+ final Method method = getMethod( clazz, property );
+ if (method != null) {
+ setAccessibility( method );
+ return method;
+ }
+ }
+ }
+ //we could not find any match
+ throw new PersistenceException( "Unable to find field or method: "
+ + clazz + "#"
+ + property);
}
- else {
- return LoadState.UNKNOWN;
+
+ private List<Class<?>> getClassHierarchy(Class<?> clazz) {
+ ClassCache cache = classCache.get( clazz );
+ if (cache == null) {
+ cache = new ClassCache(clazz);
+ classCache.put( clazz, cache );
+ }
+ return cache.classHierarchy;
}
+
+ private static List<Class<?>> findClassHierarchy(Class<?> clazz) {
+ List<Class<?>> classes = new ArrayList<Class<?>>();
+ Class<?> current = clazz;
+ do {
+ classes.add( current );
+ current = current.getSuperclass();
+ }
+ while ( current != null );
+ return classes;
+ }
+
+ private static class ClassCache {
+ List<Class<?>> classHierarchy;
+ Map<String, Member> members = new HashMap<String, Member>();
+
+ public ClassCache(Class<?> clazz) {
+ classHierarchy = findClassHierarchy( clazz );
+ }
+ }
}
}
14 years, 7 months
Hibernate SVN: r19600 - core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/util.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2010-05-25 09:07:42 -0400 (Tue, 25 May 2010)
New Revision: 19600
Added:
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/util/Author.java
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/util/CopyrightableContent.java
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/util/IsLoadedTest.java
Modified:
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/util/Book.java
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/util/GetIdentifierTest.java
Log:
HHH-5258 add tests on isLoaded and superclasses and private properties
Copied: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/util/Author.java (from rev 19599, core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/util/Book.java)
===================================================================
--- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/util/Author.java (rev 0)
+++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/util/Author.java 2010-05-25 13:07:42 UTC (rev 19600)
@@ -0,0 +1,24 @@
+package org.hibernate.ejb.test.util;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.Table;
+
+/**
+ * @author Emmanuel Bernard
+ */
+@Entity @Table(name="tbl_Author")
+public class Author {
+ @Id
+ @GeneratedValue
+ private Integer id;
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+}
Modified: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/util/Book.java
===================================================================
--- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/util/Book.java 2010-05-25 13:06:51 UTC (rev 19599)
+++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/util/Book.java 2010-05-25 13:07:42 UTC (rev 19600)
@@ -8,10 +8,18 @@
* @author Emmanuel Bernard
*/
@Entity
-public class Book {
+public class Book extends CopyrightableContent {
private Long id;
private String name;
+ public Book() {
+ super();
+ }
+
+ public Book(Author a) {
+ super(a);
+ }
+
@Id
@GeneratedValue
public Long getId() {
Added: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/util/CopyrightableContent.java
===================================================================
--- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/util/CopyrightableContent.java (rev 0)
+++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/util/CopyrightableContent.java 2010-05-25 13:07:42 UTC (rev 19600)
@@ -0,0 +1,31 @@
+package org.hibernate.ejb.test.util;
+
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.ManyToOne;
+import javax.persistence.MappedSuperclass;
+
+
+/**
+ * @author Emmanuel Bernard
+ */
+@MappedSuperclass
+public abstract class CopyrightableContent {
+ private Author author;
+
+ public CopyrightableContent() {
+ }
+
+ public CopyrightableContent(Author author) {
+ this.author = author;
+ }
+
+ @ManyToOne(fetch = FetchType.LAZY)
+ private Author getAuthor() {
+ return author;
+ }
+
+ private void setAuthor(Author author) {
+ this.author = author;
+ }
+}
Modified: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/util/GetIdentifierTest.java
===================================================================
--- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/util/GetIdentifierTest.java 2010-05-25 13:06:51 UTC (rev 19599)
+++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/util/GetIdentifierTest.java 2010-05-25 13:07:42 UTC (rev 19600)
@@ -56,7 +56,8 @@
return new Class[] {
Book.class,
Umbrella.class,
- Sickness.class
+ Sickness.class,
+ Author.class
};
}
}
Added: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/util/IsLoadedTest.java
===================================================================
--- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/util/IsLoadedTest.java (rev 0)
+++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/util/IsLoadedTest.java 2010-05-25 13:07:42 UTC (rev 19600)
@@ -0,0 +1,36 @@
+package org.hibernate.ejb.test.util;
+
+import javax.persistence.EntityManager;
+
+import org.hibernate.ejb.test.TestCase;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class IsLoadedTest extends TestCase {
+
+ public void testIsLoadedOnPrivateSuperclassProperty() {
+ EntityManager em = factory.createEntityManager();
+ em.getTransaction().begin();
+ Author a = new Author();
+ Book book = new Book(a);
+ em.persist( a );
+ em.persist( book );
+ em.flush();
+ em.clear();
+ book = em.find( Book.class, book.getId() );
+ assertTrue( em.getEntityManagerFactory().getPersistenceUnitUtil().isLoaded( book ) );
+ assertFalse( em.getEntityManagerFactory().getPersistenceUnitUtil().isLoaded( book, "author" ) );
+ em.getTransaction().rollback();
+ em.close();
+ }
+
+ @Override
+ protected Class<?>[] getAnnotatedClasses() {
+ return new Class<?>[] {
+ Author.class,
+ Book.class,
+ CopyrightableContent.class
+ };
+ }
+}
14 years, 7 months
Hibernate SVN: r19599 - core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/ejb3configuration.
by hibernate-commits@lists.jboss.org
Author: epbernard
Date: 2010-05-25 09:06:51 -0400 (Tue, 25 May 2010)
New Revision: 19599
Modified:
core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/ejb3configuration/EntityManagerSerializationTest.java
Log:
Typo in test
Modified: core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/ejb3configuration/EntityManagerSerializationTest.java
===================================================================
--- core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/ejb3configuration/EntityManagerSerializationTest.java 2010-05-25 09:50:12 UTC (rev 19598)
+++ core/trunk/entitymanager/src/test/java/org/hibernate/ejb/test/ejb3configuration/EntityManagerSerializationTest.java 2010-05-25 13:06:51 UTC (rev 19599)
@@ -32,10 +32,10 @@
stream.close();
ByteArrayInputStream byteIn = new ByteArrayInputStream( serialized );
ObjectInputStream in = new ObjectInputStream( byteIn );
- EntityManagerFactory seriallizedFactory = (EntityManagerFactory) in.readObject();
+ EntityManagerFactory serializedFactory = (EntityManagerFactory) in.readObject();
in.close();
byteIn.close();
- EntityManager em = seriallizedFactory.createEntityManager();
+ EntityManager em = serializedFactory.createEntityManager();
//em.getTransaction().begin();
//em.setFlushMode( FlushModeType.NEVER );
Cat cat = new Cat();
14 years, 7 months