Skip to content

Commit

Permalink
Adds null checks for apply(F), throwing an NPE if parameter is null a…
Browse files Browse the repository at this point in the history
…s evidently

required by the @nullable contract of apply() and as FindBug's
NP_PARAMETER_MUST_BE_NONNULL_BUT_MARKED_AS_NULLABLE
has gently reminded.
  • Loading branch information
Edwin Shin committed Apr 12, 2013
1 parent 9ae0ae9 commit 1053fd5
Showing 1 changed file with 7 additions and 3 deletions.
@@ -1,6 +1,7 @@

package org.fcrepo.utils;

import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.Collections2.transform;
import static com.google.common.collect.ImmutableSet.copyOf;
import static org.fcrepo.utils.FedoraJcrTypes.FEDORA_DATASTREAM;
Expand Down Expand Up @@ -35,7 +36,7 @@ public class FedoraTypesUtils {

@Override
public boolean apply(Node node) {

checkNotNull(node);
try {
return map(node.getMixinNodeTypes(), nodetype2name).contains(
FEDORA_OBJECT);
Expand All @@ -52,7 +53,7 @@ public boolean apply(Node node) {

@Override
public boolean apply(Node node) {

checkNotNull(node);
try {
return map(node.getMixinNodeTypes(), nodetype2name).contains(
FEDORA_DATASTREAM);
Expand All @@ -69,7 +70,7 @@ public boolean apply(Node node) {

@Override
public boolean apply(Node node) {

checkNotNull(node);
try {
return map(node.getMixinNodeTypes(), nodetype2name).contains(
FEDORA_OWNED);
Expand All @@ -87,6 +88,7 @@ public boolean apply(Node node) {

@Override
public String apply(NodeType t) {
checkNotNull(t);
return t.getName();
}
};
Expand All @@ -99,6 +101,7 @@ public String apply(NodeType t) {

@Override
public String apply(Value v) {
checkNotNull(v);
try {
return v.getString();
} catch (RepositoryException e) {
Expand All @@ -112,6 +115,7 @@ public String apply(Value v) {

@Override
public ValueFactory apply(Node n) {
checkNotNull(n);
try {
return n.getSession().getValueFactory();
} catch (RepositoryException e) {
Expand Down

0 comments on commit 1053fd5

Please sign in to comment.