001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.wicket.bean.validation; 018 019import java.lang.annotation.Annotation; 020 021import javax.validation.Validator; 022import javax.validation.metadata.ConstraintDescriptor; 023 024import org.apache.wicket.markup.html.form.FormComponent; 025 026/** 027 * A read-only view of {@link BeanValidationConfiguration} that can be retrieved by components to 028 * access the validator and other helpers. 029 * 030 * @see BeanValidationConfiguration#get() 031 * 032 * @author igor 033 * 034 */ 035public interface BeanValidationContext extends IPropertyResolver 036{ 037 038 /** 039 * Gets the tag modifier for the specified annotation type 040 * 041 * @param annotationType 042 * @return tag modifier or {@code null} if none 043 */ 044 <T extends Annotation> ITagModifier<T> getTagModifier(Class<T> annotationType); 045 046 /** 047 * @return the validator 048 */ 049 Validator getValidator(); 050 051 /** 052 * @return the violation translator 053 */ 054 IViolationTranslator getViolationTranslator(); 055 056 /** 057 * Resolve the property for a component. 058 * 059 * @param component component 060 */ 061 @Override 062 Property resolveProperty(FormComponent<?> component); 063 064 /** 065 * Does the given constraint make a component required. 066 * 067 * @param constraint constraint 068 * @return <code>true</code> if required 069 */ 070 boolean isRequiredConstraint(ConstraintDescriptor<?> constraint); 071}