View Javadoc
1   /*
2    *    Copyright 2016-2025 the original author or authors.
3    *
4    *    Licensed under the Apache License, Version 2.0 (the "License");
5    *    you may not use this file except in compliance with the License.
6    *    You may obtain a copy of the License at
7    *
8    *       https://www.apache.org/licenses/LICENSE-2.0
9    *
10   *    Unless required by applicable law or agreed to in writing, software
11   *    distributed under the License is distributed on an "AS IS" BASIS,
12   *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *    See the License for the specific language governing permissions and
14   *    limitations under the License.
15   */
16  package org.mybatis.dynamic.sql.where.condition;
17  
18  import java.util.NoSuchElementException;
19  import java.util.function.Function;
20  import java.util.function.Predicate;
21  
22  import org.mybatis.dynamic.sql.AbstractSingleValueCondition;
23  
24  public class IsNotLike<T> extends AbstractSingleValueCondition<T>
25          implements AbstractSingleValueCondition.Filterable<T>, AbstractSingleValueCondition.Mappable<T> {
26      private static final IsNotLike<?> EMPTY = new IsNotLike<Object>(-1) {
27          @Override
28          public Object value() {
29              throw new NoSuchElementException("No value present"); //$NON-NLS-1$
30          }
31  
32          @Override
33          public boolean isEmpty() {
34              return true;
35          }
36      };
37  
38      public static <T> IsNotLike<T> empty() {
39          @SuppressWarnings("unchecked")
40          IsNotLike<T> t = (IsNotLike<T>) EMPTY;
41          return t;
42      }
43  
44      protected IsNotLike(T value) {
45          super(value);
46      }
47  
48      @Override
49      public String operator() {
50          return "not like"; //$NON-NLS-1$
51      }
52  
53      public static <T> IsNotLike<T> of(T value) {
54          return new IsNotLike<>(value);
55      }
56  
57      @Override
58      public IsNotLike<T> filter(Predicate<? super T> predicate) {
59          return filterSupport(predicate, IsNotLike::empty, this);
60      }
61  
62      @Override
63      public <R> IsNotLike<R> map(Function<? super T, ? extends R> mapper) {
64          return mapSupport(mapper, IsNotLike::new, IsNotLike::empty);
65      }
66  }