Browse Source

Add JSR305

Use @Nonnull
pull/5/head
Greg Holmes 9 years ago
parent
commit
7305fae38d
2 changed files with 7 additions and 3 deletions
  1. 2
    0
      build.gradle
  2. 5
    3
      src/com/dmdirc/util/StringUtils.java

+ 2
- 0
build.gradle View File

@@ -27,6 +27,8 @@ targetCompatibility = 1.7
27 27
 repositories.mavenCentral()
28 28
 
29 29
 dependencies {
30
+    compile group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.0'
31
+
30 32
     testCompile group: 'junit', name: 'junit', version: '4.11'
31 33
     testCompile group: 'org.mockito', name: 'mockito-all', version: '1.9.5'
32 34
     testCompile group: 'com.google.jimfs', name: 'jimfs', version: '1.0'

+ 5
- 3
src/com/dmdirc/util/StringUtils.java View File

@@ -22,6 +22,8 @@
22 22
 
23 23
 package com.dmdirc.util;
24 24
 
25
+import javax.annotation.Nonnull;
26
+
25 27
 /**
26 28
  * Utilities for dealing with strings.
27 29
  */
@@ -41,7 +43,7 @@ public final class StringUtils {
41 43
      * the index of the first character beyond the end of the word. If the specified index is not
42 44
      * contained within a word (i.e., is whitespace) then 0,0 is returned.
43 45
      */
44
-    public static int[] indiciesOfWord(final CharSequence text, final int index) {
46
+    public static int[] indiciesOfWord(@Nonnull final CharSequence text, final int index) {
45 47
         final int start = indexOfStartOfWord(text, index);
46 48
         final int end = indexOfEndOfWord(text, index);
47 49
 
@@ -61,7 +63,7 @@ public final class StringUtils {
61 63
      *
62 64
      * @return Start index of the word surrounding the index
63 65
      */
64
-    public static int indexOfStartOfWord(final CharSequence text, final int index) {
66
+    public static int indexOfStartOfWord(@Nonnull final CharSequence text, final int index) {
65 67
         int start = index;
66 68
 
67 69
         // Traverse backwards
@@ -83,7 +85,7 @@ public final class StringUtils {
83 85
      *
84 86
      * @return End index of the word surrounding the index
85 87
      */
86
-    public static int indexOfEndOfWord(final CharSequence text, final int index) {
88
+    public static int indexOfEndOfWord(@Nonnull final CharSequence text, final int index) {
87 89
         int end = index;
88 90
 
89 91
         // And forwards

Loading…
Cancel
Save