forked from devonfw/IDEasy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDelegatingToolCommandlet.java
More file actions
86 lines (69 loc) · 2.27 KB
/
DelegatingToolCommandlet.java
File metadata and controls
86 lines (69 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package com.devonfw.tools.ide.tool;
import java.nio.file.Path;
import java.util.Set;
import com.devonfw.tools.ide.common.Tag;
import com.devonfw.tools.ide.context.IdeContext;
import com.devonfw.tools.ide.environment.EnvironmentVariablesFiles;
import com.devonfw.tools.ide.process.ProcessContext;
import com.devonfw.tools.ide.version.VersionIdentifier;
/**
* {@link ToolCommandlet} that delegates to another ToolCommandlet.
*/
public abstract class DelegatingToolCommandlet<D extends ToolCommandlet> extends ToolCommandlet {
private Class<D> delegateClass;
/**
* The constructor.
*
* @param context the {@link IdeContext}.
* @param tool the {@link #getName() tool name}.
* @param tags the {@link #getTags() tags} classifying the tool. Should be created via {@link Set#of(Object) Set.of} method.
* @param delegateClass the {@link ToolCommandlet}.
*/
public DelegatingToolCommandlet(IdeContext context, String tool, Set<Tag> tags, Class<D> delegateClass) {
super(context, tool, tags);
this.delegateClass = delegateClass;
}
private D getDelegate() {
return getCommandlet(this.delegateClass);
}
@Override
public final boolean install(boolean silent, ProcessContext processContext) {
return getDelegate().install(silent, processContext);
}
@Override
public VersionIdentifier getInstalledVersion() {
return getDelegate().getInstalledVersion();
}
@Override
public String getInstalledEdition() {
return getDelegate().getInstalledEdition();
}
@Override
public Path getInstalledSoftwareRepoPath() {
return getDelegate().getInstalledSoftwareRepoPath();
}
@Override
public void uninstall() {
getDelegate().uninstall();
}
@Override
public void forceUninstall() {
getDelegate().forceUninstall();
}
@Override
public void listEditions() {
getDelegate().listEditions();
}
@Override
public void listVersions() {
getDelegate().listVersions();
}
@Override
public void setVersion(VersionIdentifier version, boolean hint, EnvironmentVariablesFiles destination) {
getDelegate().setVersion(version, hint, destination);
}
@Override
public void setEdition(String edition, boolean hint, EnvironmentVariablesFiles destination) {
getDelegate().setEdition(edition, hint, destination);
}
}