View Javadoc
1   /*
2    *    Copyright 2015-2022 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.caches.redis;
17  
18  import java.util.concurrent.TimeUnit;
19  import java.util.concurrent.locks.Condition;
20  import java.util.concurrent.locks.Lock;
21  import java.util.concurrent.locks.ReadWriteLock;
22  
23  /**
24   * @author Iwao AVE!
25   */
26  class DummyReadWriteLock implements ReadWriteLock {
27  
28    private Lock lock = new DummyLock();
29  
30    @Override
31    public Lock readLock() {
32      return lock;
33    }
34  
35    @Override
36    public Lock writeLock() {
37      return lock;
38    }
39  
40    static class DummyLock implements Lock {
41  
42      @Override
43      public void lock() {
44        // Not implemented
45      }
46  
47      @Override
48      public void lockInterruptibly() throws InterruptedException {
49        // Not implemented
50      }
51  
52      @Override
53      public boolean tryLock() {
54        return true;
55      }
56  
57      @Override
58      public boolean tryLock(long paramLong, TimeUnit paramTimeUnit) throws InterruptedException {
59        return true;
60      }
61  
62      @Override
63      public void unlock() {
64        // Not implemented
65      }
66  
67      @Override
68      public Condition newCondition() {
69        return null;
70      }
71    }
72  
73  }