summaryrefslogtreecommitdiff
path: root/platform/vcs-impl/src/com/intellij/openapi/vcs/impl/projectlevelman/RecursiveFilePathSet.java
blob: fb54450c492f92f88882a29bbb6098c448572adb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.openapi.vcs.impl.projectlevelman;

import com.intellij.openapi.vcs.FilePath;
import org.jetbrains.annotations.NotNull;

import java.util.Collection;

public class RecursiveFilePathSet {
  private final FilePathMapping<FilePath> myMapping;

  public RecursiveFilePathSet(boolean caseSensitive) {
    myMapping = new FilePathMapping<>(caseSensitive);
  }

  public void add(@NotNull FilePath filePath) {
    myMapping.add(filePath.getPath(), filePath);
  }

  public void addAll(@NotNull Collection<? extends FilePath> filePath) {
    for (FilePath path : filePath) {
      add(path);
    }
  }

  public void remove(@NotNull FilePath filePath) {
    myMapping.remove(filePath.getPath());
  }

  public boolean isEmpty() {
    return myMapping.values().isEmpty();
  }

  public void clear() {
    myMapping.clear();
  }

  public boolean contains(@NotNull FilePath filePath) {
    return myMapping.containsKey(filePath.getPath());
  }

  public boolean hasAncestor(@NotNull FilePath filePath) {
    return myMapping.getMappingFor(filePath.getPath()) != null;
  }

  @NotNull
  public Collection<FilePath> filePaths() {
    return myMapping.values();
  }
}