1 package org.kuali.common.devops.jenkins.archive;
2
3 import static org.kuali.common.util.base.Precondition.checkNotNull;
4 import static org.kuali.common.util.file.Files.getCanonicalFile;
5
6 import java.io.File;
7
8 import com.google.common.base.Predicate;
9
10 public enum JenkinsBuildPredicate implements Predicate<File> {
11 INSTANCE;
12
13 @Override
14 public boolean apply(File dir) {
15 boolean directory = checkNotNull(dir, "dir").isDirectory();
16 boolean hasPrefix = dir.getName().startsWith("20");
17 boolean symlink = isSymLink(dir);
18 return directory && hasPrefix && !symlink;
19 }
20
21 private boolean isSymLink(File dir) {
22 String absolute = dir.getAbsolutePath();
23 String canonical = getCanonicalFile(dir).getPath();
24 return !canonical.equals(absolute);
25 }
26
27 }