remove obsolete modules, moving required core code to jsr
Project: http://git-wip-us.apache.org/repos/asf/bval/repo Commit: http://git-wip-us.apache.org/repos/asf/bval/commit/ed299e4f Tree: http://git-wip-us.apache.org/repos/asf/bval/tree/ed299e4f Diff: http://git-wip-us.apache.org/repos/asf/bval/diff/ed299e4f Branch: refs/heads/bv2 Commit: ed299e4f15527f8eb1b90ac279b4b82d6e40cf8c Parents: 92c64b3 Author: Matt Benson <[email protected]> Authored: Sun Feb 25 14:10:25 2018 -0600 Committer: Matt Benson <[email protected]> Committed: Sun Feb 25 14:10:25 2018 -0600 ---------------------------------------------------------------------- bval-core/pom.xml | 165 -- .../main/appended-resources/META-INF/NOTICE.vm | 25 - .../org/apache/bval/BeanValidationContext.java | 355 ---- .../java/org/apache/bval/BeanValidator.java | 282 ---- .../java/org/apache/bval/ConstructorAccess.java | 81 - .../java/org/apache/bval/DynamicMetaBean.java | 48 - .../bval/IntrospectorMetaBeanFactory.java | 112 -- .../java/org/apache/bval/MetaBeanBuilder.java | 134 -- .../java/org/apache/bval/MetaBeanCache.java | 113 -- .../java/org/apache/bval/MetaBeanFactory.java | 32 - .../java/org/apache/bval/MetaBeanFinder.java | 40 - .../java/org/apache/bval/MetaBeanManager.java | 154 -- .../org/apache/bval/MetaBeanManagerFactory.java | 45 - .../src/main/java/org/apache/bval/Validate.java | 44 - .../java/org/apache/bval/ValidationResults.java | 236 --- .../java/org/apache/bval/model/DynaType.java | 31 - .../org/apache/bval/model/DynaTypeEnum.java | 121 -- .../java/org/apache/bval/model/Features.java | 117 -- .../org/apache/bval/model/FeaturesCapable.java | 186 --- .../main/java/org/apache/bval/model/Meta.java | 29 - .../org/apache/bval/model/MetaAnnotated.java | 44 - .../java/org/apache/bval/model/MetaBean.java | 378 ----- .../org/apache/bval/model/MetaConstructor.java | 34 - .../org/apache/bval/model/MetaInvocable.java | 40 - .../java/org/apache/bval/model/MetaMethod.java | 34 - .../org/apache/bval/model/MetaParameter.java | 42 - .../org/apache/bval/model/MetaProperty.java | 164 -- .../java/org/apache/bval/model/Validation.java | 30 - .../apache/bval/model/ValidationContext.java | 137 -- .../apache/bval/model/ValidationListener.java | 99 -- .../bval/routines/EMailValidationUtils.java | 75 - .../org/apache/bval/util/AccessStrategy.java | 59 - .../java/org/apache/bval/util/BValVersion.java | 195 --- .../bval/util/BeanUtilsPropertyAccess.java | 44 - .../java/org/apache/bval/util/Exceptions.java | 125 -- .../java/org/apache/bval/util/FieldAccess.java | 116 -- .../org/apache/bval/util/IndexedAccess.java | 121 -- .../java/org/apache/bval/util/KeyedAccess.java | 121 -- .../main/java/org/apache/bval/util/Lazy.java | 62 - .../main/java/org/apache/bval/util/LazyInt.java | 49 - .../java/org/apache/bval/util/MethodAccess.java | 151 -- .../java/org/apache/bval/util/ObjectUtils.java | 98 -- .../org/apache/bval/util/ObjectWrapper.java | 50 - .../org/apache/bval/util/PropertyAccess.java | 336 ---- .../java/org/apache/bval/util/StringUtils.java | 149 -- .../java/org/apache/bval/util/Validate.java | 59 - .../org/apache/bval/util/ValidationHelper.java | 239 --- .../apache/bval/util/reflection/Reflection.java | 457 ----- .../apache/bval/util/reflection/TypeUtils.java | 1557 ------------------ .../org/apache/bval/ValidationResultsTest.java | 52 - .../java/org/apache/bval/model/ExampleEnum.java | 27 - .../org/apache/bval/model/MetaPropertyTest.java | 43 - .../org/apache/bval/util/StringUtilsTest.java | 32 - bval-core/src/test/resources/log4j.xml | 41 - bval-json/pom.xml | 76 - .../main/appended-resources/META-INF/NOTICE.vm | 25 - .../org/apache/bval/json/JSONGenerator.java | 76 - .../org/apache/bval/json/bean-infos-json.ftl | 85 - .../org/apache/bval/json/JSONGeneratorTest.java | 104 -- bval-jsr/pom.xml | 69 +- .../bval/routines/EMailValidationUtils.java | 75 + .../java/org/apache/bval/util/BValVersion.java | 195 +++ .../java/org/apache/bval/util/Exceptions.java | 125 ++ .../main/java/org/apache/bval/util/Lazy.java | 62 + .../main/java/org/apache/bval/util/LazyInt.java | 49 + .../java/org/apache/bval/util/ObjectUtils.java | 98 ++ .../org/apache/bval/util/ObjectWrapper.java | 50 + .../java/org/apache/bval/util/StringUtils.java | 149 ++ .../java/org/apache/bval/util/Validate.java | 59 + .../apache/bval/util/reflection/Reflection.java | 457 +++++ .../apache/bval/util/reflection/TypeUtils.java | 1557 ++++++++++++++++++ .../org/apache/bval/jsr/TckReproducerTest.java | 25 +- bval-xstream/findbugs-exclude-filter.xml | 31 - bval-xstream/pom.xml | 102 -- .../apache/bval/routines/EMailValidation.java | 49 - .../org/apache/bval/routines/NOPValidation.java | 32 - .../java/org/apache/bval/routines/Reasons.java | 31 - .../bval/routines/StandardValidation.java | 192 --- .../org/apache/bval/xml/MetaBeanEnricher.java | 37 - .../org/apache/bval/xml/XMLFeaturesCapable.java | 100 -- .../java/org/apache/bval/xml/XMLMapper.java | 44 - .../java/org/apache/bval/xml/XMLMetaBean.java | 161 -- .../org/apache/bval/xml/XMLMetaBeanBuilder.java | 185 --- .../org/apache/bval/xml/XMLMetaBeanFactory.java | 234 --- .../org/apache/bval/xml/XMLMetaBeanInfos.java | 139 -- .../org/apache/bval/xml/XMLMetaBeanLoader.java | 26 - .../org/apache/bval/xml/XMLMetaBeanManager.java | 138 -- .../bval/xml/XMLMetaBeanManagerFactory.java | 62 - .../apache/bval/xml/XMLMetaBeanReference.java | 58 - .../apache/bval/xml/XMLMetaBeanRegistry.java | 35 - .../apache/bval/xml/XMLMetaBeanURLLoader.java | 46 - .../org/apache/bval/xml/XMLMetaElement.java | 148 -- .../org/apache/bval/xml/XMLMetaFeature.java | 60 - .../org/apache/bval/xml/XMLMetaProperty.java | 104 -- .../org/apache/bval/xml/XMLMetaValidator.java | 77 - .../bval/xml/XMLMetaValidatorReference.java | 49 - .../java/org/apache/bval/xml/XMLMetaValue.java | 34 - .../org/apache/bval/example/BusinessEnum.java | 24 - .../org/apache/bval/example/BusinessObject.java | 125 -- .../bval/example/BusinessObjectAddress.java | 49 - .../bval/example/BusinessObjectBeanInfo.java | 64 - .../bval/routines/StandardValidationTest.java | 224 --- .../org/apache/bval/xml/BeanValidatorTest.java | 105 -- .../apache/bval/xml/XMLMetaBeanInfosTest.java | 143 -- .../apache/bval/xml/XMLMetaBeanManagerTest.java | 93 -- .../bval/example/test-beanInfos-custom.xml | 31 - .../org/apache/bval/example/test-beanInfos.xml | 77 - pom.xml | 12 +- 108 files changed, 2953 insertions(+), 11114 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/bval/blob/ed299e4f/bval-core/pom.xml ---------------------------------------------------------------------- diff --git a/bval-core/pom.xml b/bval-core/pom.xml deleted file mode 100644 index b7a7f8b..0000000 --- a/bval-core/pom.xml +++ /dev/null @@ -1,165 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you 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. ---> -<!-- - Maven release plugin requires the project tag to be on a single line. ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.bval</groupId> - <artifactId>bval-parent</artifactId> - <version>2.0.0-SNAPSHOT</version> - </parent> - - <artifactId>bval-core</artifactId> - <name>Apache BVal :: bval-core</name> - <packaging>jar</packaging> - - <description>BVal Metadata Engine</description> - - <dependencies> - <!-- we only support validation in DynaBeans, but do not use c-beanutils in BVal itself --> - <dependency> - <groupId>commons-beanutils</groupId> - <artifactId>commons-beanutils-core</artifactId> - <optional>true</optional> - </dependency> - <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-weaver-privilizer-api</artifactId> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - </dependencies> - - <build> - <plugins> - <!-- - get the svn revision number and project version - and set it in a properties file for later retrieval - --> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-antrun-plugin</artifactId> - <executions> - <execution> - <id>set subversion revision</id> - <phase>compile</phase> - <configuration> - <target> - <echo>Version: ${project.version}</echo> - <echo>Revision: ${buildNumber}</echo> - <echo>Date: ${timestamp}</echo> - <mkdir dir="${project.build.outputDirectory}/META-INF" /> - <echo file="${project.build.outputDirectory}/META-INF/org.apache.bval.revision.properties"> -# Licensed under Apache License 2.0 - http://www.apache.org/licenses/LICENSE-2.0 -project.name=Apache BVal -project.version=${project.version} -svn.revision=${buildNumber} -svn.branch=${scmBranch} -build.timestamp=${timestamp} - </echo> - </target> - </configuration> - <goals> - <goal>run</goal> - </goals> - </execution> - </executions> - </plugin> - - <!-- create mainClass attribute --> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-jar-plugin</artifactId> - <executions> - <execution> - <id>default-jar</id> - <goals> - <goal>jar</goal> - </goals> - <configuration> - <archive> - <manifest> - <addDefaultImplementationEntries>true</addDefaultImplementationEntries> - <mainClass>org.apache.bval.util.BValVersion</mainClass> - </manifest> - <manifestEntries> - <Implementation-Build>${buildNumber}</Implementation-Build> - </manifestEntries> - </archive> - </configuration> - </execution> - <execution> - <id>attach-tests</id> - <goals> - <goal>test-jar</goal> - </goals> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.apache.commons</groupId> - <artifactId>commons-weaver-maven-plugin</artifactId> - </plugin> - </plugins> - <pluginManagement> - <plugins> - <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.--> - <plugin> - <groupId>org.eclipse.m2e</groupId> - <artifactId>lifecycle-mapping</artifactId> - <version>1.0.0</version> - <configuration> - <lifecycleMappingMetadata> - <pluginExecutions> - <pluginExecution> - <pluginExecutionFilter> - <groupId> - org.apache.maven.plugins - </groupId> - <artifactId> - maven-antrun-plugin - </artifactId> - <versionRange> - [1.3,) - </versionRange> - <goals> - <goal>run</goal> - </goals> - </pluginExecutionFilter> - <action> - <ignore /> - </action> - </pluginExecution> - </pluginExecutions> - </lifecycleMappingMetadata> - </configuration> - </plugin> - </plugins> - </pluginManagement> - </build> -</project> - http://git-wip-us.apache.org/repos/asf/bval/blob/ed299e4f/bval-core/src/main/appended-resources/META-INF/NOTICE.vm ---------------------------------------------------------------------- diff --git a/bval-core/src/main/appended-resources/META-INF/NOTICE.vm b/bval-core/src/main/appended-resources/META-INF/NOTICE.vm deleted file mode 100644 index 9a0c1ee..0000000 --- a/bval-core/src/main/appended-resources/META-INF/NOTICE.vm +++ /dev/null @@ -1,25 +0,0 @@ -## -## Licensed to the Apache Software Foundation (ASF) under one -## or more contributor license agreements. See the NOTICE file -## distributed with this work for additional information -## regarding copyright ownership. The ASF licenses this file -## to you 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. -## - -The following copyright notice(s) were affixed to portions of this code -with which this file is now or was at one time distributed. - -This product includes software developed by agimatec GmbH. -Copyright 2007-2010 Agimatec GmbH. All rights reserved. - http://git-wip-us.apache.org/repos/asf/bval/blob/ed299e4f/bval-core/src/main/java/org/apache/bval/BeanValidationContext.java ---------------------------------------------------------------------- diff --git a/bval-core/src/main/java/org/apache/bval/BeanValidationContext.java b/bval-core/src/main/java/org/apache/bval/BeanValidationContext.java deleted file mode 100644 index b0e386b..0000000 --- a/bval-core/src/main/java/org/apache/bval/BeanValidationContext.java +++ /dev/null @@ -1,355 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.apache.bval; - -import org.apache.bval.model.FeaturesCapable; -import org.apache.bval.model.MetaBean; -import org.apache.bval.model.MetaProperty; -import org.apache.bval.model.ValidationContext; -import org.apache.bval.model.ValidationListener; -import org.apache.bval.util.AccessStrategy; -import org.apache.bval.util.PropertyAccess; - -import java.util.IdentityHashMap; -import java.util.Map; - -/** - * Description: Context during validation to help the {@link org.apache.bval.model.Validation} - * and the {@link BeanValidator} do their jobs. - * Used to bundle {@link BeanValidationContext} and {@link ValidationListener} - * together <br/> - * <b>This class is NOT thread-safe: a new instance will be created for each - * validation - * processing per thread.<br/></b> - */ -public class BeanValidationContext<T extends ValidationListener> implements ValidationContext<T> { - /** represent an unknown propertyValue. */ - private static final Object UNKNOWN = new Object() { - @Override - public String toString() { - return "unknown property value"; - } - }; - - /** metainfo of current object. */ - private MetaBean metaBean; - /** current object. */ - private Object bean; - /** metainfo of current property. */ - private MetaProperty metaProperty; - /** - * cached value of current property. - * Cached because of potential redundant access for different Validations - */ - private Object propertyValue = UNKNOWN; - - /** access strategy used for previous access */ - private AccessStrategy access; - - /** set of objects already validated to avoid endless loops. */ - @SuppressWarnings({ "rawtypes" }) - protected Map validatedObjects; - - /** - * true when value is fixed, so that it will NOT be dynamically - * determined from the annotated element or the metaProperty. - * <b><br>Note: When value is UNKNOWN, it will be determined THE FIRST TIME - * IT IS ACCESSED.</b> - */ - private boolean fixed; - - /** listener notified of validation constraint violations. */ - private T listener; - - /** - * Create a new BeanValidationContext instance. - * @param listener - */ - @SuppressWarnings({ "rawtypes" }) - public BeanValidationContext(T listener) { - this(listener, new IdentityHashMap()); - } - - /** - * Create a new BeanValidationContext instance. - * @param listener - * @param validatedMap - */ - @SuppressWarnings({ "rawtypes" }) - protected BeanValidationContext(T listener, Map validatedMap) { - this.listener = listener; - this.validatedObjects = validatedMap; - } - - /** - * {@inheritDoc} - */ - @Override - public T getListener() { - return listener; - } - - /** - * Set the listener. - * @param listener T - */ - public void setListener(T listener) { - this.listener = listener; - } - - /** - * {@inheritDoc} - * Here, state equates to a given bean reference. - */ - @Override - @SuppressWarnings("unchecked") - public boolean collectValidated() { - return validatedObjects.put(getBean(), Boolean.TRUE) == null; - } - - /** - * Learn whether a particular object has been validated. - * @param object - * @return true when the object has already been validated in this context - */ - public boolean isValidated(Object object) { - return validatedObjects.containsKey(object); - } - - /** - * Clear map of validated objects (invoke when you want to 'reuse' the - * context for different validations) - */ - public void resetValidated() { - validatedObjects.clear(); - } - - /** - * {@inheritDoc} - */ - @Override - public void setBean(Object aBean, MetaBean aMetaBean) { - bean = aBean; - metaBean = aMetaBean; - metaProperty = null; - unknownValue(); - } - - /** - * Get the cached value or access it somehow (via field or method)<br> - * <b>you should prefer getPropertyValue(AccessStrategy) instead of this method</b> - * - * @return the current value of the property accessed by reflection - * @throws IllegalArgumentException - error accessing attribute (config error, reflection problem) - * @throws IllegalStateException - when no property is currently set in the context (application logic bug) - */ - @Override - public Object getPropertyValue() { - if (access == null) { // undefined access strategy - return getPropertyValue(PropertyAccess.getInstance(bean.getClass(), metaProperty.getName())); - } - return getPropertyValue(access); - } - - /** - * {@inheritDoc} - * Caches retrieved value. - */ - @Override - public Object getPropertyValue(AccessStrategy access) throws IllegalArgumentException, IllegalStateException { - if (propertyValue == UNKNOWN || (this.access != access && !fixed)) { - propertyValue = access.get(bean); - this.access = access; - } - return propertyValue; - } - - /** - * Convenience method to access metaProperty.name - * - * @return null or the name of the current property - */ - @Override - public String getPropertyName() { - return metaProperty == null ? null : metaProperty.getName(); - } - - /** - * Set the current property value. - * @param propertyValue - */ - public void setPropertyValue(Object propertyValue) { - this.propertyValue = propertyValue; - } - - /** - * Set the property value, fixed. - * @param value - */ - public void setFixedValue(Object value) { - setPropertyValue(value); - setFixed(true); - } - - /** - * Learn whether the current property value is "fixed." - * @return boolean - */ - public boolean isFixed() { - return fixed; - } - - /** - * Potentially declare the current property value as being "fixed." - * If <code>true</code>, the context will reuse any not-<code>UNKNOWN</code> - * propertyValue regardless of the {@link AccessStrategy} by which it is requested. - * @param fixed - */ - public void setFixed(boolean fixed) { - this.fixed = fixed; - } - - /** - * Depending on whether we have a metaProperty or not, - * this returns the metaProperty or otherwise the metaBean. - * This is used to have a simple way to request features - * in the Validation for both bean- and property-level validations. - * - * @return something that is capable to deliver features - */ - public FeaturesCapable getMeta() { - return (metaProperty == null) ? metaBean : metaProperty; - } - - /** - * Drop cached value, marking the internal cachedValue as <code>UNKNOWN</code>. - * This forces the BeanValidationContext to recompute the value - * the next time it is accessed. - * Use this method inside tests or when the propertyValue has been - * changed during validation. - */ - public void unknownValue() { - propertyValue = UNKNOWN; - access = null; - fixed = false; - } - - /** - * {@inheritDoc} - */ - @Override - public MetaBean getMetaBean() { - return metaBean; - } - - /** - * {@inheritDoc} - */ - @Override - public Object getBean() { - return bean; - } - - /** - * {@inheritDoc} - */ - @Override - public MetaProperty getMetaProperty() { - return metaProperty; - } - - /** - * {@inheritDoc} - */ - @Override - public void setMetaBean(MetaBean metaBean) { - this.metaBean = metaBean; - } - - /** - * {@inheritDoc} - */ - @Override - public void setBean(Object bean) { - this.bean = bean; - unknownValue(); - } - - /** - * {@inheritDoc} - */ - @Override - public void setMetaProperty(MetaProperty metaProperty) { - this.metaProperty = metaProperty; - unknownValue(); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return "BeanValidationContext{ bean=" + bean + ", metaProperty=" + metaProperty + ", propertyValue=" - + propertyValue + '}'; - } - - /** - * {@inheritDoc} - */ - @Override - public void moveDown(MetaProperty prop, AccessStrategy access) { - setBean(getPropertyValue(access), prop.getMetaBean()); - } - - @Override - public void moveDown(String prop) { - // no-op: not supported - } - - /** - * {@inheritDoc} - */ - @Override - public void moveUp(Object bean, MetaBean aMetaBean) { - setBean(bean, aMetaBean); // reset context state - } - - /** - * {@inheritDoc} - */ - @Override - public void setCurrentIndex(Integer index) { - // do nothing - } - - /** - * {@inheritDoc} - */ - @Override - public void setCurrentKey(Object key) { - // do nothing - } - - /** - * {@inheritDoc} - */ - @Override - public AccessStrategy getAccess() { - return this.access; - } - -} http://git-wip-us.apache.org/repos/asf/bval/blob/ed299e4f/bval-core/src/main/java/org/apache/bval/BeanValidator.java ---------------------------------------------------------------------- diff --git a/bval-core/src/main/java/org/apache/bval/BeanValidator.java b/bval-core/src/main/java/org/apache/bval/BeanValidator.java deleted file mode 100644 index d4b44b6..0000000 --- a/bval-core/src/main/java/org/apache/bval/BeanValidator.java +++ /dev/null @@ -1,282 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.apache.bval; - -import org.apache.bval.model.Features; -import org.apache.bval.model.MetaBean; -import org.apache.bval.model.MetaProperty; -import org.apache.bval.model.ValidationContext; -import org.apache.bval.model.ValidationListener; -import org.apache.bval.util.AccessStrategy; -import org.apache.bval.util.PropertyAccess; -import org.apache.bval.util.ValidationHelper; - -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; -import java.util.Collection; - -// TODO: centralize treatMapsLikeBeans - -/** - * Description: Top-Level API-class to validate objects or object-trees. You can - * invoke, extend or utilize this class if you need other ways to integrate - * validation in your application. - * <p/> - * This class supports cyclic object graphs by keeping track of validated - * instances in the validation context.<br/> - */ -public class BeanValidator<T extends ValidationListener> { - private final MetaBeanFinder metaBeanFinder; - - /** - * Create a new BeanValidator instance. Convenience constructor. Use the - * global instance of MetaBeanManagerFactory.getFinder(). - */ - public BeanValidator() { - this(MetaBeanManagerFactory.getFinder()); - } - - /** - * Create a new BeanValidator instance. - * - * @param metaBeanFinder - */ - public BeanValidator(MetaBeanFinder metaBeanFinder) { - this.metaBeanFinder = metaBeanFinder; - } - - /** - * Convenience API. validate a root object with all related objects with its - * default metaBean definition. - * - * @param bean - * @return results - validation results found - */ - public T validate(Object bean) { - MetaBean metaBean = getMetaBeanFinder().findForClass(bean.getClass()); - return validate(bean, metaBean); - } - - /** - * Convenience API. validate a root object with all related objects - * according to the metaBean. - * - * @param bean - * - a single bean or a collection of beans (that share the same - * metaBean!) - * @param metaBean - * @return results - validation results found - */ - public T validate(Object bean, MetaBean metaBean) { - ValidationContext<T> context = createContext(); - context.setBean(bean, metaBean); - ValidationHelper.validateContext(context, new BeanValidatorCallback(context), treatMapsLikeBeans); - return context.getListener(); - } - - /** - * Validate the method parameters based on @Validate annotations. - * Requirements: Parameter, that are to be validated must be annotated with @Validate - * - * @param method - * - a method - * @param parameters - * - the parameters suitable to the method - * @return a validation result or null when there was nothing to validate - * @see Validate - */ - public T validateCall(Method method, Object[] parameters) { - if (parameters.length > 0) { - // shortcut (for performance!) - Annotation[][] annotations = method.getParameterAnnotations(); - ValidationContext<T> context = null; - for (int i = 0; i < parameters.length; i++) { - for (Annotation anno : annotations[i]) { - if (anno instanceof Validate) { - if (context == null) { - context = createContext(); - } - if (determineMetaBean((Validate) anno, parameters[i], context)) { - ValidationHelper.validateContext(context, new BeanValidatorCallback(context), - treatMapsLikeBeans); - break; // next parameter - } - } - } - } - return context == null ? null : context.getListener(); - } - return null; - } - - /** - * Determine the metabean for the given object. - * - * @param <VL> - * @param validate - * @param parameter - * @param context - * @return true when validation should happen, false to skip it - */ - protected <VL extends ValidationListener> boolean determineMetaBean(Validate validate, Object parameter, - ValidationContext<VL> context) { - if (validate.value().isEmpty()) { - if (parameter == null) { - return false; - } - Class<?> beanClass; - if (parameter instanceof Collection<?>) { // do not validate empty collection - Collection<?> coll = ((Collection<?>) parameter); - if (coll.isEmpty()) { - return false; - } - beanClass = coll.iterator().next().getClass(); // get first object - } else if (parameter.getClass().isArray()) { - beanClass = parameter.getClass().getComponentType(); - } else { - beanClass = parameter.getClass(); - } - context.setBean(parameter, getMetaBeanFinder().findForClass(beanClass)); - } else { - context.setBean(parameter, getMetaBeanFinder().findForId(validate.value())); - } - return true; - } - - /** - * factory method - overwrite in subclasses - * - * @return ValidationListener of the proper type - */ - @SuppressWarnings("unchecked") - protected T createResults() { - return (T) new ValidationResults(); - } - - /** - * factory method - overwrite in subclasses - * - * @return ValidationContext parameterized with our listener type - */ - protected ValidationContext<T> createContext() { - return new BeanValidationContext<T>(createResults()); - } - - /** - * Convenience API. validate a single property. - * - * @param bean - * - the root object - * @param metaProperty - * - metadata for the property - * @return validation results - */ - public T validateProperty(Object bean, MetaProperty metaProperty) { - ValidationContext<T> context = createContext(); - context.setBean(bean); - context.setMetaProperty(metaProperty); - ValidationHelper.validateProperty(context); - return context.getListener(); - } - - /** - * {@inheritDoc} internal validate a bean (=not a collection of beans) and - * its related beans - */ - protected <VL extends ValidationListener> void validateBeanNet(ValidationContext<VL> context) { - if (context.collectValidated()) { - ValidationHelper.validateBean(context); - for (MetaProperty prop : context.getMetaBean().getProperties()) { - validateRelatedBean(context, prop); - } - } - } - - /** - * Validate a property of a graph. - * - * @param <VL> - * @param context - * @param prop - */ - protected <VL extends ValidationListener> void validateRelatedBean(ValidationContext<VL> context, - MetaProperty prop) { - AccessStrategy[] access = prop.getFeature(Features.Property.REF_CASCADE); - if (access == null && prop.getMetaBean() != null) { // single property access strategy - // save old values from context - final Object bean = context.getBean(); - final MetaBean mbean = context.getMetaBean(); - // modify context state for relationship-target bean - context.moveDown(prop, PropertyAccess.getInstance(bean.getClass(), prop.getName())); - ValidationHelper.validateContext(context, new BeanValidatorCallback(context), treatMapsLikeBeans); - // restore old values in context - context.moveUp(bean, mbean); - } else if (access != null) { // different accesses to relation - // save old values from context - final Object bean = context.getBean(); - final MetaBean mbean = context.getMetaBean(); - for (AccessStrategy each : access) { - // modify context state for relationship-target bean - context.moveDown(prop, each); - ValidationHelper.validateContext(context, new BeanValidatorCallback(context), treatMapsLikeBeans); - // restore old values in context - context.moveUp(bean, mbean); - } - } - } - - private boolean treatMapsLikeBeans = false; - - public boolean isTreatMapsLikeBeans() { - return treatMapsLikeBeans; - } - - public void setTreatMapsLikeBeans(boolean treatMapsLikeBeans) { - this.treatMapsLikeBeans = treatMapsLikeBeans; - } - - /** - * Get the metabean finder associated with this validator. - * - * @return a MetaBeanFinder - * @see org.apache.bval.MetaBeanManagerFactory#getFinder() - */ - public MetaBeanFinder getMetaBeanFinder() { - return metaBeanFinder; - } - - /** - * Dispatches a call from {@link #validate()} to - * {@link BeanValidator#validateBeanNet(ValidationContext)} with the current - * context set. - */ - private class BeanValidatorCallback implements ValidationHelper.ValidateCallback { - - private final ValidationContext<?> context; - - public BeanValidatorCallback(ValidationContext<?> context) { - this.context = context; - } - - @Override - public void validate() { - validateBeanNet(context); - } - - } - -} http://git-wip-us.apache.org/repos/asf/bval/blob/ed299e4f/bval-core/src/main/java/org/apache/bval/ConstructorAccess.java ---------------------------------------------------------------------- diff --git a/bval-core/src/main/java/org/apache/bval/ConstructorAccess.java b/bval-core/src/main/java/org/apache/bval/ConstructorAccess.java deleted file mode 100644 index 5509cde..0000000 --- a/bval-core/src/main/java/org/apache/bval/ConstructorAccess.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.apache.bval; - -import java.lang.annotation.ElementType; -import java.lang.reflect.Constructor; -import java.lang.reflect.Type; - -import org.apache.bval.util.AccessStrategy; - -public class ConstructorAccess extends AccessStrategy { - - private final Constructor<?> constructor; - - public ConstructorAccess(final Constructor<?> constructor) { - this.constructor = constructor; - } - - @Override - public Object get(final Object instance) { - throw new UnsupportedOperationException(); - } - - @Override - public ElementType getElementType() { - return ElementType.CONSTRUCTOR; - } - - @Override - public Type getJavaType() { - return constructor.getDeclaringClass(); - } - - /** - * {@inheritDoc} - */ - @Override - public String getPropertyName() { - return constructor.getDeclaringClass().getSimpleName(); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return constructor.toString(); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - - final ConstructorAccess that = (ConstructorAccess) o; - return constructor.equals(that.constructor); - } - - @Override - public int hashCode() { - return constructor.hashCode(); - } -} http://git-wip-us.apache.org/repos/asf/bval/blob/ed299e4f/bval-core/src/main/java/org/apache/bval/DynamicMetaBean.java ---------------------------------------------------------------------- diff --git a/bval-core/src/main/java/org/apache/bval/DynamicMetaBean.java b/bval-core/src/main/java/org/apache/bval/DynamicMetaBean.java deleted file mode 100644 index d1ddba8..0000000 --- a/bval-core/src/main/java/org/apache/bval/DynamicMetaBean.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.apache.bval; - -import org.apache.bval.model.MetaBean; - -// TODO: Reduce visibility - -/** - * Description: Dynamic {@link MetaBean} subclass.<br/> - */ -public final class DynamicMetaBean extends MetaBean { - private static final long serialVersionUID = 1L; - - private final MetaBeanFinder finder; - - /** - * Create a new DynamicMetaBean instance. - * @param finder - */ - public DynamicMetaBean(MetaBeanFinder finder) { - this.finder = finder; - } - - /** - * {@inheritDoc} - * different strategies with hints to find MetaBean of associated object can - * be implemented here. - */ - @Override - public MetaBean resolveMetaBean(Object bean) { - return bean instanceof Class<?> ? finder.findForClass((Class<?>) bean) : finder.findForClass(bean.getClass()); - } -} http://git-wip-us.apache.org/repos/asf/bval/blob/ed299e4f/bval-core/src/main/java/org/apache/bval/IntrospectorMetaBeanFactory.java ---------------------------------------------------------------------- diff --git a/bval-core/src/main/java/org/apache/bval/IntrospectorMetaBeanFactory.java b/bval-core/src/main/java/org/apache/bval/IntrospectorMetaBeanFactory.java deleted file mode 100644 index f85afa4..0000000 --- a/bval-core/src/main/java/org/apache/bval/IntrospectorMetaBeanFactory.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.apache.bval; - -import org.apache.bval.model.MetaBean; -import org.apache.bval.model.MetaProperty; - -import java.beans.BeanInfo; -import java.beans.IndexedPropertyDescriptor; -import java.beans.Introspector; -import java.beans.PropertyDescriptor; -import java.lang.reflect.Method; -import java.lang.reflect.Type; -import java.util.Enumeration; - -import static org.apache.bval.model.Features.Property.HIDDEN; -import static org.apache.bval.model.Features.Property.PREFERRED; -import static org.apache.bval.model.Features.Property.READONLY; - -/** - * Description: use information from java.beans.Introspector in MetaBeans. The PropertyDescriptor can contain info about - * HIDDEN, PREFERRED, READONLY and other features<br/> - * NOTE: THIS IS AN OPTIONAL CLASS, TO ENABLE IT, SET Factory Property apache.bval.enable-introspector="true" - */ -public class IntrospectorMetaBeanFactory implements MetaBeanFactory { - - /** - * {@inheritDoc} - */ - @Override - public void buildMetaBean(MetaBean meta) throws Exception { - if (meta.getBeanClass() == null) { - return; // handle only, when local class exists - } - BeanInfo info = Introspector.getBeanInfo(meta.getBeanClass()); - if (meta.getName() == null && info.getBeanDescriptor() != null) { - meta.setName(info.getBeanDescriptor().getName()); // (display?)name = simple class name! - } - for (PropertyDescriptor pd : info.getPropertyDescriptors()) { - if (!(pd instanceof IndexedPropertyDescriptor || pd.getName().equals("class"))) { - MetaProperty metaProp = buildMetaProperty(pd, meta.getProperty(pd.getName())); - meta.putProperty(pd.getName(), metaProp); - } - } - } - - /** - * Create a {@link MetaProperty} from the specified {@link PropertyDescriptor}. - * - * @param pd - * @return MetaProperty - */ - @Deprecated - protected MetaProperty buildMetaProperty(PropertyDescriptor pd) { - return buildMetaProperty(pd, null); - } - - /** - * Create a {@link MetaProperty} from the specified {@link PropertyDescriptor}. - * - * @param pd - * @param existing - * @return MetaProperty - */ - protected MetaProperty buildMetaProperty(PropertyDescriptor pd, MetaProperty existing) { - MetaProperty meta = new MetaProperty(); - meta.setName(pd.getName()); - meta.setType(determineGenericPropertyType(pd)); - if (pd.isHidden()) { - meta.putFeature(HIDDEN, Boolean.TRUE); - } - if (pd.isPreferred()) { - meta.putFeature(PREFERRED, Boolean.TRUE); - } - if (pd.isConstrained()) { - meta.putFeature(READONLY, Boolean.TRUE); - } - Enumeration<String> enumeration = pd.attributeNames(); - while (enumeration.hasMoreElements()) { - String key = enumeration.nextElement(); - Object value = pd.getValue(key); - meta.putFeature(key, value); - } - return meta; - } - - private Type determineGenericPropertyType(PropertyDescriptor pd) { - Method m = pd.getReadMethod(); - if (m != null) { - return m.getGenericReturnType(); - } - m = pd.getWriteMethod(); - if (m != null && m.getParameterTypes().length == 1) { - return m.getGenericParameterTypes()[0]; - } - return pd.getPropertyType(); - } -} http://git-wip-us.apache.org/repos/asf/bval/blob/ed299e4f/bval-core/src/main/java/org/apache/bval/MetaBeanBuilder.java ---------------------------------------------------------------------- diff --git a/bval-core/src/main/java/org/apache/bval/MetaBeanBuilder.java b/bval-core/src/main/java/org/apache/bval/MetaBeanBuilder.java deleted file mode 100644 index 2c9de93..0000000 --- a/bval-core/src/main/java/org/apache/bval/MetaBeanBuilder.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.apache.bval; - -import org.apache.bval.model.MetaBean; -import org.apache.bval.util.reflection.Reflection; - -import java.util.HashMap; -import java.util.Map; -import java.util.logging.Level; -import java.util.logging.Logger; - -/** - * Description: internal implementation class to construct metabeans with - * factories<br/> - */ -public class MetaBeanBuilder { - - private static final Logger log = Logger.getLogger(MetaBeanBuilder.class.getName()); - - /** - * here you can install different kinds of factories to create MetaBeans - * from - */ - private MetaBeanFactory[] factories; - - /** - * Create a new MetaBeanBuilder instance. - */ - public MetaBeanBuilder() { - this(new MetaBeanFactory[] { new IntrospectorMetaBeanFactory() }); - } - - /** - * Create a new MetaBeanBuilder instance. - * - * @param factories - */ - public MetaBeanBuilder(MetaBeanFactory[] factories) { - setFactories(factories); - } - - /** - * Get the configured set of {@link MetaBeanFactory} objects. - * - * @return {@link MetaBeanFactory} array - */ - public MetaBeanFactory[] getFactories() { - return factories != null ? factories.clone() : null; - } - - /** - * Set the array of {@link MetaBeanFactory} instances with which to enrich - * {@link MetaBean}s. - * - * @param factories - */ - public void setFactories(MetaBeanFactory[] factories) { - this.factories = factories != null ? factories.clone() : null; - } - - /** - * Build a {@link MetaBean} for a given id. - * - * @param beanInfoId - * @return MetaBean - * @throws Exception - * if unable to build - */ - public MetaBean buildForId(String beanInfoId) throws Exception { - throw new IllegalArgumentException("MetaBean " + beanInfoId + " not found"); - } - - /** - * Build beans for all known ids. Default implementation returns an empty - * map. - * - * @return Map of String : MetaBean - */ - public Map<String, MetaBean> buildAll() throws Exception { - return new HashMap<String, MetaBean>(); - } - - /** - * Find the named class. - * - * @param className - * @return Class found or null - */ - protected Class<?> findLocalClass(String className) { - if (className != null) { - try { - return Reflection.toClass(className); - } catch (ClassNotFoundException e) { - log.log(Level.FINE, String.format("Class not found: %s", className), e); - } - } - return null; - } - - /** - * Build a MetaBean for the specified class. - * - * @param clazz - * @return MetaBean - * @throws Exception - */ - public MetaBean buildForClass(Class<?> clazz) throws Exception { - MetaBean meta = new MetaBean(); - if (clazz != null) { // local class here? - meta.setBeanClass(clazz); - meta.setId(clazz.getName()); // default id = full class name! - } - for (MetaBeanFactory factory : factories) { - factory.buildMetaBean(meta); - } - return meta; - } - -} http://git-wip-us.apache.org/repos/asf/bval/blob/ed299e4f/bval-core/src/main/java/org/apache/bval/MetaBeanCache.java ---------------------------------------------------------------------- diff --git a/bval-core/src/main/java/org/apache/bval/MetaBeanCache.java b/bval-core/src/main/java/org/apache/bval/MetaBeanCache.java deleted file mode 100644 index 5c1b281..0000000 --- a/bval-core/src/main/java/org/apache/bval/MetaBeanCache.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.apache.bval; - -import org.apache.bval.model.MetaBean; - -import java.io.Serializable; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - -/** - * Description: a cache to hold metabeans by id and by class.<br/> - */ -public class MetaBeanCache implements MetaBeanFinder, Serializable { - private static final long serialVersionUID = 1L; - - /** - * Cache keyed by id. - */ - protected final ConcurrentMap<String, MetaBean> cacheById = new ConcurrentHashMap<String, MetaBean>(); - /** - * Cache keyed by class. - */ - protected final ConcurrentMap<Class<?>, MetaBean> cacheByClass = new ConcurrentHashMap<Class<?>, MetaBean>(); - - /** - * Create a new MetaBeanCache instance. - */ - public MetaBeanCache() { - super(); - } - - /** - * Create a new MetaBeanCache instance. - * @param beans - */ - public MetaBeanCache(Map<String, MetaBean> beans) { - this(); - for (MetaBean bean : beans.values()) { - cache(bean); - } - } - - /** - * Clear the cache. - */ - public void clear() { - cacheById.clear(); - cacheByClass.clear(); - } - - /** - * {@inheritDoc} - */ - @Override - public MetaBean findForId(String beanInfoId) { - return cacheById.get(beanInfoId); - } - - /** - * {@inheritDoc} - */ - @Override - public MetaBean findForClass(Class<?> clazz) { - return cacheByClass.get(clazz); - } - - /** - * Return all cached MetaBeans by id. - * @return live map - */ - public Map<String, MetaBean> findAll() { - return cacheById; - } - - /** - * Cache the specified MetaBean. - * @param beanInfo - */ - public void cache(MetaBean beanInfo) { - cacheById.put(beanInfo.getId(), beanInfo); - if (beanInfo.getBeanClass() != null && beanInfo.getId().equals(beanInfo.getBeanClass().getName())) { - cacheByClass.putIfAbsent(beanInfo.getBeanClass(), beanInfo); - } - } - - /** - * Remove a single MetaBean from the cache. - * @param beanInfo - */ - public void removeFromCache(MetaBean beanInfo) { - cacheById.remove(beanInfo.getId()); - if (beanInfo.getBeanClass() != null && beanInfo.getId().equals(beanInfo.getBeanClass().getName())) { - cacheByClass.remove(beanInfo.getBeanClass()); - } - } - -} http://git-wip-us.apache.org/repos/asf/bval/blob/ed299e4f/bval-core/src/main/java/org/apache/bval/MetaBeanFactory.java ---------------------------------------------------------------------- diff --git a/bval-core/src/main/java/org/apache/bval/MetaBeanFactory.java b/bval-core/src/main/java/org/apache/bval/MetaBeanFactory.java deleted file mode 100644 index e5a06d7..0000000 --- a/bval-core/src/main/java/org/apache/bval/MetaBeanFactory.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.apache.bval; - -import org.apache.bval.model.MetaBean; - -/** - * Description: interface for abstraction how to initialize a MetaBean - * with information from somewhere<br/> - */ -public interface MetaBeanFactory { - /** - * Initialize the specified {@link MetaBean}. - * @param metaBean - * @throws Exception - */ - void buildMetaBean(MetaBean metaBean) throws Exception; -} http://git-wip-us.apache.org/repos/asf/bval/blob/ed299e4f/bval-core/src/main/java/org/apache/bval/MetaBeanFinder.java ---------------------------------------------------------------------- diff --git a/bval-core/src/main/java/org/apache/bval/MetaBeanFinder.java b/bval-core/src/main/java/org/apache/bval/MetaBeanFinder.java deleted file mode 100644 index 3d0846b..0000000 --- a/bval-core/src/main/java/org/apache/bval/MetaBeanFinder.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.apache.bval; - -import org.apache.bval.model.MetaBean; - -/** - * Description: Interface to find BeanInfos <br/> - */ -public interface MetaBeanFinder { - /** - * Find a MetaBean with a certain id. - * @param beanInfoId - symbolic unique name of Meta Info - * @return BeanInfo - * @throws IllegalArgumentException - when MetaBean not found - */ - MetaBean findForId(String beanInfoId); - - /** - * Find the MetaBean for the specified class. - * @param clazz - bean class - * @return BeanInfo (never null) - */ - MetaBean findForClass(Class<?> clazz); - -} http://git-wip-us.apache.org/repos/asf/bval/blob/ed299e4f/bval-core/src/main/java/org/apache/bval/MetaBeanManager.java ---------------------------------------------------------------------- diff --git a/bval-core/src/main/java/org/apache/bval/MetaBeanManager.java b/bval-core/src/main/java/org/apache/bval/MetaBeanManager.java deleted file mode 100644 index 37eed6d..0000000 --- a/bval-core/src/main/java/org/apache/bval/MetaBeanManager.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.apache.bval; - -import org.apache.bval.model.MetaBean; -import org.apache.bval.model.MetaProperty; - -import static org.apache.bval.model.Features.Property.REF_BEAN_ID; -import static org.apache.bval.model.Features.Property.REF_BEAN_TYPE; -import static org.apache.bval.model.Features.Property.REF_CASCADE; - -/** - * Description: Default implementation for the interface to find, register and - * create MetaBeans. In most situations a single instance of this class is - * sufficient and you can get this instance from the - * {@link MetaBeanManagerFactory}. <br/> - */ -public class MetaBeanManager implements MetaBeanFinder { - - /** MetaBean cache */ - protected final MetaBeanCache cache = new MetaBeanCache(); - /** MetaBean builder */ - protected final MetaBeanBuilder builder; - /** Complete flag */ - protected boolean complete = false; - - /** - * Create a new MetaBeanManager instance. - */ - public MetaBeanManager() { - builder = new MetaBeanBuilder(); - } - - /** - * Create a new MetaBeanManager instance. - * - * @param builder meta bean builder - */ - public MetaBeanManager(MetaBeanBuilder builder) { - this.builder = builder; - } - - /** - * Get the builder used. - * - * @return {@link MetaBeanBuilder} - */ - public MetaBeanBuilder getBuilder() { - return builder; - } - - /** - * Get the cache used. - * - * @return {@link MetaBeanCache} - */ - public MetaBeanCache getCache() { - return cache; - } - - /** - * {@inheritDoc} - */ - @Override - public MetaBean findForId(final String beanInfoId) { - MetaBean beanInfo = cache.findForId(beanInfoId); - if (beanInfo != null) { - return beanInfo; - } - - try { - beanInfo = builder.buildForId(beanInfoId); - cache.cache(beanInfo); - computeRelationships(beanInfo); - return beanInfo; - } catch (final RuntimeException e) { - throw e; // do not wrap runtime exceptions - } catch (final Exception e) { - throw new IllegalArgumentException("error creating beanInfo with id: " + beanInfoId, e); - } - } - - /** - * {@inheritDoc} - */ - @Override - public MetaBean findForClass(final Class<?> clazz) { - if (clazz == null) { - return null; - } - - MetaBean beanInfo = cache.findForClass(clazz); - if (beanInfo != null) { - return beanInfo; - } - - try { - beanInfo = builder.buildForClass(clazz); - cache.cache(beanInfo); - computeRelationships(beanInfo); - return beanInfo; - } catch (final RuntimeException e) { - throw e; // do not wrap runtime exceptions - } catch (final Exception e) { - throw new IllegalArgumentException("error creating beanInfo for " + clazz, e); - } - } - - /** - * Compute all known relationships for <code>beanInfo</code>. must be called - * AFTER cache.cache() to avoid endless loop - * - * @param beanInfo - * - the bean for which to compute relationships - */ - protected void computeRelationships(MetaBean beanInfo) { - for (final MetaProperty prop : beanInfo.getProperties()) { - final String beanRef = prop.getFeature(REF_BEAN_ID); - computeRelatedMetaBean(prop, beanRef); - } - } - - /** - * Compute a single related {@link MetaBean}. - * - * @param prop meta property - * @param beanRef bean reference - */ - protected void computeRelatedMetaBean(MetaProperty prop, String beanRef) { - Class<?> beanType = prop.getFeature(REF_BEAN_TYPE); - if (beanType == null) { - if (prop.getFeature(REF_CASCADE) != null) { // dynamic type resolution: - prop.setMetaBean(new DynamicMetaBean(this)); - } - } else { - prop.setMetaBean(findForClass(beanType)); - } - } - -} http://git-wip-us.apache.org/repos/asf/bval/blob/ed299e4f/bval-core/src/main/java/org/apache/bval/MetaBeanManagerFactory.java ---------------------------------------------------------------------- diff --git a/bval-core/src/main/java/org/apache/bval/MetaBeanManagerFactory.java b/bval-core/src/main/java/org/apache/bval/MetaBeanManagerFactory.java deleted file mode 100644 index 85d49b8..0000000 --- a/bval-core/src/main/java/org/apache/bval/MetaBeanManagerFactory.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.apache.bval; - -/** - * Description: API class to hold a singleton of a {@link MetaBeanManager} - * that implements the finder and registry interfaces for MetaBeans<br/> - * - * @see org.apache.bval.model.MetaBean - * @see MetaBeanManager - */ -public class MetaBeanManagerFactory { - private static MetaBeanManager manager = new MetaBeanManager(); - - /** - * global meta bean finder. - * @return the singleton - */ - public static MetaBeanFinder getFinder() { - return manager; - } - - /** - * set global meta bean manager, that is responsible - * for finding, caching, xml registry and enrichment algorithm. - * @param finder - */ - public static void setManager(MetaBeanManager finder) { - manager = finder; - } -} http://git-wip-us.apache.org/repos/asf/bval/blob/ed299e4f/bval-core/src/main/java/org/apache/bval/Validate.java ---------------------------------------------------------------------- diff --git a/bval-core/src/main/java/org/apache/bval/Validate.java b/bval-core/src/main/java/org/apache/bval/Validate.java deleted file mode 100644 index ad895a4..0000000 --- a/bval-core/src/main/java/org/apache/bval/Validate.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.apache.bval; - -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import static java.lang.annotation.ElementType.CONSTRUCTOR; -import static java.lang.annotation.ElementType.FIELD; -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.ElementType.PARAMETER; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -/** - * Description: Annotate an element (parameter) to be validated. - * <br> - */ -@Target({ METHOD, FIELD, CONSTRUCTOR, PARAMETER }) -@Retention(RUNTIME) -public @interface Validate { - /** - * (optional) the MetaBean.id to use - */ - String value() default ""; - - /** - * to Support groups on @Valid(ate) in method/return validation - */ - Class<?>[] groups() default {}; -} http://git-wip-us.apache.org/repos/asf/bval/blob/ed299e4f/bval-core/src/main/java/org/apache/bval/ValidationResults.java ---------------------------------------------------------------------- diff --git a/bval-core/src/main/java/org/apache/bval/ValidationResults.java b/bval-core/src/main/java/org/apache/bval/ValidationResults.java deleted file mode 100644 index 2ad46f6..0000000 --- a/bval-core/src/main/java/org/apache/bval/ValidationResults.java +++ /dev/null @@ -1,236 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.apache.bval; - -import org.apache.bval.model.ValidationContext; -import org.apache.bval.model.ValidationListener; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -/** - * Description: Implements a contains to hold and transport validation results<br/> - */ -public class ValidationResults implements ValidationListener, Serializable { - private static final long serialVersionUID = 1L; - - private Map<String, List<Error>> errorsByReason; - private Map<Object, Map<String, List<Error>>> errorsByOwner; - - /** - * API to add an error to the validation results. - * - * @param reason - Features from {@link org.apache.bval.model.Features.Property} - * or custom reason of validation error - * @param context - context information (bean, propertyName, value, ...) - */ - @Override - public <T extends ValidationListener> void addError(String reason, ValidationContext<T> context) { - Error error = createError(reason, context.getBean(), context.getPropertyName()); - addError(error, context); - } - - /** - * API to add an error to the validation results. - * - * @param error - holding the description of reason and object to describe - * the validation error - * @param context - null or the context to provide additional information - */ - @Override - public <T extends ValidationListener> void addError(Error error, ValidationContext<T> context) { - if (errorsByReason == null) { - initialize(); - } - addToReasonBucket(error); - addToOwnerBucket(error); - } - - /** - * Old API to add an error to the validation results when no context is available. - * - * @param reason - Features from {@link org.apache.bval.model.Features.Property} or custom validation reason - * @param bean - (optional) owner bean or null - * @param propertyName - (optional) propertyName where valiation error occurred or null - */ - public void addError(String reason, Object bean, String propertyName) { - addError(createError(reason, bean, propertyName), null); - } - - /** - * Create an Error object. - * @param reason - * @param owner - * @param propertyName - * @return new {@link Error} - */ - protected Error createError(String reason, Object owner, String propertyName) { - return new Error(reason, owner, propertyName); - } - - /** - * initialize the error-buckets now when needed and - * not on instance creation to save memory garbage. - */ - protected void initialize() { - errorsByReason = new LinkedHashMap<String, List<Error>>(); - errorsByOwner = new LinkedHashMap<Object, Map<String, List<Error>>>(); - } - - /** - * Add an Error to the set of Errors shared by a particular "reason." - * @param error - * @see {@link Error#getReason()} - */ - protected void addToReasonBucket(Error error) { - if (error.getReason() == null) { - return; - } - - List<Error> errors = errorsByReason.get(error.getReason()); - if (errors == null) { - errors = new ArrayList<Error>(); - errorsByReason.put(error.getReason(), errors); - } - errors.add(error); - } - - /** - * Add an Error to the property-keyed map of Errors maintained for this Error's owner. - * @param error - * @see {@link Error#getOwner()} - */ - protected void addToOwnerBucket(Error error) { - if (error.getOwner() == null) { - return; - } - - Map<String, List<Error>> errors = errorsByOwner.get(error.getOwner()); - if (errors == null) { - errors = new HashMap<String, List<Error>>(); - errorsByOwner.put(error.getOwner(), errors); - } - List<Error> list = errors.get(error.getPropertyName()); - if (list == null) { - list = new ArrayList<Error>(); - errors.put(error.getPropertyName(), list); - } - list.add(error); - } - - /** - * Get the map of Errors by reason; - * key = reason, value = list of errors for this reason - * @return map - */ - public Map<String, List<Error>> getErrorsByReason() { - if (errorsByReason == null) { - return Collections.emptyMap(); - } - return errorsByReason; - } - - /** - * Get the map of Errors by owner; - * key = owner, value = map with:<br> - * key = propertyName, value = list of errors for this owner.propertyName - * @return map - */ - public Map<Object, Map<String, List<Error>>> getErrorsByOwner() { - if (errorsByOwner == null) { - return Collections.emptyMap(); - } - return errorsByOwner; - } - - /** - * Learn whether these results are empty/error-free. - * @return true when there are NO errors in this validation result - */ - public boolean isEmpty() { - if (errorsByReason == null || (errorsByReason.isEmpty() && errorsByOwner.isEmpty())) { - return true; - } - for (List<Error> list : errorsByReason.values()) { - if (!list.isEmpty()) { - return false; - } - } - for (Map<String, List<Error>> map : errorsByOwner.values()) { - for (List<Error> list : map.values()) { - if (!list.isEmpty()) { - return false; - } - } - } - return true; - } - - /** - * Learn whether there is an Error keyed to a specified reason description. - * @param reason - * @return boolean - * @see {@link Error#getReason()} - */ - public boolean hasErrorForReason(String reason) { - if (errorsByReason == null) { - return false; - } - List<Error> errors = errorsByReason.get(reason); - return errors != null && !errors.isEmpty(); - } - - /** - * Learn whether <code>bean</code> has any errors keyed to property <code>propertyName</code>. - * @param bean - * @param propertyName - may be null: any property is checked - * OR the name of the property to check - * @return boolean - */ - public boolean hasError(Object bean, String propertyName) { - if (errorsByOwner == null) { - return false; - } - Map<String, List<Error>> errors = errorsByOwner.get(bean); - if (errors == null) { - return false; - } - if (propertyName == null) { - for (List<Error> list : errors.values()) { - if (!list.isEmpty()) { - return true; - } - } - return false; - } - List<Error> list = errors.get(propertyName); - return list != null && !list.isEmpty(); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - return "ValidationResults{" + errorsByOwner + "}"; - } -} http://git-wip-us.apache.org/repos/asf/bval/blob/ed299e4f/bval-core/src/main/java/org/apache/bval/model/DynaType.java ---------------------------------------------------------------------- diff --git a/bval-core/src/main/java/org/apache/bval/model/DynaType.java b/bval-core/src/main/java/org/apache/bval/model/DynaType.java deleted file mode 100644 index 7a89862..0000000 --- a/bval-core/src/main/java/org/apache/bval/model/DynaType.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.apache.bval.model; - -import java.lang.reflect.Type; - -/** - * Description: implementation of a dynamic type. can be used inside a - * MetaProperty for instance-based types <br/> - */ -public interface DynaType extends Type { - /** - * Resolve the type indirection. - * @return Type - */ - Type getRawType(); -} http://git-wip-us.apache.org/repos/asf/bval/blob/ed299e4f/bval-core/src/main/java/org/apache/bval/model/DynaTypeEnum.java ---------------------------------------------------------------------- diff --git a/bval-core/src/main/java/org/apache/bval/model/DynaTypeEnum.java b/bval-core/src/main/java/org/apache/bval/model/DynaTypeEnum.java deleted file mode 100644 index 247678d..0000000 --- a/bval-core/src/main/java/org/apache/bval/model/DynaTypeEnum.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.apache.bval.model; - -/** - * Description: ("artificial" enum with custom values).<br/> - */ -public class DynaTypeEnum implements DynaType { - private final Class<?> enumClass; - private Value[] enumConstants; - - /** - * Create a new DynaTypeEnum instance. - * @param enumClass - */ - public DynaTypeEnum(Class<?> enumClass) { - this.enumClass = enumClass; - } - - /** - * Create a new DynaTypeEnum instance. - * @param enumClass - * @param names - */ - public DynaTypeEnum(Class<?> enumClass, String... names) { - this(enumClass); - setEnumNames(names); - } - - /** - * Set the enumeration value names. - * @param names - */ - public void setEnumNames(String[] names) { - enumConstants = new Value[names.length]; - int i = 0; - for (String each : names) { - enumConstants[i++] = new Value(each); - } - } - - /** - * Get the name of the enum class. - * @return String - */ - public String getName() { - return enumClass.getName(); - } - - /** - * {@inheritDoc} - */ - @Override - public Class<?> getRawType() { - return enumClass; - } - - /** - * Learn whether the referred class is, in fact, an enum class. - * used by freemarker-template "bean-infos-json.ftl" - */ - public boolean isEnum() { - return enumClass.isEnum(); - } - - /** - * Get the emulated constants. - * used by freemarker-template "bean-infos-json.ftl" - * @return Value[] - */ - public Value[] getEnumConstants() { - return enumConstants != null ? enumConstants.clone() : null; - } - - /** - * Learn whether the wrapped class is assignable from <code>cls</code>. - * @param cls - * @return boolean - */ - public boolean isAssignableFrom(Class<?> cls) { - return enumClass.isAssignableFrom(cls); - } - - /** - * Represents a single "enum" instance (= the value). - */ - public static final class Value { - final String name; - - /** - * Create a new Value instance. - * @param name - */ - Value(String name) { - this.name = name; - } - - /** - * used by freemarker-template "bean-infos-json.ftl" - * @return the name of this constant - */ - public String name() { - return name; - } - - } -} http://git-wip-us.apache.org/repos/asf/bval/blob/ed299e4f/bval-core/src/main/java/org/apache/bval/model/Features.java ---------------------------------------------------------------------- diff --git a/bval-core/src/main/java/org/apache/bval/model/Features.java b/bval-core/src/main/java/org/apache/bval/model/Features.java deleted file mode 100644 index 5c97c8e..0000000 --- a/bval-core/src/main/java/org/apache/bval/model/Features.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 org.apache.bval.model; - -/** - * Description: Contains key of common feature keys used by standard validators etc. - * This DOES NOT MEAN that the list of property- or bean-features is closed. You can - * put anything into the metabean as a feature and use it in your custom validators - * and other classes that access your metabeans.<br/> - * - * @see FeaturesCapable - */ -public interface Features { - /** Features of {@link MetaBean} */ - public interface Bean { - /** INFO: String, name of the Property, that is the Primary Key */ - String MAIN_KEY = "mainKey"; - /** INFO: category/domain to which the metaBean belongs to */ - String DOMAIN = "domain"; - - // String DISPLAY_NAME = "displayName"; - String UNIQUE_KEY = "uniqueKey"; - - String EXECUTABLES = "executables"; - String PROPERTIES = "properties"; - } - - /** Features of {@link MetaProperty} */ - public interface Property { - /** INFO: possible Enum values */ - String ENUM = "enum"; - /** INFO: Boolean, TRUE if Property is a Unique Key */ - String UNIQUE_KEY = "uniqueKey"; - /** VALIDATION: Boolean, mandatory field? */ - String MANDATORY = "mandatory"; - /** VALIDATION: Integer, max. number of chars/digits / max. cardinality of a to-many relationship */ - String MAX_LENGTH = "maxLen"; - /** VALIDATION: Comparable (e.g. a subclass of Number), max value */ - String MAX_VALUE = "maxValue"; - /** VALIDATION: Integer, min. number of chars/digits / min. cardinality of a to-many relationship */ - String MIN_LENGTH = "minLen"; - /** VALIDATION: Comparable (e.g. a subclass of Number), min value */ - String MIN_VALUE = "minValue"; - /** INFO: String-representation of a default value */ - String DEFAULT_VALUE = "defValue"; - /** SECURITY, INFO: Boolean, is value or relationship unmodifiable */ - String READONLY = "readonly"; - /** - * SECURITY, INFO: Boolean, Field accessible? - * If false, the field must not be displayed, queried, changed. - */ - String DENIED = "denied"; - /** VALIDATION: String, regular expression to validate the format of input data */ - String REG_EXP = "regExp"; - /** - * VALIDATION: String, Constraint for time-information of a Date-field: - * {@link org.apache.bval.xml.XMLMetaValue#TIMELAG_Past} - * or - * {@link org.apache.bval.xml.XMLMetaValue#TIMELAG_Future} - */ - String TIME_LAG = "timeLag"; - - /** - * INFO: Boolean, Field visible? - * - * @see java.beans.PropertyDescriptor#isHidden() - */ - String HIDDEN = "hidden"; - /** - * INFO: Boolean - * - * @see java.beans.PropertyDescriptor#isPreferred() - */ - String PREFERRED = "preferred"; - - /** INFO: relationship's target metaBean.id * */ - String REF_BEAN_ID = "refBeanId"; - - /** - * INFO: Class<br> - * Relationship's target metaBean.beanClass. - * In case of to-many relationships, this feature - * hold the Bean-type not the Collection-type. - */ - String REF_BEAN_TYPE = "refBeanType"; - - /** - * INFO: AccessStrategy[]<br> - * an array of accessStrategies - * how validation should cascade into relationship target beans<br> - * null when validation should NOT cascade into relationship target - * beans<br> - * <p/> - * Default: {PropertyAccess(metaProperty.name)}, - * when MetaProperty.metaBean is != null - */ - String REF_CASCADE = "refCascade"; - - /** INFO: an array with the string names of custom java script validation functions */ - @Deprecated // TODO RSt - I suggest to remove this and all related code - String JAVASCRIPT_VALIDATION_FUNCTIONS = "jsFunctions"; - } -}
