Skip to content

Commit fe85e24

Browse files
author
jantje
committed
#1339 merged the 2 version implementations
Also used the versionNumber class to store versions
1 parent ee7b5ca commit fe85e24

File tree

15 files changed

+211
-244
lines changed

15 files changed

+211
-244
lines changed

io.sloeber.core/src/io/sloeber/core/api/BoardDescription.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ private void ParseSection() {
205205
} else if (valueSplit.length == 4) {
206206
String refVendor = valueSplit[0];
207207
String refArchitecture = valueSplit[1];
208-
String refVersion = valueSplit[2];
208+
VersionNumber refVersion = new VersionNumber(valueSplit[2]);
209209
String actualValue = valueSplit[3];
210210
myBoardsCore = actualValue;
211211
myReferencedCorePlatformPath = InternalPackageManager.getPlatformInstallPath(refVendor, refArchitecture,
@@ -239,7 +239,7 @@ private void ParseSection() {
239239
} else if (valueSplit.length == 4) {
240240
String refVendor = valueSplit[0];
241241
String refArchitecture = valueSplit[1];
242-
String refVersion = valueSplit[2];
242+
VersionNumber refVersion = new VersionNumber(valueSplit[2]);
243243
String actualValue = valueSplit[3];
244244
this.myBoardsVariant = actualValue;
245245
if ("*".equals(refVersion)) { //$NON-NLS-1$
@@ -278,7 +278,7 @@ private void ParseSection() {
278278
} else if (valueSplit.length == 4) {
279279
String refVendor = valueSplit[0];
280280
String refArchitecture = valueSplit[1];
281-
String refVersion = valueSplit[2];
281+
VersionNumber refVersion = new VersionNumber(valueSplit[2]);
282282
String actualValue = valueSplit[3];
283283
this.myUploadTool = actualValue;
284284
this.myReferencedUploadToolPlatformPath = InternalPackageManager.getPlatformInstallPath(refVendor,
@@ -370,7 +370,8 @@ private void setDefaultOptions() {
370370
Map<String, String> allMenuIDs = this.myBoardTxtFile.getMenus();
371371
for (Map.Entry<String, String> curMenuID : allMenuIDs.entrySet()) {
372372
String providedMenuValue = this.myOptions.get(curMenuID.getKey());
373-
ArrayList<String> menuOptions = this.myBoardTxtFile.getMenuItemIDsFromMenuID(curMenuID.getKey(), getBoardID());
373+
ArrayList<String> menuOptions = this.myBoardTxtFile.getMenuItemIDsFromMenuID(curMenuID.getKey(),
374+
getBoardID());
374375
if (menuOptions.size() > 0) {
375376
if (providedMenuValue == null) {
376377

@@ -853,7 +854,6 @@ public Map<String, String> getEnvVars() {
853854
Programmers localProgrammers[] = Programmers.fromBoards(this);
854855
String programmer = getProgrammer();
855856
for (Programmers curProgrammer : localProgrammers) {
856-
// allVars.putAll(curProgrammer.getAllEnvironVars());
857857
String programmerID = curProgrammer.getIDFromNiceName(programmer);
858858
if (programmerID != null) {
859859
allVars.putAll(curProgrammer.getAllEnvironVars(programmerID));

io.sloeber.core/src/io/sloeber/core/api/Json/library/LibraryIndexJson.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import io.sloeber.core.api.Defaults;
2323
import io.sloeber.core.api.LibraryDescriptor;
24-
import io.sloeber.core.tools.Version;
24+
import io.sloeber.core.api.VersionNumber;
2525

2626
/**
2727
* This class represents a json file that references libraries
@@ -64,7 +64,7 @@ public void resolve(File packageFile) {
6464

6565
LibraryJson current = this.latestLibs.get(name);
6666
if (current != null) {
67-
if (Version.compare(library.getVersion(), current.getVersion()) > 0) {
67+
if (library.getVersion().compareTo(current.getVersion()) > 0) {
6868
this.latestLibs.put(name, library);
6969
}
7070
} else {
@@ -77,7 +77,7 @@ public LibraryJson getLatestLibrary(String name) {
7777
return this.latestLibs.get(name);
7878
}
7979

80-
public LibraryJson getLibrary(String libName, String version) {
80+
public LibraryJson getLibrary(String libName, VersionNumber version) {
8181
for (LibraryJson library : this.libraries) {
8282
if (library.getName().equals(libName) && (library.getVersion().equals(version))) {
8383
return library;

io.sloeber.core/src/io/sloeber/core/api/Json/library/LibraryJson.java

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.google.gson.JsonParseException;
2424

2525
import io.sloeber.core.Activator;
26+
import io.sloeber.core.api.VersionNumber;
2627
import io.sloeber.core.common.Common;
2728
import io.sloeber.core.common.ConfigurationPreferences;
2829
import io.sloeber.core.managers.InternalPackageManager;
@@ -38,7 +39,7 @@
3839
public class LibraryJson implements Comparable<LibraryJson> {
3940

4041
private String name;
41-
private String version;
42+
private VersionNumber version;
4243
private String author;
4344
private String maintainer;
4445
private String sentence;
@@ -58,7 +59,7 @@ public LibraryJson(JsonElement json, LibraryIndexJson libraryIndexJson) {
5859
JsonObject jsonObject = json.getAsJsonObject();
5960
try {
6061
name = getSafeString(jsonObject, "name");
61-
version = getSafeString(jsonObject, "version");
62+
version = getSafeVersion(jsonObject, "version");
6263
author = getSafeString(jsonObject, "author");
6364
maintainer = getSafeString(jsonObject, "maintainer");
6465
sentence = getSafeString(jsonObject, "sentence");
@@ -82,64 +83,64 @@ public LibraryJson(JsonElement json, LibraryIndexJson libraryIndexJson) {
8283
}
8384

8485
public String getName() {
85-
return this.name;
86+
return name;
8687
}
8788

88-
public String getVersion() {
89-
return this.version;
89+
public VersionNumber getVersion() {
90+
return version;
9091
}
9192

9293
public String getAuthor() {
93-
return this.author;
94+
return author;
9495
}
9596

9697
public String getMaintainer() {
97-
return this.maintainer;
98+
return maintainer;
9899
}
99100

100101
public String getSentence() {
101-
return this.sentence;
102+
return sentence;
102103
}
103104

104105
public String getParagraph() {
105-
return this.paragraph;
106+
return paragraph;
106107
}
107108

108109
public String getWebsite() {
109-
return this.website;
110+
return website;
110111
}
111112

112113
public String getCategory() {
113-
return this.category;
114+
return category;
114115
}
115116

116117
public List<String> getArchitectures() {
117-
return this.architectures;
118+
return architectures;
118119
}
119120

120121
public List<String> getTypes() {
121-
return this.types;
122+
return types;
122123
}
123124

124125
public String getUrl() {
125-
return this.url;
126+
return url;
126127
}
127128

128129
public String getArchiveFileName() {
129-
return this.archiveFileName;
130+
return archiveFileName;
130131
}
131132

132133
public int getSize() {
133-
return this.size;
134+
return size;
134135
}
135136

136137
public String getChecksum() {
137-
return this.checksum;
138+
return checksum;
138139
}
139140

140141
public IPath getInstallPath() {
141142
return ConfigurationPreferences.getInstallationPathLibraries().append(this.name.replace(' ', '_'))
142-
.append(this.version);
143+
.append(version.toString());
143144
}
144145

145146
public boolean isInstalled() {

io.sloeber.core/src/io/sloeber/core/api/Json/packages/ArduinoPlatform.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import com.google.gson.JsonParseException;
2727

2828
import io.sloeber.core.Activator;
29+
import io.sloeber.core.api.VersionNumber;
2930
import io.sloeber.core.common.ConfigurationPreferences;
3031
import io.sloeber.core.common.Const;
3132
import io.sloeber.core.managers.InternalPackageManager;
@@ -34,7 +35,7 @@ public class ArduinoPlatform {
3435

3536
private String name;
3637
private String architecture;
37-
private String version;
38+
private VersionNumber version;
3839
private String category;
3940
private String url;
4041
private String archiveFileName;
@@ -55,7 +56,7 @@ public ArduinoPlatform(JsonElement json, Package parent) {
5556
try {
5657
name = getSafeString(jsonObject, "name");
5758
architecture = getSafeString(jsonObject, "architecture");
58-
version = getSafeString(jsonObject, "version");
59+
version = getSafeVersion(jsonObject, "version");
5960
category = getSafeString(jsonObject, "category");
6061
url = getSafeString(jsonObject, "url");
6162
archiveFileName = getSafeString(jsonObject, "archiveFileName");
@@ -83,35 +84,35 @@ public String getName() {
8384
}
8485

8586
public String getArchitecture() {
86-
return this.architecture;
87+
return architecture;
8788
}
8889

89-
public String getVersion() {
90-
return this.version;
90+
public VersionNumber getVersion() {
91+
return version;
9192
}
9293

9394
public String getCategory() {
94-
return this.category;
95+
return category;
9596
}
9697

9798
public String getUrl() {
98-
return this.url;
99+
return url;
99100
}
100101

101102
public String getArchiveFileName() {
102-
return this.archiveFileName;
103+
return archiveFileName;
103104
}
104105

105106
public String getChecksum() {
106-
return this.checksum;
107+
return checksum;
107108
}
108109

109110
public String getSize() {
110-
return this.size;
111+
return size;
111112
}
112113

113114
public List<ToolDependency> getToolsDependencies() {
114-
return this.toolsDependencies;
115+
return toolsDependencies;
115116
}
116117

117118
public boolean isInstalled() {
@@ -128,7 +129,7 @@ public File getPlatformFile() {
128129

129130
public IPath getInstallPath() {
130131
IPath stPath = ConfigurationPreferences.getInstallationPathPackages().append(this.myParent.getName())
131-
.append(Const.ARDUINO_HARDWARE_FOLDER_NAME).append(this.architecture).append(this.version);
132+
.append(Const.ARDUINO_HARDWARE_FOLDER_NAME).append(this.architecture).append(this.version.toString());
132133
return stPath;
133134
}
134135

@@ -138,7 +139,6 @@ public List<IPath> getIncludePath() {
138139
installPath.append(Const.VARIANTS_FOLDER_NAME + "/{build.variant}")); //$NON-NLS-1$
139140
}
140141

141-
@SuppressWarnings("unused")
142142
public IStatus remove(IProgressMonitor monitor) {
143143
// Check if we're installed
144144
if (!isInstalled()) {

io.sloeber.core/src/io/sloeber/core/api/Json/packages/Package.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
import com.google.gson.JsonObject;
2222
import com.google.gson.JsonParseException;
2323

24-
import io.sloeber.core.tools.Version;
25-
2624
public class Package implements Comparable<Package> {
2725

2826
private String name;
@@ -95,7 +93,7 @@ public Collection<ArduinoPlatform> getLatestPlatforms() {
9593
Map<String, ArduinoPlatform> platformMap = new HashMap<>();
9694
for (ArduinoPlatform platform : this.platforms) {
9795
ArduinoPlatform p = platformMap.get(platform.getArchitecture());
98-
if (p == null || Version.compare(platform.getVersion(), p.getVersion()) > 0) {
96+
if (p == null || platform.getVersion().compareTo(p.getVersion()) > 0) {
9997
platformMap.put(platform.getArchitecture(), platform);
10098
}
10199
}
@@ -115,7 +113,7 @@ public Collection<ArduinoPlatform> getLatestInstalledPlatforms() {
115113
for (ArduinoPlatform platform : this.platforms) {
116114
if (platform.isInstalled()) {
117115
ArduinoPlatform p = platformMap.get(platform.getID());
118-
if (p == null || Version.compare(platform.getVersion(), p.getVersion()) > 0) {
116+
if (p == null || platform.getVersion().compareTo(p.getVersion()) > 0) {
119117
platformMap.put(platform.getID(), platform);
120118
}
121119
}
@@ -147,7 +145,7 @@ public ArduinoPlatform getLatestPlatform(String architectureName, boolean mustBe
147145
if (foundPlatform == null) {
148146
foundPlatform = platform;
149147
} else {
150-
if (Version.compare(platform.getVersion(), foundPlatform.getVersion()) > 0) {
148+
if (platform.getVersion().compareTo(foundPlatform.getVersion()) > 0) {
151149
foundPlatform = platform;
152150
}
153151
}
@@ -161,7 +159,7 @@ public ArduinoPlatform getPlatform(String platformName, String version) {
161159

162160
for (ArduinoPlatform platform : this.platforms) {
163161
if (platform.getName().equals(platformName)) {
164-
if (Version.compare(platform.getVersion(), version) == 0) {
162+
if (platform.getVersion().compareTo(version) == 0) {
165163
return platform;
166164
}
167165
}
@@ -186,7 +184,7 @@ public Tool getLatestTool(String toolName) {
186184
Tool latestTool = null;
187185
for (Tool tool : this.tools) {
188186
if (tool.getName().equals(toolName)) {
189-
if (latestTool == null || Version.compare(tool.getVersion(), latestTool.getVersion()) > 0) {
187+
if (latestTool == null || tool.getVersion().compareTo(latestTool.getVersion()) > 0) {
190188
latestTool = tool;
191189
}
192190
}

0 commit comments

Comments
 (0)