blob: b34ab6221fba401fe71fc0fe584b845fd503d5bb [file] [log] [blame]
Tor Norbye814f8292014-03-06 17:27:18 -08001package com.jetbrains;
2
3import com.google.common.base.Predicate;
4import org.jetbrains.annotations.NotNull;
5import org.jetbrains.annotations.Nullable;
6
7/**
8 * Filters out nullable elements allowing children to filter not-null elements
9 *
10 * @author Ilya.Kazakevich
11 */
12public class NotNullPredicate<T> implements Predicate<T> {
13 /**
14 * Simply filters nulls
15 */
16 public static final Predicate<Object> INSTANCE = new NotNullPredicate<Object>();
17
18 @Override
19 public final boolean apply(@Nullable final T input) {
20 if (input == null) {
21 return false;
22 }
23 return applyNotNull(input);
24 }
25
26 protected boolean applyNotNull(@NotNull final T input) {
27 return true;
28 }
29}