1 /*
2 * Copyright (c) 2011-2024 Qulice.com
3 *
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met: 1) Redistributions of source code must retain the above
9 * copyright notice, this list of conditions and the following
10 * disclaimer. 2) Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following
12 * disclaimer in the documentation and/or other materials provided
13 * with the distribution. 3) Neither the name of the Qulice.com nor
14 * the names of its contributors may be used to endorse or promote
15 * products derived from this software without specific prior written
16 * permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
20 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
21 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22 * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
29 * OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31 package com.qulice.ant;
32
33 import org.apache.tools.ant.types.Path;
34
35 /**
36 * Represents subset of org.apache.tools.ant.types.Path API which is relevant to Qulice.
37 *
38 * @since 1.0
39 */
40 public interface AntPath {
41 /**
42 * Returns all indivudual pathes of this path.
43 * @return List of elements.
44 */
45 String[] list();
46
47 /**
48 * Default implementation which wraps Ant path.
49 * @since 1.0
50 */
51 class Default implements AntPath {
52 /**
53 * Wrapped path.
54 */
55 private final Path path;
56
57 /**
58 * Returns AntPath equivalent to the given path.
59 * @param path A path to wrap.
60 */
61 Default(final Path path) {
62 this.path = path;
63 }
64
65 @Override
66 public String[] list() {
67 return this.path.list();
68 }
69 }
70
71 /**
72 * Simple implementation for tests.
73 * @since 1.0
74 */
75 class Fake implements AntPath {
76 /**
77 * Result for the list() method.
78 */
79 private final String[] listres;
80
81 /**
82 * Creates fake AntPath.
83 * @param listres Array to return from the list(), assumed to be immutable.
84 * @since 1.0
85 */
86 Fake(final String... listres) {
87 this.listres = listres;
88 }
89
90 @Override
91 public String[] list() {
92 return this.listres;
93 }
94 }
95 }