View Javadoc

1   package com.atlassian.core.util.zip;
2   
3   import javax.annotation.concurrent.Immutable;
4   
5   @Immutable
6   public class ArchiveParams
7   {
8       private final String archiveFolderName;
9       private final boolean includeHiddenFiles;
10  
11      private ArchiveParams(Builder builder)
12      {
13          this.archiveFolderName = builder.archiveFolderName;
14          this.includeHiddenFiles = builder.includeHiddenFiles;
15      }
16  
17      public String getArchiveFolderName()
18      {
19          return archiveFolderName;
20      }
21  
22      public boolean isIncludeHiddenFiles()
23      {
24          return includeHiddenFiles;
25      }
26  
27      public static Builder builder()
28      {
29          return new Builder();
30      }
31  
32      public static class Builder
33      {
34          private String archiveFolderName;
35          private boolean includeHiddenFiles = true;
36  
37          private Builder()
38          {
39  
40          }
41  
42          /**
43           * The path used as target directory within archive, so all files and directories
44           * inside archive will start with this path. For example when {@code folderToCompress}
45           * is pointing into /home/A/B directory which contains file with path /home/A/B/C/file
46           * and {@code archiveFolderName} equals "archive" a result zip archive will contain
47           * entry: /archive/C/file
48           */
49          public Builder withArchiveFolderName(String archiveFolderName)
50          {
51              this.archiveFolderName = archiveFolderName;
52              return this;
53          }
54  
55          /**
56           * Should hidden files be included in the archive.
57           */
58          public Builder withIncludeHiddenFiles(boolean includeHiddenFiles)
59          {
60              this.includeHiddenFiles = includeHiddenFiles;
61              return this;
62          }
63  
64          public ArchiveParams build()
65          {
66              return new ArchiveParams(this);
67          }
68      }
69  }