1 package org.codehaus.plexus.languages.java.jpms;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.File;
23 import java.nio.file.Path;
24 import java.nio.file.Paths;
25
26
27
28
29
30
31 public abstract class ResolvePathRequest<T> {
32 private Path jdkHome;
33
34 private T path;
35
36 private ResolvePathRequest() {}
37
38 public static ResolvePathRequest<File> ofFile(File file) {
39 ResolvePathRequest<File> request = new ResolvePathRequest<File>() {
40 @Override
41 protected Path toPath(File f) {
42 return f.toPath();
43 }
44 };
45 request.path = file;
46 return request;
47 }
48
49 public static ResolvePathRequest<Path> ofPath(Path path) {
50 ResolvePathRequest<Path> request = new ResolvePathRequest<Path>() {
51 @Override
52 protected Path toPath(Path p) {
53 return p;
54 }
55 };
56 request.path = path;
57 return request;
58 }
59
60 public static ResolvePathRequest<String> ofString(String string) {
61 ResolvePathRequest<String> request = new ResolvePathRequest<String>() {
62 @Override
63 protected Path toPath(String s) {
64 return Paths.get(s);
65 }
66 };
67 request.path = string;
68 return request;
69 }
70
71 protected abstract Path toPath(T t);
72
73 public T getPathElement() {
74 return path;
75 }
76
77
78
79
80
81
82
83 public ResolvePathRequest<T> setJdkHome(T jdkHome) {
84 this.jdkHome = toPath(jdkHome);
85 return this;
86 }
87
88 public Path getJdkHome() {
89 return jdkHome;
90 }
91 }