Skip to content

Commit

Permalink
HV-371: Unifying TypeDescriptorImpl and BeanDescriptorImpl in order t…
Browse files Browse the repository at this point in the history
…o simplify handling in BeanMetaDataImpl
  • Loading branch information
gunnarmorling committed Mar 4, 2011
1 parent b9084f6 commit 8dc6142
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 59 deletions.
Expand Up @@ -16,20 +16,27 @@
*/
package org.hibernate.validator.metadata;

import java.lang.reflect.Method;
import java.util.Set;
import javax.validation.metadata.BeanDescriptor;
import javax.validation.metadata.PropertyDescriptor;

import org.hibernate.validator.method.metadata.MethodDescriptor;
import org.hibernate.validator.method.metadata.TypeDescriptor;

/**
* @author Emmanuel Bernard
* @author Hardy Ferentschik
* @author Gunnar Morling
*/
public class BeanDescriptorImpl<T> extends ElementDescriptorImpl implements BeanDescriptor {
public class BeanDescriptorImpl<T> extends ElementDescriptorImpl implements BeanDescriptor, TypeDescriptor {

public BeanDescriptorImpl(BeanMetaData<T> beanMetaData) {
super( beanMetaData.getBeanClass(), beanMetaData );
}

//BeanDescriptor methods

public final boolean isBeanConstrained() {
return getMetaDataBean().getMetaConstraintsAsMap().size() > 0;
}
Expand All @@ -44,4 +51,22 @@ public final PropertyDescriptor getConstraintsForProperty(String propertyName) {
public final Set<PropertyDescriptor> getConstrainedProperties() {
return getMetaDataBean().getConstrainedProperties();
}

//TypeDescriptor methods

public boolean isTypeConstrained() {
throw new UnsupportedOperationException( "Not yet implemented" );
}

public Set<MethodDescriptor> getConstrainedMethods() {
throw new UnsupportedOperationException( "Not yet implemented" );
}

public MethodDescriptor getConstraintsForMethod(Method method) {
throw new UnsupportedOperationException( "Not yet implemented" );
}

public BeanDescriptor getBeanDescriptor() {
return this;
}
}
Expand Up @@ -83,8 +83,6 @@ public final class BeanMetaDataImpl<T> implements BeanMetaData<T> {
*/
private BeanDescriptorImpl<T> beanDescriptor;

private TypeDescriptor typeDescriptor;

/**
* Map of all direct constraints which belong to the entity {@code beanClass}. The constraints are mapped to the class
* (eg super class or interface) in which they are defined.
Expand Down Expand Up @@ -322,10 +320,14 @@ public BeanDescriptor getBeanDescriptor() {
return beanDescriptor;
}

public TypeDescriptor getTypeDescriptor() {
return beanDescriptor;
}

public Set<Member> getCascadedMembers() {
return Collections.unmodifiableSet( cascadedMembers );
}

public Map<Class<?>, List<BeanMetaConstraint<T, ? extends Annotation>>> getMetaConstraintsAsMap() {
return Collections.unmodifiableMap( metaConstraints );
}
Expand Down

This file was deleted.

0 comments on commit 8dc6142

Please sign in to comment.