-
Notifications
You must be signed in to change notification settings - Fork 14
/
TransformationConfiguration.java
154 lines (122 loc) · 5.39 KB
/
TransformationConfiguration.java
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/**
* Copyright (C) 2020 Czech Technical University in Prague
* <p>
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later
* version.
* <p>
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details. You should have received a copy of the GNU General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
package cz.cvut.kbss.jopa.owl2java.config;
import cz.cvut.kbss.jopa.owl2java.cli.CliParams;
import cz.cvut.kbss.jopa.owl2java.cli.Option;
import cz.cvut.kbss.jopa.owl2java.cli.PropertiesType;
public class TransformationConfiguration {
private final String context;
private final String packageName;
private final String targetDir;
private final boolean generateOwlapiIris;
private final boolean generateJavadoc;
private final boolean preferMultilingualStrings;
private final PropertiesType propertiesType;
private final CliParams cliParams;
private TransformationConfiguration(TransformationConfigurationBuilder builder) {
this.context = builder.context;
this.packageName = builder.packageName;
this.targetDir = builder.targetDir;
this.generateOwlapiIris = builder.owlapiIris;
this.generateJavadoc = builder.generateJavadoc;
this.preferMultilingualStrings = builder.preferMultilingualStrings;
this.propertiesType = builder.propertiesType;
this.cliParams = CliParams.empty();
}
private TransformationConfiguration(CliParams cliParams) {
this.cliParams = cliParams;
this.context =
cliParams.is(Option.WHOLE_ONTOLOGY_AS_IC.arg) ? null : cliParams.valueOf(Option.CONTEXT.arg).toString();
this.packageName = cliParams.valueOf(Option.PACKAGE.arg).toString();
this.targetDir = cliParams.valueOf(Option.TARGET_DIR.arg).toString();
this.generateOwlapiIris = cliParams.is(Option.WITH_IRIS.arg, Defaults.WITH_IRIS);
this.generateJavadoc = cliParams
.is(Option.GENERATE_JAVADOC_FROM_COMMENT.arg, Defaults.GENERATE_JAVADOC_FROM_COMMENT);
this.preferMultilingualStrings = cliParams
.is(Option.PREFER_MULTILINGUAL_STRINGS.arg, Defaults.PREFER_MULTILINGUAL_STRINGS);
this.propertiesType = PropertiesType.fromParam(cliParams.valueOf(Option.PROPERTIES_TYPE.arg));
}
public String getContext() {
return context;
}
public String getPackageName() {
return packageName;
}
public String getTargetDir() {
return targetDir;
}
public boolean areAllAxiomsIntegrityConstraints() {
return context == null;
}
public boolean shouldGenerateOwlapiIris() {
return generateOwlapiIris;
}
public boolean shouldGenerateJavadoc() {
return generateJavadoc;
}
public boolean shouldPreferMultilingualStrings() {
return preferMultilingualStrings;
}
public PropertiesType getPropertiesType() {
return propertiesType;
}
public CliParams getCliParams() {
return cliParams;
}
public static TransformationConfiguration config(CliParams cliParams) {
return new TransformationConfiguration(cliParams);
}
public static TransformationConfigurationBuilder builder() {
return new TransformationConfigurationBuilder();
}
public static class TransformationConfigurationBuilder {
private String context;
private String packageName = Defaults.PACKAGE;
private String targetDir = Defaults.TARGET_DIR;
private PropertiesType propertiesType = PropertiesType.valueOf(Defaults.PROPERTIES_TYPE);
private boolean owlapiIris = Defaults.WITH_IRIS;
private boolean generateJavadoc = Defaults.GENERATE_JAVADOC_FROM_COMMENT;
private boolean preferMultilingualStrings = true;
public TransformationConfigurationBuilder context(String context) {
this.context = context;
return this;
}
public TransformationConfigurationBuilder packageName(String packageName) {
this.packageName = packageName;
return this;
}
public TransformationConfigurationBuilder targetDir(String targetDir) {
this.targetDir = targetDir;
return this;
}
public TransformationConfigurationBuilder addOwlapiIris(boolean add) {
this.owlapiIris = add;
return this;
}
public TransformationConfigurationBuilder generateJavadoc(boolean javadoc) {
this.generateJavadoc = javadoc;
return this;
}
public TransformationConfigurationBuilder preferMultilingualStrings(boolean preferMultilingualStrings) {
this.preferMultilingualStrings = preferMultilingualStrings;
return this;
}
public TransformationConfigurationBuilder propertiesType(PropertiesType propertiesType) {
this.propertiesType = propertiesType;
return this;
}
public TransformationConfiguration build() {
return new TransformationConfiguration(this);
}
}
}