Repository: bval Updated Branches: refs/heads/bv2 ed299e4f1 -> 0e874301a
remove remaining bval-core references Project: http://git-wip-us.apache.org/repos/asf/bval/repo Commit: http://git-wip-us.apache.org/repos/asf/bval/commit/731c8ef0 Tree: http://git-wip-us.apache.org/repos/asf/bval/tree/731c8ef0 Diff: http://git-wip-us.apache.org/repos/asf/bval/diff/731c8ef0 Branch: refs/heads/bv2 Commit: 731c8ef0a55293138529a2a35d7fdd4cd1fe5d8b Parents: ed299e4 Author: Matt Benson <[email protected]> Authored: Sun Feb 25 14:20:47 2018 -0600 Committer: Matt Benson <[email protected]> Committed: Sun Feb 25 14:20:47 2018 -0600 ---------------------------------------------------------------------- bundle/pom.xml | 6 - bval-extras/pom.xml | 5 - bval-jsr/pom.xml | 14 - .../java/org/apache/bval/jsr/metadata/Meta.java | 338 +++++++++++++++++++ .../org/apache/bval/jsr/metadata/Metas.java | 338 ------------------- .../java/org/apache/bval/jsr/BootstrapTest.java | 3 - bval-tck/pom.xml | 11 - 7 files changed, 338 insertions(+), 377 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/bval/blob/731c8ef0/bundle/pom.xml ---------------------------------------------------------------------- diff --git a/bundle/pom.xml b/bundle/pom.xml index 2f57116..75ef592 100644 --- a/bundle/pom.xml +++ b/bundle/pom.xml @@ -42,12 +42,6 @@ <!-- JARs to include in aggregate JAR via maven-shade-plugin --> <dependency> <groupId>org.apache.bval</groupId> - <artifactId>bval-core</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>org.apache.bval</groupId> <artifactId>bval-jsr</artifactId> <version>${project.version}</version> <scope>provided</scope> http://git-wip-us.apache.org/repos/asf/bval/blob/731c8ef0/bval-extras/pom.xml ---------------------------------------------------------------------- diff --git a/bval-extras/pom.xml b/bval-extras/pom.xml index 3dc7982..4ead8ce 100644 --- a/bval-extras/pom.xml +++ b/bval-extras/pom.xml @@ -39,11 +39,6 @@ <dependencies> <dependency> <groupId>org.apache.bval</groupId> - <artifactId>bval-core</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.bval</groupId> <artifactId>bval-jsr</artifactId> <version>${project.version}</version> </dependency> http://git-wip-us.apache.org/repos/asf/bval/blob/731c8ef0/bval-jsr/pom.xml ---------------------------------------------------------------------- diff --git a/bval-jsr/pom.xml b/bval-jsr/pom.xml index 8913f7c..b94b02d 100644 --- a/bval-jsr/pom.xml +++ b/bval-jsr/pom.xml @@ -161,20 +161,6 @@ </dependency> <!-- optional dependencies --> <dependency> - <groupId>org.apache.bval</groupId> - <artifactId>bval-xstream</artifactId> - <version>${project.version}</version> - <!-- don't pull into OSGi bundle --> - <scope>provided</scope> - <optional>true</optional> - <exclusions> - <exclusion> - <groupId>org.apache.bval</groupId> - <artifactId>bval-core</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <scope>provided</scope> http://git-wip-us.apache.org/repos/asf/bval/blob/731c8ef0/bval-jsr/src/main/java/org/apache/bval/jsr/metadata/Meta.java ---------------------------------------------------------------------- diff --git a/bval-jsr/src/main/java/org/apache/bval/jsr/metadata/Meta.java b/bval-jsr/src/main/java/org/apache/bval/jsr/metadata/Meta.java new file mode 100644 index 0000000..60267c1 --- /dev/null +++ b/bval-jsr/src/main/java/org/apache/bval/jsr/metadata/Meta.java @@ -0,0 +1,338 @@ +/* + * 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.jsr.metadata; + +import static java.util.Arrays.asList; +import static java.util.Collections.singleton; + +import java.lang.annotation.Annotation; +import java.lang.annotation.ElementType; +import java.lang.reflect.AnnotatedElement; +import java.lang.reflect.AnnotatedType; +import java.lang.reflect.Constructor; +import java.lang.reflect.Executable; +import java.lang.reflect.Field; +import java.lang.reflect.Member; +import java.lang.reflect.Method; +import java.lang.reflect.Parameter; +import java.lang.reflect.Type; +import java.util.Collection; +import java.util.Objects; + +import javax.validation.constraintvalidation.ValidationTarget; + +import org.apache.bval.util.Validate; + +/** + * Validation class model. + * + * @param <E> + */ +// TODO rename to Meta; delete old type of that name +public abstract class Metas<E extends AnnotatedElement> { + + public static class ForClass extends Metas<Class<?>> { + + public ForClass(Class<?> host) { + super(host, ElementType.TYPE); + } + + @Override + public final Class<?> getDeclaringClass() { + return getHost(); + } + + @Override + public Type getType() { + return getHost(); + } + + @Override + public AnnotatedType getAnnotatedType() { + return new AnnotatedType() { + + @Override + public Annotation[] getDeclaredAnnotations() { + return getHost().getDeclaredAnnotations(); + } + + @Override + public Annotation[] getAnnotations() { + return getHost().getAnnotations(); + } + + @Override + public <T extends Annotation> T getAnnotation(Class<T> annotationClass) { + return getHost().getAnnotation(annotationClass); + } + + @Override + public Type getType() { + return getHost(); + } + }; + } + + @Override + public String getName() { + return getHost().getName(); + } + } + + public static abstract class ForMember<M extends Member & AnnotatedElement> extends Metas<M> { + + protected ForMember(M host, ElementType elementType) { + super(host, elementType); + } + + @Override + public Class<?> getDeclaringClass() { + return getHost().getDeclaringClass(); + } + } + + public static class ForField extends ForMember<Field> { + + public ForField(Field host) { + super(host, ElementType.FIELD); + } + + @Override + public Type getType() { + return getHost().getGenericType(); + } + + @Override + public AnnotatedType getAnnotatedType() { + return getHost().getAnnotatedType(); + } + + @Override + public String getName() { + return getHost().getName(); + } + } + + public static abstract class ForExecutable<E extends Executable> extends ForMember<E> { + + protected ForExecutable(E host, ElementType elementType) { + super(host, elementType); + } + + @Override + public AnnotatedType getAnnotatedType() { + return getHost().getAnnotatedReturnType(); + } + } + + public static class ForConstructor extends ForExecutable<Constructor<?>> { + + public ForConstructor(Constructor<?> host) { + super(host, ElementType.CONSTRUCTOR); + } + + @Override + public Type getType() { + return getHost().getDeclaringClass(); + } + + @Override + public String getName() { + return getHost().getDeclaringClass().getSimpleName(); + } + } + + public static class ForMethod extends ForExecutable<Method> { + + public ForMethod(Method host) { + super(host, ElementType.METHOD); + } + + @Override + public Type getType() { + return getHost().getGenericReturnType(); + } + + @Override + public String getName() { + return getHost().getName(); + } + } + + public static class ForCrossParameter<E extends Executable> extends Metas.ForExecutable<E> { + + public ForCrossParameter(Metas<E> parent) { + super(parent.getHost(), parent.getElementType()); + } + + @Override + public Type getType() { + return Object[].class; + } + + @Override + public String getName() { + return "<cross parameter>"; + } + + @Override + public ValidationTarget getValidationTarget() { + return ValidationTarget.PARAMETERS; + } + + @Override + public String toString() { + return String.format("%s(%s of %s)", getStringPrefix(), getName(), getHost()); + } + } + + public static class ForParameter extends Metas<Parameter> { + + private final String name; + + public ForParameter(Parameter host, String name) { + super(host, ElementType.PARAMETER); + this.name = Validate.notNull(name, "name"); + } + + @Override + public Collection<ValidationTarget> getValidationTargets() { + return asList(ValidationTarget.values()); + } + + @Override + public Type getType() { + return getHost().getType(); + } + + @Override + public Class<?> getDeclaringClass() { + return getHost().getDeclaringExecutable().getDeclaringClass(); + } + + @Override + public AnnotatedType getAnnotatedType() { + return getHost().getAnnotatedType(); + } + + public String getName() { + return name; + } + } + + public static class ForContainerElement extends Metas<AnnotatedType> { + + private final Metas<?> parent; + private final ContainerElementKey key; + + public ForContainerElement(Metas<?> parent, ContainerElementKey key) { + super(key.getAnnotatedType(), ElementType.TYPE_USE); + this.parent = Validate.notNull(parent, "parent"); + this.key = Validate.notNull(key, "key"); + } + + @Override + public Type getType() { + return getHost().getType(); + } + + @Override + public Class<?> getDeclaringClass() { + return parent.getDeclaringClass(); + } + + @Override + public AnnotatedType getAnnotatedType() { + return key.getAnnotatedType(); + } + + public Integer getTypeArgumentIndex() { + return Integer.valueOf(key.getTypeArgumentIndex()); + } + + @Override + public String getName() { + return key.toString(); + } + + @Override + public String toString() { + return String.format("%s(%s of %s)", getStringPrefix(), key, getHost()); + } + } + + private final E host; + private final ElementType elementType; + + protected Metas(E host, ElementType elementType) { + super(); + this.host = Validate.notNull(host, "host"); + this.elementType = Validate.notNull(elementType, "elementType"); + } + + public E getHost() { + return host; + } + + public ElementType getElementType() { + return elementType; + } + + public abstract Type getType(); + + public abstract Class<?> getDeclaringClass(); + + public abstract AnnotatedType getAnnotatedType(); + + public abstract String getName(); + + public Collection<ValidationTarget> getValidationTargets() { + // todo: cache for perf? + return singleton(getValidationTarget()); + } + + public ValidationTarget getValidationTarget() { + return ValidationTarget.ANNOTATED_ELEMENT; + } + + @Override + public String toString() { + return String.format("%s(%s)", getStringPrefix(), host); + } + + protected String getStringPrefix() { + return Metas.class.getSimpleName() + '.' + getClass().getSimpleName(); + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!obj.getClass().equals(getClass())) { + return false; + } + return Objects.equals(((Metas<?>) obj).getHost(), getHost()); + } + + @Override + public int hashCode() { + return Objects.hash(getHost()); + } +} http://git-wip-us.apache.org/repos/asf/bval/blob/731c8ef0/bval-jsr/src/main/java/org/apache/bval/jsr/metadata/Metas.java ---------------------------------------------------------------------- diff --git a/bval-jsr/src/main/java/org/apache/bval/jsr/metadata/Metas.java b/bval-jsr/src/main/java/org/apache/bval/jsr/metadata/Metas.java deleted file mode 100644 index 60267c1..0000000 --- a/bval-jsr/src/main/java/org/apache/bval/jsr/metadata/Metas.java +++ /dev/null @@ -1,338 +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.jsr.metadata; - -import static java.util.Arrays.asList; -import static java.util.Collections.singleton; - -import java.lang.annotation.Annotation; -import java.lang.annotation.ElementType; -import java.lang.reflect.AnnotatedElement; -import java.lang.reflect.AnnotatedType; -import java.lang.reflect.Constructor; -import java.lang.reflect.Executable; -import java.lang.reflect.Field; -import java.lang.reflect.Member; -import java.lang.reflect.Method; -import java.lang.reflect.Parameter; -import java.lang.reflect.Type; -import java.util.Collection; -import java.util.Objects; - -import javax.validation.constraintvalidation.ValidationTarget; - -import org.apache.bval.util.Validate; - -/** - * Validation class model. - * - * @param <E> - */ -// TODO rename to Meta; delete old type of that name -public abstract class Metas<E extends AnnotatedElement> { - - public static class ForClass extends Metas<Class<?>> { - - public ForClass(Class<?> host) { - super(host, ElementType.TYPE); - } - - @Override - public final Class<?> getDeclaringClass() { - return getHost(); - } - - @Override - public Type getType() { - return getHost(); - } - - @Override - public AnnotatedType getAnnotatedType() { - return new AnnotatedType() { - - @Override - public Annotation[] getDeclaredAnnotations() { - return getHost().getDeclaredAnnotations(); - } - - @Override - public Annotation[] getAnnotations() { - return getHost().getAnnotations(); - } - - @Override - public <T extends Annotation> T getAnnotation(Class<T> annotationClass) { - return getHost().getAnnotation(annotationClass); - } - - @Override - public Type getType() { - return getHost(); - } - }; - } - - @Override - public String getName() { - return getHost().getName(); - } - } - - public static abstract class ForMember<M extends Member & AnnotatedElement> extends Metas<M> { - - protected ForMember(M host, ElementType elementType) { - super(host, elementType); - } - - @Override - public Class<?> getDeclaringClass() { - return getHost().getDeclaringClass(); - } - } - - public static class ForField extends ForMember<Field> { - - public ForField(Field host) { - super(host, ElementType.FIELD); - } - - @Override - public Type getType() { - return getHost().getGenericType(); - } - - @Override - public AnnotatedType getAnnotatedType() { - return getHost().getAnnotatedType(); - } - - @Override - public String getName() { - return getHost().getName(); - } - } - - public static abstract class ForExecutable<E extends Executable> extends ForMember<E> { - - protected ForExecutable(E host, ElementType elementType) { - super(host, elementType); - } - - @Override - public AnnotatedType getAnnotatedType() { - return getHost().getAnnotatedReturnType(); - } - } - - public static class ForConstructor extends ForExecutable<Constructor<?>> { - - public ForConstructor(Constructor<?> host) { - super(host, ElementType.CONSTRUCTOR); - } - - @Override - public Type getType() { - return getHost().getDeclaringClass(); - } - - @Override - public String getName() { - return getHost().getDeclaringClass().getSimpleName(); - } - } - - public static class ForMethod extends ForExecutable<Method> { - - public ForMethod(Method host) { - super(host, ElementType.METHOD); - } - - @Override - public Type getType() { - return getHost().getGenericReturnType(); - } - - @Override - public String getName() { - return getHost().getName(); - } - } - - public static class ForCrossParameter<E extends Executable> extends Metas.ForExecutable<E> { - - public ForCrossParameter(Metas<E> parent) { - super(parent.getHost(), parent.getElementType()); - } - - @Override - public Type getType() { - return Object[].class; - } - - @Override - public String getName() { - return "<cross parameter>"; - } - - @Override - public ValidationTarget getValidationTarget() { - return ValidationTarget.PARAMETERS; - } - - @Override - public String toString() { - return String.format("%s(%s of %s)", getStringPrefix(), getName(), getHost()); - } - } - - public static class ForParameter extends Metas<Parameter> { - - private final String name; - - public ForParameter(Parameter host, String name) { - super(host, ElementType.PARAMETER); - this.name = Validate.notNull(name, "name"); - } - - @Override - public Collection<ValidationTarget> getValidationTargets() { - return asList(ValidationTarget.values()); - } - - @Override - public Type getType() { - return getHost().getType(); - } - - @Override - public Class<?> getDeclaringClass() { - return getHost().getDeclaringExecutable().getDeclaringClass(); - } - - @Override - public AnnotatedType getAnnotatedType() { - return getHost().getAnnotatedType(); - } - - public String getName() { - return name; - } - } - - public static class ForContainerElement extends Metas<AnnotatedType> { - - private final Metas<?> parent; - private final ContainerElementKey key; - - public ForContainerElement(Metas<?> parent, ContainerElementKey key) { - super(key.getAnnotatedType(), ElementType.TYPE_USE); - this.parent = Validate.notNull(parent, "parent"); - this.key = Validate.notNull(key, "key"); - } - - @Override - public Type getType() { - return getHost().getType(); - } - - @Override - public Class<?> getDeclaringClass() { - return parent.getDeclaringClass(); - } - - @Override - public AnnotatedType getAnnotatedType() { - return key.getAnnotatedType(); - } - - public Integer getTypeArgumentIndex() { - return Integer.valueOf(key.getTypeArgumentIndex()); - } - - @Override - public String getName() { - return key.toString(); - } - - @Override - public String toString() { - return String.format("%s(%s of %s)", getStringPrefix(), key, getHost()); - } - } - - private final E host; - private final ElementType elementType; - - protected Metas(E host, ElementType elementType) { - super(); - this.host = Validate.notNull(host, "host"); - this.elementType = Validate.notNull(elementType, "elementType"); - } - - public E getHost() { - return host; - } - - public ElementType getElementType() { - return elementType; - } - - public abstract Type getType(); - - public abstract Class<?> getDeclaringClass(); - - public abstract AnnotatedType getAnnotatedType(); - - public abstract String getName(); - - public Collection<ValidationTarget> getValidationTargets() { - // todo: cache for perf? - return singleton(getValidationTarget()); - } - - public ValidationTarget getValidationTarget() { - return ValidationTarget.ANNOTATED_ELEMENT; - } - - @Override - public String toString() { - return String.format("%s(%s)", getStringPrefix(), host); - } - - protected String getStringPrefix() { - return Metas.class.getSimpleName() + '.' + getClass().getSimpleName(); - } - - @Override - public boolean equals(Object obj) { - if (obj == this) { - return true; - } - if (!obj.getClass().equals(getClass())) { - return false; - } - return Objects.equals(((Metas<?>) obj).getHost(), getHost()); - } - - @Override - public int hashCode() { - return Objects.hash(getHost()); - } -} http://git-wip-us.apache.org/repos/asf/bval/blob/731c8ef0/bval-jsr/src/test/java/org/apache/bval/jsr/BootstrapTest.java ---------------------------------------------------------------------- diff --git a/bval-jsr/src/test/java/org/apache/bval/jsr/BootstrapTest.java b/bval-jsr/src/test/java/org/apache/bval/jsr/BootstrapTest.java index c72ec72..d6187df 100644 --- a/bval-jsr/src/test/java/org/apache/bval/jsr/BootstrapTest.java +++ b/bval-jsr/src/test/java/org/apache/bval/jsr/BootstrapTest.java @@ -83,9 +83,6 @@ public class BootstrapTest { builder.messageInterpolator(interpolator); ApacheValidatorFactory factory = (ApacheValidatorFactory) builder.buildValidatorFactory(); - // ALTERNATIVE: - // you could do it without modifying the builder or reusing it, - // but then you need to use bval-core proprietary APIs: ((DefaultMessageInterpolator) factory.getMessageInterpolator()).setLocale(Locale.ENGLISH); // now factory's message resolver is using the english locale } http://git-wip-us.apache.org/repos/asf/bval/blob/731c8ef0/bval-tck/pom.xml ---------------------------------------------------------------------- diff --git a/bval-tck/pom.xml b/bval-tck/pom.xml index cd338b7..2449f76 100644 --- a/bval-tck/pom.xml +++ b/bval-tck/pom.xml @@ -79,17 +79,6 @@ under the License. </dependency> <dependency> <groupId>org.apache.bval</groupId> - <artifactId>bval-core</artifactId> - <version>${project.version}</version> - <exclusions> - <exclusion> - <groupId>org.apache.commons</groupId> - <artifactId>commons-lang3</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>org.apache.bval</groupId> <artifactId>bval-jsr</artifactId> <version>${project.version}</version> <exclusions>
