br.com.anteros.bean.validation.extensions.MethodBeanDescriptorImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of Anteros-Bean-Validation Show documentation
Show all versions of Anteros-Bean-Validation Show documentation
Anteros Bean Validation for Java.
/*******************************************************************************
* Copyright 2012 Anteros Tecnologia
*
* 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 br.com.anteros.bean.validation.extensions;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import br.com.anteros.bean.validation.AnterosFactoryContext;
import br.com.anteros.bean.validation.BeanDescriptorImpl;
import br.com.anteros.bean.validation.model.MetaBean;
/**
* Description: {@link MethodBeanDescriptor} implementation.
*/
class MethodBeanDescriptorImpl extends BeanDescriptorImpl implements MethodBeanDescriptor {
private Map methodConstraints;
private Map, ConstructorDescriptor> constructorConstraints;
/**
* Create a new MethodBeanDescriptorImpl instance.
*
* @param factoryContext
* @param metaBean
*/
protected MethodBeanDescriptorImpl(AnterosFactoryContext factoryContext, MetaBean metaBean) {
super(factoryContext, metaBean);
}
/**
* Set the map of method constraints for this bean.
*
* @param methodConstraints
*/
public void setMethodConstraints(Map methodConstraints) {
this.methodConstraints = methodConstraints;
}
/**
* Set the map of constructor constraints for this bean.
*
* @param constructorConstraints
*/
public void setConstructorConstraints(Map, ConstructorDescriptor> constructorConstraints) {
this.constructorConstraints = constructorConstraints;
}
/**
* {@inheritDoc}
*/
public MethodDescriptor getConstraintsForMethod(Method method) {
return methodConstraints.get(method);
}
/**
* {@inheritDoc}
*/
public ConstructorDescriptor getConstraintsForConstructor(Constructor> constructor) {
return constructorConstraints.get(constructor);
}
/**
* {@inheritDoc}
*/
public Set getConstrainedMethods() {
return new HashSet(methodConstraints.values());
}
/**
* Add a {@link MethodDescriptor} to this {@link MethodBeanDescriptorImpl}.
*
* @param method
* @param desc
*/
public void putMethodDescriptor(Method method, MethodDescriptor desc) {
methodConstraints.put(method, desc);
}
/**
* {@inheritDoc}
*/
public Set getConstrainedConstructors() {
return new HashSet(this.constructorConstraints.values());
}
/**
* Add a {@link ConstructorDescriptor} to this
* {@link MethodBeanDescriptorImpl}.
*
* @param cons
* @param desc
*/
public void putConstructorDescriptor(Constructor> cons, ConstructorDescriptor desc) {
constructorConstraints.put(cons, desc);
}
/**
* Get the configured method constraints.
*
* @return {@link Map} of {@link Method} : {@link MethodDescriptor}
*/
public Map getMethodConstraints() {
return methodConstraints;
}
/**
* Get the configured constructor constraints.
*
* @return {@link Map} of {@link Constructor} :
* {@link ConstructorDescriptor}
*/
public Map, ConstructorDescriptor> getConstructorConstraints() {
return constructorConstraints;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy