• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java BeanDescriptor类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中javax.validation.metadata.BeanDescriptor的典型用法代码示例。如果您正苦于以下问题:Java BeanDescriptor类的具体用法?Java BeanDescriptor怎么用?Java BeanDescriptor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



BeanDescriptor类属于javax.validation.metadata包,在下文中一共展示了BeanDescriptor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: resolveForProperty

import javax.validation.metadata.BeanDescriptor; //导入依赖的package包/类
@Override
public List<Constraint> resolveForProperty(String property, Class<?> clazz) {
    List<Constraint> constraints = new ArrayList<>();

    String[] properties = property.split("\\.");
    Class<?> clazzforLoop = clazz;
    for (int i = 0; i < properties.length; i++) {
        String propertyForLoop = properties[i];
        propertyForLoop = propertyForLoop.replace("[]", "");

        BeanDescriptor beanDescriptor = this.validator.getConstraintsForClass(clazzforLoop);
        PropertyDescriptor propertyDescriptor = beanDescriptor.getConstraintsForProperty(
                propertyForLoop);
        if (propertyDescriptor != null) {
            if (isLastElement(properties, i)) {
                collectConstraints(constraints, propertyDescriptor);
            }
            clazzforLoop = getFollowUpClass(propertyDescriptor, clazzforLoop);
        } else {
            break;
        }
    }
    return constraints;
}
 
开发者ID:uweschaefer,项目名称:factcast,代码行数:25,代码来源:ValidatorConstraintResolver.java


示例2: initBeanValidator

import javax.validation.metadata.BeanDescriptor; //导入依赖的package包/类
protected void initBeanValidator() {
    MetadataTools metadataTools = AppBeans.get(MetadataTools.NAME);
    MetaClass propertyEnclosingMetaClass = metadataTools.getPropertyEnclosingMetaClass(metaPropertyPath);
    Class enclosingJavaClass = propertyEnclosingMetaClass.getJavaClass();

    if (enclosingJavaClass != KeyValueEntity.class
            && !DynamicAttributesUtils.isDynamicAttribute(metaProperty)) {
        BeanValidation beanValidation = AppBeans.get(BeanValidation.NAME);
        javax.validation.Validator validator = beanValidation.getValidator();
        BeanDescriptor beanDescriptor = validator.getConstraintsForClass(enclosingJavaClass);

        if (beanDescriptor.isBeanConstrained()) {
            addValidator(new BeanValidator(enclosingJavaClass, metaProperty.getName()));
        }
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:17,代码来源:WebAbstractField.java


示例3: getPropertyDescriptor

import javax.validation.metadata.BeanDescriptor; //导入依赖的package包/类
/**
 * @return PropertyDescriptor may be null when JavaBean do not have any Bean Validation
 *         annotations.
 */
private PropertyDescriptor getPropertyDescriptor() throws JspException {
    String path = getBindStatus().getPath();
    int dotPos = path.indexOf('.');
    if (dotPos == -1) {
        return null;
    }
    String beanName = path.substring(0, dotPos);
    String expression = path.substring(dotPos + 1);

    Map<String, Object> model = getRequestContext().getModel();
    Object bean = getBean(beanName, model);

    Validator validator = getRequestContext().getWebApplicationContext().getBean(Validator.class);
    BeanDescriptor constraints = validator.getConstraintsForClass(bean.getClass());
    return constraints.getConstraintsForProperty(expression);
}
 
开发者ID:arey,项目名称:spring-mvc-toolkit,代码行数:21,代码来源:Html5InputTag.java


示例4: applyDDL

import javax.validation.metadata.BeanDescriptor; //导入依赖的package包/类
private static void applyDDL(
		String prefix,
		PersistentClass persistentClass,
		Class<?> clazz,
		ValidatorFactory factory,
		Set<Class<?>> groups,
		boolean activateNotNull,
		Dialect dialect) {
	final BeanDescriptor descriptor = factory.getValidator().getConstraintsForClass( clazz );
	//no bean level constraints can be applied, go to the properties

	for ( PropertyDescriptor propertyDesc : descriptor.getConstrainedProperties() ) {
		Property property = findPropertyByName( persistentClass, prefix + propertyDesc.getPropertyName() );
		boolean hasNotNull;
		if ( property != null ) {
			hasNotNull = applyConstraints(
					propertyDesc.getConstraintDescriptors(), property, propertyDesc, groups, activateNotNull, dialect
			);
			if ( property.isComposite() && propertyDesc.isCascaded() ) {
				Class<?> componentClass = ( (Component) property.getValue() ).getComponentClass();

				/*
				 * we can apply not null if the upper component let's us activate not null
				 * and if the property is not null.
				 * Otherwise, all sub columns should be left nullable
				 */
				final boolean canSetNotNullOnColumns = activateNotNull && hasNotNull;
				applyDDL(
						prefix + propertyDesc.getPropertyName() + ".",
						persistentClass, componentClass, factory, groups,
						canSetNotNullOnColumns,
                           dialect
				);
			}
			//FIXME add collection of components
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:39,代码来源:TypeSafeActivator.java


示例5: validate

import javax.validation.metadata.BeanDescriptor; //导入依赖的package包/类
@Override
public <T> Set<ConstraintViolation<T>> validate(final T object, final Class<?>... groups) {
    final MinijaxConstraintValidatorContext<T> context = new MinijaxConstraintValidatorContext<>(object);
    final BeanDescriptor descriptor = getConstraintsForClass(object.getClass());

    for (final PropertyDescriptor propertyDescriptor : descriptor.getConstrainedProperties()) {
        final Object value = ((MinijaxPropertyDescriptor) propertyDescriptor).getValue(object);
        validateProperty(context, propertyDescriptor, value);
    }

    return context.getResult();
}
 
开发者ID:minijax,项目名称:minijax,代码行数:13,代码来源:MinijaxValidator.java


示例6: validateProperty

import javax.validation.metadata.BeanDescriptor; //导入依赖的package包/类
@Override
public <T> Set<ConstraintViolation<T>> validateProperty(final T object, final String propertyName, final Class<?>... groups) {
    final MinijaxConstraintValidatorContext<T> context = new MinijaxConstraintValidatorContext<>(object);
    final BeanDescriptor descriptor = getConstraintsForClass(object.getClass());
    final PropertyDescriptor propertyDescriptor = descriptor.getConstraintsForProperty(propertyName);
    final Object value = ((MinijaxPropertyDescriptor) propertyDescriptor).getValue(object);
    validateProperty(context, propertyDescriptor, value);
    return context.getResult();
}
 
开发者ID:minijax,项目名称:minijax,代码行数:10,代码来源:MinijaxValidator.java


示例7: GwtValidationContext

import javax.validation.metadata.BeanDescriptor; //导入依赖的package包/类
private GwtValidationContext(final Class<T> rootBeanClass, final T rootBean,
    final BeanDescriptor beanDescriptor, final MessageInterpolator messageInterpolator,
    final TraversableResolver traversableResolver, final AbstractGwtValidator validator,
    final Set<Object> validatedObjects) {
  this.rootBeanClass = rootBeanClass;
  this.rootBean = rootBean;
  this.beanDescriptor = beanDescriptor;
  this.messageInterpolator = messageInterpolator;
  this.traversableResolver = traversableResolver;
  this.validator = validator;
  this.validatedObjects = new HashSet<>(validatedObjects);
}
 
开发者ID:ManfredTremmel,项目名称:gwt-bean-validators,代码行数:13,代码来源:GwtValidationContext.java


示例8: compose

import javax.validation.metadata.BeanDescriptor; //导入依赖的package包/类
@Override
protected void compose(final ClassSourceFileComposerFactory composerFactory) {
  this.addImports(composerFactory, GWT.class, GwtBeanDescriptor.class, GwtSpecificValidator.class,
      GwtValidationContext.class, ValidationGroupsMetadata.class, Set.class, HashSet.class,
      Map.class, HashMap.class, Default.class, ConstraintViolation.class, BeanDescriptor.class);
  composerFactory.setSuperclass(AbstractGwtValidator.class.getCanonicalName());
  composerFactory.addImplementedInterface(this.validatorType.getQualifiedSourceName());
}
 
开发者ID:ManfredTremmel,项目名称:gwt-bean-validators,代码行数:9,代码来源:ValidatorCreator.java


示例9: doCreateHelper

import javax.validation.metadata.BeanDescriptor; //导入依赖的package包/类
private BeanHelper doCreateHelper(final Class<?> clazz, final JClassType beanType,
    final TreeLogger logger, final GeneratorContext context) throws UnableToCompleteException {
  BeanHelper helper = this.getBean(beanType);
  if (helper == null) {
    BeanDescriptor bean;
    try {
      bean = this.serverSideValidator.getConstraintsForClass(clazz);
    } catch (final ValidationException e) {
      logger.log(TreeLogger.ERROR, "Unable to create a validator for " + clazz.getCanonicalName()
          + " because " + e.getMessage(), e);
      throw new UnableToCompleteException(); // NOPMD
    }
    helper = new BeanHelper(beanType, clazz, bean);
    this.cache.put(helper.getJClass(), helper);

    this.writeInterface(context, logger, helper);

    // now recurse on all Cascaded elements
    for (final PropertyDescriptor p : bean.getConstrainedProperties()) {
      // TODO(idol) only bother creating objects for properties that have constrains in the groups
      // specified in @GwtValidation, but not others
      if (p.isCascaded()) {
        this.doCreateHelperForProp(p, helper, logger, context);
      }
    }
  }
  return helper;
}
 
开发者ID:ManfredTremmel,项目名称:gwt-bean-validators,代码行数:29,代码来源:BeanHelperCache.java


示例10: BeanHelper

import javax.validation.metadata.BeanDescriptor; //导入依赖的package包/类
/**
 * Shouldn't be created directly; instead use BeanHelperCache.
 */
BeanHelper(final JClassType pjclass, final Class<?> pclazz,
    final BeanDescriptor pbeanDescriptor) {
  this.beanDescriptor = pbeanDescriptor;
  this.jclass = pjclass;
  this.clazz = pclazz;
}
 
开发者ID:ManfredTremmel,项目名称:gwt-bean-validators,代码行数:10,代码来源:BeanHelper.java


示例11: buildValidator

import javax.validation.metadata.BeanDescriptor; //导入依赖的package包/类
public Validator<?> buildValidator(Class<?> beanClass, String propertyName) {
	javax.validation.Validator beanValidator = getDefaultValidator();
	if (beanValidator != null) {
		BeanDescriptor descriptor = beanValidator.getConstraintsForClass(beanClass);

		PropertyDescriptor propDescriptor = descriptor.getConstraintsForProperty(propertyName);
		if (propDescriptor != null && propDescriptor.hasConstraints()) {
			return new JSR303BeanValidator(beanClass, propertyName);
		}
	}
	return null;
}
 
开发者ID:frincon,项目名称:abstractform,代码行数:13,代码来源:BeanValidationProvider.java


示例12: hasConstraints

import javax.validation.metadata.BeanDescriptor; //导入依赖的package包/类
/**
 * Only accepts if method isn't parameterless and have at least one constraint.
 */
private boolean hasConstraints(ControllerMethod controllerMethod) {
	Method method = controllerMethod.getMethod();
	if (method.getParameterTypes().length == 0) {
		logger.debug("method {} has no parameters, skipping", controllerMethod);
		return false;
	}
	BeanDescriptor bean = bvalidator.getConstraintsForClass(controllerMethod.getController().getType());
	if(bean == null) {
		return false;
	}
	MethodDescriptor descriptor = bean.getConstraintsForMethod(method.getName(), method.getParameterTypes());
	return descriptor != null && descriptor.hasConstrainedParameters();
}
 
开发者ID:caelum,项目名称:vraptor4,代码行数:17,代码来源:MethodValidator.java


示例13: testPropertyDescriptorHasConstraints

import javax.validation.metadata.BeanDescriptor; //导入依赖的package包/类
public void testPropertyDescriptorHasConstraints() {
    BeanDescriptor cons = validator.getConstraintsForClass(Book.class);
    Assert.assertTrue(cons.getConstraintsForProperty("author").hasConstraints());
    Assert.assertTrue(cons.getConstraintsForProperty("title").hasConstraints());
    Assert.assertTrue(cons.getConstraintsForProperty("uselessField").hasConstraints());
    // cons.getConstraintsForProperty("unconstraintField") == null without
    // Introspector
    // cons.getConstraintsForProperty("unconstraintField") != null with
    // Introspector
    assertTrue(cons.getConstraintsForProperty("unconstraintField") == null
            || !cons.getConstraintsForProperty("unconstraintField").hasConstraints());
    assertNull(cons.getConstraintsForProperty("unknownField"));
}
 
开发者ID:xuzhikethinker,项目名称:t4f-data,代码行数:14,代码来源:Jsr303Test.java


示例14: testMetadataAPI_Book

import javax.validation.metadata.BeanDescriptor; //导入依赖的package包/类
public void testMetadataAPI_Book() {
    Assert.assertNotNull(validator.getConstraintsForClass(Book.class));
    // not necessary for implementation correctness, but we'll test
    // nevertheless:
    Assert.assertSame(validator.getConstraintsForClass(Book.class), validator.getConstraintsForClass(Book.class));
    BeanDescriptor bc = validator.getConstraintsForClass(Book.class);
    // assertEquals(ElementType.TYPE, bc.getElementType());
    Assert.assertEquals(Book.class, bc.getElementClass());
    // assertEquals(false, bc.isCascaded());
    // assertEquals("", bc.getPropertyPath());
    Assert.assertTrue(bc.getConstraintDescriptors() != null);
    TestUtils.failOnModifiable(bc.getConstraintDescriptors(), "beanDescriptor constraintDescriptors");
}
 
开发者ID:xuzhikethinker,项目名称:t4f-data,代码行数:14,代码来源:Jsr303Test.java


示例15: getConstraintDescriptors

import javax.validation.metadata.BeanDescriptor; //导入依赖的package包/类
@Override
public Set<ConstraintDescriptor<?>> getConstraintDescriptors(final Object keyObj) {
	String key = String.valueOf(keyObj);
	final Validator validator = Validation.byDefaultProvider().configure().buildValidatorFactory().getValidator();

	BeanDescriptor beanDesc = validator.getConstraintsForClass(getClass());
	for(PropertyDescriptor prop : beanDesc.getConstrainedProperties()) {
		if(prop.getPropertyName().equalsIgnoreCase(key)) {
			return prop.getConstraintDescriptors();
		}
	}
	return new HashSet<ConstraintDescriptor<?>>();
}
 
开发者ID:jesse-gallagher,项目名称:XPages-Scaffolding,代码行数:14,代码来源:AbstractModelObject.java


示例16: getConstraintsForClass

import javax.validation.metadata.BeanDescriptor; //导入依赖的package包/类
@Override
public BeanDescriptor getConstraintsForClass(Class<?> clazz) {
	Assert.notNull(this.targetValidator, "No target Validator set");
	return this.targetValidator.getConstraintsForClass(clazz);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:6,代码来源:SpringValidatorAdapter.java


示例17: getConstraintsForClass

import javax.validation.metadata.BeanDescriptor; //导入依赖的package包/类
@Override
public BeanDescriptor getConstraintsForClass(Class<?> clazz) {
    throw new ValidationException(this.getClass().getName() + " does not implement getConstraintsForClass()");
}
 
开发者ID:Nike-Inc,项目名称:backstopper,代码行数:5,代码来源:NoOpJsr303Validator.java


示例18: getConstraintsForClass

import javax.validation.metadata.BeanDescriptor; //导入依赖的package包/类
@Override
public BeanDescriptor getConstraintsForClass(Class<?> clazz) {
	Assert.state(this.targetValidator != null, "No target Validator set");
	return this.targetValidator.getConstraintsForClass(clazz);
}
 
开发者ID:txazo,项目名称:spring,代码行数:6,代码来源:SpringValidatorAdapter.java


示例19: getConstraintsForClass

import javax.validation.metadata.BeanDescriptor; //导入依赖的package包/类
@Override
public BeanDescriptor getConstraintsForClass(Class<?> clazz) {
  return null;
}
 
开发者ID:domenique,项目名称:tripled-framework,代码行数:5,代码来源:TestValidator.java


示例20: getConstraintsForClass

import javax.validation.metadata.BeanDescriptor; //导入依赖的package包/类
@Override
public BeanDescriptor getConstraintsForClass(Class<?> clazz) {
    return null;
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:5,代码来源:AbstractValidationTest.java



注:本文中的javax.validation.metadata.BeanDescriptor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MysqlIO类代码示例发布时间:2022-05-21
下一篇:
Java Maps类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap