@@ -86,7 +86,8 @@ public PathPredicateBuilder fileTest(Predicate<File> predicate) {
8686 * @return this builder for chaining
8787 */
8888 public PathPredicateBuilder hasName (String name ) {
89- return pathTest (PathPredicates .hasName (name ));
89+ Objects .requireNonNull (name , "name is null" );
90+ return pathTest (path -> PathPredicates .hasName (path , name ));
9091 }
9192
9293 /**
@@ -98,7 +99,8 @@ public PathPredicateBuilder hasName(String name) {
9899 * @return this builder for chaining
99100 */
100101 public PathPredicateBuilder hasNameIgnoreCase (String name ) {
101- return pathTest (PathPredicates .hasNameIgnoreCase (name ));
102+ Objects .requireNonNull (name , "name is null" );
103+ return pathTest (path -> PathPredicates .hasNameIgnoreCase (path , name ));
102104 }
103105
104106 /**
@@ -109,7 +111,8 @@ public PathPredicateBuilder hasNameIgnoreCase(String name) {
109111 * @return this builder for chaining
110112 */
111113 public PathPredicateBuilder hasNameMatching (Pattern pattern ) {
112- return pathTest (PathPredicates .hasNameMatching (pattern ));
114+ Objects .requireNonNull (pattern , "pattern is null" );
115+ return pathTest (path -> PathPredicates .hasNameMatching (path , pattern ));
113116 }
114117
115118 /**
@@ -120,7 +123,8 @@ public PathPredicateBuilder hasNameMatching(Pattern pattern) {
120123 * @return this builder for chaining
121124 */
122125 public PathPredicateBuilder hasNameEndingWith (String suffix ) {
123- return pathTest (PathPredicates .hasNameEndingWith (suffix ));
126+ Objects .requireNonNull (suffix , "suffix is null" );
127+ return pathTest (path -> PathPredicates .hasNameEndingWith (path , suffix ));
124128 }
125129
126130 /**
@@ -135,7 +139,8 @@ public PathPredicateBuilder hasNameEndingWith(String suffix) {
135139 * @return this builder for chaining
136140 */
137141 public PathPredicateBuilder hasExtension (String extension ) {
138- return pathTest (PathPredicates .hasExtension (extension ));
142+ Objects .requireNonNull (extension , "extension is null" );
143+ return pathTest (path -> PathPredicates .hasExtension (path , extension ));
139144 }
140145
141146 // ---------- Type ----------
@@ -146,7 +151,7 @@ public PathPredicateBuilder hasExtension(String extension) {
146151 * @return this builder for chaining
147152 */
148153 public PathPredicateBuilder isDirectory () {
149- return pathTest (PathPredicates .isDirectory ());
154+ return pathTest (path -> PathPredicates .isDirectory (path ));
150155 }
151156
152157 /**
@@ -155,7 +160,7 @@ public PathPredicateBuilder isDirectory() {
155160 * @return this builder for chaining
156161 */
157162 public PathPredicateBuilder isFile () {
158- return pathTest (PathPredicates .isFile ());
163+ return pathTest (path -> PathPredicates .isFile (path ));
159164 }
160165
161166 // ---------- Hierarchy ----------
@@ -170,7 +175,8 @@ public PathPredicateBuilder isFile() {
170175 * @see PathPredicates#hasParentMatching(Predicate)
171176 */
172177 public PathPredicateBuilder hasParentMatching (Predicate <Path > parentPredicate ) {
173- return pathTest (PathPredicates .hasParentMatching (parentPredicate ));
178+ Objects .requireNonNull (parentPredicate , "parentPredicate is null" );
179+ return pathTest (path -> PathPredicates .hasParentMatching (path , parentPredicate ));
174180 }
175181
176182 /**
@@ -186,7 +192,8 @@ public PathPredicateBuilder hasParentMatching(Predicate<Path> parentPredicate) {
186192 * @see PathPredicates#hasAncestorMatching(Predicate)
187193 */
188194 public PathPredicateBuilder hasAncestorMatching (Predicate <Path > ancestorPredicate ) {
189- return pathTest (PathPredicates .hasAncestorMatching (ancestorPredicate ));
195+ Objects .requireNonNull (ancestorPredicate , "ancestorPredicate is null" );
196+ return pathTest (path -> PathPredicates .hasAncestorMatching (path , ancestorPredicate ));
190197 }
191198
192199 /**
@@ -202,7 +209,8 @@ public PathPredicateBuilder hasAncestorMatching(Predicate<Path> ancestorPredicat
202209 * @see PathPredicates#hasDirectChildMatching(Predicate)
203210 */
204211 public PathPredicateBuilder hasDirectChildMatching (Predicate <Path > childPredicate ) {
205- return pathTest (PathPredicates .hasDirectChildMatching (childPredicate ));
212+ Objects .requireNonNull (childPredicate , "childPredicate is null" );
213+ return pathTest (path -> PathPredicates .hasDirectChildMatching (path , childPredicate ));
206214 }
207215
208216 /**
@@ -218,7 +226,8 @@ public PathPredicateBuilder hasDirectChildMatching(Predicate<Path> childPredicat
218226 * @see PathPredicates#hasDescendantMatching(Predicate)
219227 */
220228 public PathPredicateBuilder hasDescendantMatching (Predicate <Path > descendantPredicate ) {
221- return pathTest (PathPredicates .hasDescendantMatching (descendantPredicate ));
229+ Objects .requireNonNull (descendantPredicate , "descendantPredicate is null" );
230+ return pathTest (path -> PathPredicates .hasDescendantMatching (path , descendantPredicate ));
222231 }
223232
224233 /**
@@ -234,7 +243,8 @@ public PathPredicateBuilder hasDescendantMatching(Predicate<Path> descendantPred
234243 * @see PathPredicates#hasSiblingMatching(Predicate)
235244 */
236245 public PathPredicateBuilder hasSiblingMatching (Predicate <Path > siblingPredicate ) {
237- return pathTest (PathPredicates .hasSiblingMatching (siblingPredicate ));
246+ Objects .requireNonNull (siblingPredicate , "siblingPredicate is null" );
247+ return pathTest (path -> PathPredicates .hasSiblingMatching (path , siblingPredicate ));
238248 }
239249
240250}
0 commit comments