You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by md...@apache.org on 2012/05/30 11:16:48 UTC

svn commit: r1344163 - in /jackrabbit/oak/trunk/oak-commons: pom.xml src/main/java/org/apache/jackrabbit/oak/commons/ArrayUtils.java src/main/java/org/apache/jackrabbit/oak/commons/PathUtils.java

Author: mduerig
Date: Wed May 30 09:16:47 2012
New Revision: 1344163

URL: http://svn.apache.org/viewvc?rev=1344163&view=rev
Log:
OAK-37: Use nullability annotation to enforce/document API contract

Modified:
    jackrabbit/oak/trunk/oak-commons/pom.xml
    jackrabbit/oak/trunk/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/ArrayUtils.java
    jackrabbit/oak/trunk/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/PathUtils.java

Modified: jackrabbit/oak/trunk/oak-commons/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-commons/pom.xml?rev=1344163&r1=1344162&r2=1344163&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-commons/pom.xml (original)
+++ jackrabbit/oak/trunk/oak-commons/pom.xml Wed May 30 09:16:47 2012
@@ -47,8 +47,13 @@
       <artifactId>slf4j-api</artifactId>
       <version>1.6.4</version>
     </dependency>
+    <dependency>
+      <groupId>com.google.code.findbugs</groupId>
+      <artifactId>jsr305</artifactId>
+      <version>1.3.9</version>
+    </dependency>
 
-    <!-- Test dependencies -->
+      <!-- Test dependencies -->
     <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>

Modified: jackrabbit/oak/trunk/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/ArrayUtils.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/ArrayUtils.java?rev=1344163&r1=1344162&r2=1344163&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/ArrayUtils.java (original)
+++ jackrabbit/oak/trunk/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/ArrayUtils.java Wed May 30 09:16:47 2012
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.oak.commons;
 
+import javax.annotation.Nonnull;
 import java.lang.reflect.Array;
 import java.util.HashSet;
 import java.util.Set;
@@ -40,6 +41,7 @@ public class ArrayUtils {
      * @param x the value to add
      * @return the new array
      */
+    @Nonnull
     public static <T> T[] arrayReplace(T[] values, int index, T x) {
         int size = values.length;
         @SuppressWarnings("unchecked")
@@ -89,6 +91,7 @@ public class ArrayUtils {
      * @param x the value to add
      * @return the new array
      */
+    @Nonnull
     public static <T> T[] arrayInsert(T[] values, int index, T x) {
         int size = values.length;
         @SuppressWarnings("unchecked")
@@ -106,6 +109,7 @@ public class ArrayUtils {
      * @param x the value to add
      * @return the new array
      */
+    @Nonnull
     public static String[] arrayInsert(String[] values, int index, String x) {
         int size = values.length;
         String[] v2 = new String[size + 1];
@@ -138,6 +142,7 @@ public class ArrayUtils {
      * @param index the index
      * @return the new array
      */
+    @Nonnull
     public static <T> T[] arrayRemove(T[] values, int index) {
         int size = values.length;
         @SuppressWarnings("unchecked")
@@ -171,6 +176,7 @@ public class ArrayUtils {
      * @param index the index
      * @return the new array
      */
+    @Nonnull
     public static String[] arrayRemove(String[] values, int index) {
         int size = values.length;
         if (size == 1) {
@@ -221,6 +227,7 @@ public class ArrayUtils {
      * @param <T>
      * @return
      */
+    @Nonnull
     public static <T> Set<T> toSet(T... elements) {
         return new HashSet<T>(java.util.Arrays.asList(elements));
     }

Modified: jackrabbit/oak/trunk/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/PathUtils.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/PathUtils.java?rev=1344163&r1=1344162&r2=1344163&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/PathUtils.java (original)
+++ jackrabbit/oak/trunk/oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/PathUtils.java Wed May 30 09:16:47 2012
@@ -16,6 +16,7 @@
  */
 package org.apache.jackrabbit.oak.commons;
 
+import javax.annotation.Nonnull;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.NoSuchElementException;
@@ -73,6 +74,7 @@ public class PathUtils {
      * @param path the path
      * @return the parent path
      */
+    @Nonnull
     public static String getParentPath(String path) {
         return getAncestorPath(path, 1);
     }
@@ -86,6 +88,7 @@ public class PathUtils {
      * @param path the path
      * @return the ancestor path
      */
+    @Nonnull
     public static String getAncestorPath(String path, int nth) {
         assert isValid(path);
 
@@ -117,6 +120,7 @@ public class PathUtils {
      * @param path the complete path
      * @return the last element
      */
+    @Nonnull
     public static String getName(String path) {
         assert isValid(path);
 
@@ -164,6 +168,7 @@ public class PathUtils {
      * @param path the path
      * @return the path elements
      */
+    @Nonnull
     public static String[] split(String path) {
         assert isValid(path);
 
@@ -198,6 +203,7 @@ public class PathUtils {
      * @param path the path
      * @return an Iterable for the path elements
      */
+    @Nonnull
     public static Iterable<String> elements(final String path) {
         assert isValid(path);
 
@@ -262,6 +268,7 @@ public class PathUtils {
      * @param relativePaths the relative path elements to add
      * @return the concatenated path
      */
+    @Nonnull
     public static String concat(String parentPath, String... relativePaths) {
         assert isValid(parentPath);
         int parentLen = parentPath.length();
@@ -292,6 +299,7 @@ public class PathUtils {
      * @param subPath the subPath path to add
      * @return the concatenated path
      */
+    @Nonnull
     public static String concat(String parentPath, String subPath) {
         assert isValid(parentPath);
         assert isValid(subPath);
@@ -339,6 +347,7 @@ public class PathUtils {
      * @param path path to relativize
      * @return relativized path
      */
+    @Nonnull
     public static String relativize(String parentPath, String path) {
         assert isValid(parentPath);
         assert isValid(path);