Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
   * 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
  * 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.util.Map;
Base class for all constraint definition types. Each sub type represents a single constraint annotation type and allows to add this constraint to a bean class in a programmatic type-safe way with help of the ConstraintMapping API.

<C> The type of a concrete sub type. Following to the "self referencing generic type" pattern each sub type has to be parametrized with itself.
<A> The constraint annotation type represented by a concrete sub type.
Hardy Ferentschik
Gunnar Morling
 public abstract class ConstraintDef<C extends ConstraintDef<C, A>, A extends Annotation> {
 	// Note on visibility of members: These members are intentionally made
 	// protected and published by a sub-class for internal use. There aren't
 	// public getters as they would pollute the fluent definition API.
The constraint annotation type of this definition.
 	protected final Class<A> constraintType;

A map with the annotation parameters of this definition. Keys are property names of this definition's annotation type, values are annotation parameter values of the appropriate types.
 	protected final Map<StringObjectparameters;
 	protected ConstraintDef(Class<A> constraintType) {
 		this. = constraintType;
 		this. = new HashMap<StringObject>();
 	protected ConstraintDef(ConstraintDef<?, A> original) {
 		this. = original.constraintType;
 		this. = original.parameters;
 	private C getThis() {
 		return (C) this;
 	protected C addParameter(String keyObject value) {
 		.putkeyvalue );
 		return getThis();
 	public C message(String message) {
 		addParameter"message"message );
 		return getThis();
 	public C groups(Class<?>... groups) {
 		addParameter"groups"groups );
 		return getThis();
 	public C payload(Class<? extends Payload>... payload) {
 		addParameter"payload"payload );
 		return getThis();
 	public String toString() {
 		final StringBuilder sb = new StringBuilder();
 		sb.appendthis.getClass().getName() );
 		sb.append", constraintType=" ).append );
 		sb.append", parameters=" ).append );
 		sb.append'}' );
 		return sb.toString();
New to GrepCode? Check out our FAQ X