You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2016/01/29 14:13:39 UTC
[4/5] jena git commit: Add some not-null checking.
Add some not-null checking.
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/f25c0f02
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/f25c0f02
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/f25c0f02
Branch: refs/heads/master
Commit: f25c0f027573a86d7bad559300751318c0f1dab4
Parents: 61d13b5
Author: Andy Seaborne <an...@apache.org>
Authored: Fri Jan 29 10:15:24 2016 +0000
Committer: Andy Seaborne <an...@apache.org>
Committed: Fri Jan 29 12:35:54 2016 +0000
----------------------------------------------------------------------
.../java/org/apache/jena/graph/NodeFactory.java | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/f25c0f02/jena-core/src/main/java/org/apache/jena/graph/NodeFactory.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/graph/NodeFactory.java b/jena-core/src/main/java/org/apache/jena/graph/NodeFactory.java
index d127bb9..56af943 100644
--- a/jena-core/src/main/java/org/apache/jena/graph/NodeFactory.java
+++ b/jena-core/src/main/java/org/apache/jena/graph/NodeFactory.java
@@ -18,6 +18,8 @@
package org.apache.jena.graph ;
+import java.util.Objects ;
+
import org.apache.jena.datatypes.DatatypeFormatException ;
import org.apache.jena.datatypes.RDFDatatype ;
import org.apache.jena.datatypes.TypeMapper ;
@@ -27,6 +29,7 @@ import org.apache.jena.graph.impl.LiteralLabelFactory ;
public class NodeFactory {
public static RDFDatatype getType(String s) {
+ Objects.requireNonNull(s, "Argument to NodeFactory.getFactory is null") ;
return TypeMapper.getInstance().getSafeTypeByName(s) ;
}
@@ -38,6 +41,7 @@ public class NodeFactory {
/** make a blank node with the specified label
*/
public static Node createBlankNode(BlankNodeId id) {
+ Objects.requireNonNull(id, "Argument to NodeFactory.createBlankNode is null") ;
return new Node_Blank(id) ;
}
@@ -60,6 +64,7 @@ public class NodeFactory {
*/
@Deprecated
public static Node createAnon(BlankNodeId id) {
+ Objects.requireNonNull(id, "Argument to NodeFactory.createAnon is null") ;
return new Node_Blank(id) ;
}
@@ -68,26 +73,31 @@ public class NodeFactory {
*/
@Deprecated
public static Node createAnon(String string) {
+ Objects.requireNonNull(string, "Argument to NodeFactory.createAnon is null") ;
BlankNodeId id = BlankNodeId.create(string) ;
return new Node_Blank(id) ;
}
/** make a literal node with the specified literal value */
public static Node createLiteral(LiteralLabel lit) {
+ Objects.requireNonNull(lit, "Argument to NodeFactory.createLiteral is null") ;
return new Node_Literal( lit ) ;
}
/** make a URI node with the specified URIref string */
public static Node createURI(String uri) {
+ Objects.requireNonNull(uri, "Argument to NodeFactory.createURI is null") ;
return new Node_URI(uri) ;
}
/** make a variable node with a given name */
public static Node createVariable(String name) {
+ Objects.requireNonNull(name, "Argument to NodeFactory.createVariable is null") ;
return new Node_Variable(name) ;
}
public static Node createLiteral(String value) {
+ Objects.requireNonNull(value, "Argument to NodeFactory.createLiteral is null") ;
return createLiteral(value, "", false) ;
}
@@ -168,12 +178,13 @@ public class NodeFactory {
* @throws DatatypeFormatException
*/
public static Node createLiteralByValue(Object value, RDFDatatype dtype) throws DatatypeFormatException {
+ Objects.requireNonNull(value, "Argument 'value' to NodeFactory.createLiteralByValue is null") ;
return new Node_Literal(LiteralLabelFactory.createByValue(value, "", dtype)) ;
}
/** Create a Node based on the value
* If the value is a string we
- * assume this is inteded to be a lexical form after all.
+ * assume this is intended to be a lexical form after all.
* @param value
* The value, mapped according to registered types.
* @param lang
@@ -184,18 +195,21 @@ public class NodeFactory {
* @throws DatatypeFormatException
*/
public static Node createLiteralByValue(Object value, String lang, RDFDatatype dtype) throws DatatypeFormatException {
+ Objects.requireNonNull(value, "Argument 'value' to NodeFactory.createLiteralByValue is null") ;
return new Node_Literal(LiteralLabelFactory.createByValue(value, lang, dtype)) ;
}
/** @deprecated To be removed: Use {@link #createLiteralByValue(Object, RDFDatatype)} */
@Deprecated
public static Node createUncachedLiteral(Object value, RDFDatatype dtype) throws DatatypeFormatException {
+ Objects.requireNonNull(value, "Argument 'value' to NodeFactory.createLiteralByValue is null") ;
return createLiteralByValue(value, dtype) ;
}
/** @deprecated To be removed: Use {@link #createLiteralByValue(Object, String, RDFDatatype)} */
@Deprecated
public static Node createUncachedLiteral(Object value, String lang, RDFDatatype dtype) throws DatatypeFormatException {
+ Objects.requireNonNull(value, "Argument 'value' to NodeFactory.createLiteralByValue is null") ;
return createLiteralByValue(value, lang, dtype) ;
}
}