Skip to content
Permalink
Browse files
drop validations which should be redundant due to code path
  • Loading branch information
rmannibucau committed Feb 17, 2019
1 parent d425f90 commit 43935b44a95164fda045357ac969288696af6ba6
Showing 5 changed files with 6 additions and 18 deletions.
@@ -30,7 +30,6 @@
import org.apache.bval.jsr.util.NodeImpl;
import org.apache.bval.jsr.util.PathImpl;
import org.apache.bval.util.Exceptions;
import org.apache.bval.util.Validate;
import org.apache.bval.util.reflection.TypeUtils;

public class GraphContext {
@@ -46,8 +45,8 @@ public GraphContext(ApacheFactoryContext validatorContext, PathImpl path, Object

private GraphContext(ApacheFactoryContext validatorContext, PathImpl path, Object value, GraphContext parent) {
super();
this.validatorContext = Validate.notNull(validatorContext, "validatorContext");
this.path = Validate.notNull(path, "path");
this.validatorContext = validatorContext;
this.path = path;
this.value = value;
this.parent = parent;
}
@@ -65,16 +64,16 @@ public Object getValue() {
}

public GraphContext child(NodeImpl node, Object value) {
Validate.notNull(node, "node");
// Validate.notNull(node, "node");
final PathImpl p = PathImpl.copy(path);
p.addNode(node);
return new GraphContext(validatorContext, p, value, this);
}

public GraphContext child(Path p, Object value) {
Validate.notNull(p, "Path");
// Validate.notNull(p, "Path");
final PathImpl impl = PathImpl.of(p);
Validate.isTrue(impl.isSubPathOf(path), "%s is not a subpath of %s", p, path);
// Validate.isTrue(impl.isSubPathOf(path), "%s is not a subpath of %s", p, path);
return new GraphContext(validatorContext, impl == p ? PathImpl.copy(impl) : impl, value, this);
}

@@ -120,7 +119,6 @@ public int hashCode() {
}

public ContainerElementKey runtimeKey(ContainerElementKey key) {
Validate.notNull(key);
if (value != null) {
final Class<?> containerClass = key.getContainerClass();
final Class<? extends Object> runtimeType = value.getClass();
@@ -28,7 +28,6 @@
import org.apache.bval.jsr.GraphContext;
import org.apache.bval.jsr.util.Methods;
import org.apache.bval.jsr.util.PathImpl;
import org.apache.bval.util.Validate;
import org.apache.bval.util.reflection.Reflection;
import org.apache.commons.weaver.privilizer.Privilizing;
import org.apache.commons.weaver.privilizer.Privilizing.CallTo;
@@ -94,7 +93,6 @@ protected PropertyD(MetadataReader.ForContainer<E> reader, BeanD<?> parent) {
}

public final Stream<GraphContext> read(GraphContext context) {
Validate.notNull(context);
if (context.getValue() == null) {
return Stream.empty();
}
@@ -34,7 +34,6 @@

import org.apache.bval.util.Exceptions;
import org.apache.bval.util.ObjectWrapper;
import org.apache.bval.util.Validate;

/**
* Immutable object that wraps an interface representing a single group.
@@ -128,7 +127,7 @@ public static final Sequence sequence(Collection<Group> groups) {
* @param group
*/
public Group(Class<?> group) {
this.group = Validate.notNull(group);
this.group = group;
}

/**
@@ -29,7 +29,6 @@
import java.util.stream.Collectors;

import org.apache.bval.jsr.util.ToUnmodifiable;
import org.apache.bval.util.Validate;

/**
* Group strategy interface.
@@ -78,8 +77,6 @@ public static class Composite implements GroupStrategy {
protected final boolean ordered;

public Composite(Collection<? extends GroupStrategy> components, boolean ordered) {
Validate.isTrue(Validate.notNull(components).stream().noneMatch(Objects::isNull),
"null component not permitted");
this.components = new LinkedHashSet<>(components);
this.ordered = ordered;
}
@@ -155,8 +152,6 @@ public Set<Group> getGroups() {
};

public static GroupStrategy redefining(GroupStrategy source, Map<Group, ? extends GroupStrategy> redefinitions) {
Validate.notNull(source, "source");

if (!(redefinitions == null || redefinitions.isEmpty())) {
if (redefinitions.containsValue(null)) {
redefinitions = redefinitions.entrySet().stream().filter(e -> e.getValue() != null)
@@ -174,7 +169,6 @@ public static GroupStrategy simple(Group... groups) {
}

public static GroupStrategy simple(Collection<? extends Group> coll) {
Validate.notNull(coll);
if (coll.size() == 1) {
return coll.iterator().next();
}
@@ -257,7 +257,6 @@ public ValueExtractors createChild(OnDuplicateContainerElementKey onDuplicateCon
}

public void add(ValueExtractor<?> extractor) {
Validate.notNull(extractor);
final ContainerElementKey key = ContainerElementKey.forValueExtractor(extractor);
if (key == null) {
Exceptions.raise(IllegalStateException::new, "Computed null %s for %s",

0 comments on commit 43935b4

Please sign in to comment.