View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.buildcache.checksum;
20  
21  import java.nio.file.Path;
22  
23  /**
24   * WalkKey
25   */
26  public class WalkKey {
27  
28      private final Path normalized;
29      private final String glob;
30      private final boolean recursive;
31  
32      public WalkKey(Path normalized, String glob, boolean recursive) {
33          this.normalized = normalized;
34          this.glob = glob;
35          this.recursive = recursive;
36      }
37  
38      @Override
39      public boolean equals(Object o) {
40          if (this == o) {
41              return true;
42          }
43          if (o == null || getClass() != o.getClass()) {
44              return false;
45          }
46  
47          WalkKey key = (WalkKey) o;
48  
49          if (recursive != key.recursive) {
50              return false;
51          }
52          if (!normalized.equals(key.normalized)) {
53              return false;
54          }
55          return glob.equals(key.glob);
56      }
57  
58      @Override
59      public int hashCode() {
60          int result = normalized.hashCode();
61          result = 31 * result + glob.hashCode();
62          result = 31 * result + (recursive ? 1 : 0);
63          return result;
64      }
65  
66      public Path getPath() {
67          return normalized;
68      }
69  
70      public String getGlob() {
71          return glob;
72      }
73  
74      public boolean isRecursive() {
75          return recursive;
76      }
77  
78      @Override
79      public String toString() {
80          return "WalkKey{" + "normalized=" + normalized + ", glob='" + glob + '\'' + ", recursive=" + recursive + '}';
81      }
82  }