• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2009 The Android Open Source Project
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  *      http://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 
17 package vogar;
18 
19 import java.io.File;
20 import java.util.ArrayList;
21 import java.util.Arrays;
22 import java.util.Collection;
23 import java.util.List;
24 import vogar.util.Strings;
25 
26 /**
27  * A list of jar files and directories.
28  */
29 public final class Classpath {
30 
31     private final List<File> elements = new ArrayList<File>();
32 
of(File... files)33     public static Classpath of(File... files) {
34         return of(Arrays.asList(files));
35     }
36 
of(Collection<File> files)37     public static Classpath of(Collection<File> files) {
38         Classpath result = new Classpath();
39         result.elements.addAll(files);
40         return result;
41     }
42 
addAll(File... elements)43     public void addAll(File... elements) {
44         addAll(Arrays.asList(elements));
45     }
46 
addAll(Collection<File> elements)47     public void addAll(Collection<File> elements) {
48         this.elements.addAll(elements);
49     }
50 
addAll(Classpath anotherClasspath)51     public void addAll(Classpath anotherClasspath) {
52         this.elements.addAll(anotherClasspath.elements);
53     }
54 
getElements()55     public Collection<File> getElements() {
56         return elements;
57     }
58 
isEmpty()59     public boolean isEmpty() {
60         return elements.isEmpty();
61     }
62 
contains(File file)63     public boolean contains(File file) {
64         return elements.contains(file);
65     }
66 
toString()67     @Override public String toString() {
68         return Strings.join(elements, ":");
69     }
70 }
71