Skip to content

Commit cf47e2a

Browse files
committed
Implement Versioned interface where appropriate
1 parent a3fb65c commit cf47e2a

File tree

3 files changed

+35
-24
lines changed

3 files changed

+35
-24
lines changed

src/main/java/org/scijava/Gateway.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
* @author Mark Hiner
117117
* @author Curtis Rueden
118118
*/
119-
public interface Gateway extends RichPlugin {
119+
public interface Gateway extends RichPlugin, Versioned {
120120

121121
/**
122122
* Returns an implementation of the requested {@link Service}, if it exists in
@@ -199,10 +199,13 @@ public interface Gateway extends RichPlugin {
199199
/** @see org.scijava.app.App#getTitle() */
200200
String getTitle();
201201

202-
/** @see org.scijava.app.App#getVersion() */
203-
String getVersion();
204-
205202
/** @see org.scijava.app.App#getInfo(boolean) */
206203
String getInfo(boolean mem);
207204

205+
// -- Versioned methods --
206+
207+
/** @see org.scijava.app.App#getVersion() */
208+
@Override
209+
String getVersion();
210+
208211
}

src/main/java/org/scijava/app/App.java

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
import java.io.File;
3535

36+
import org.scijava.Versioned;
3637
import org.scijava.plugin.Plugin;
3738
import org.scijava.plugin.RichPlugin;
3839
import org.scijava.plugin.SingletonPlugin;
@@ -53,22 +54,11 @@
5354
* @see Plugin
5455
* @see AppService
5556
*/
56-
public interface App extends RichPlugin, SingletonPlugin {
57+
public interface App extends RichPlugin, SingletonPlugin, Versioned {
5758

5859
/** Gets the title of the application. */
5960
String getTitle();
6061

61-
/**
62-
* Gets the version of the application.
63-
* <p>
64-
* SciJava conforms to the <a href="http://semver.org/">Semantic
65-
* Versioning</a> specification.
66-
* </p>
67-
*
68-
* @return The application version, in {@code major.minor.micro} format.
69-
*/
70-
String getVersion();
71-
7262
/** The Maven {@code groupId} of the application. */
7363
String getGroupId();
7464

@@ -106,4 +96,18 @@ public interface App extends RichPlugin, SingletonPlugin {
10696
*/
10797
File getBaseDirectory();
10898

99+
// -- Versioned methods --
100+
101+
/**
102+
* Gets the version of the application.
103+
* <p>
104+
* SciJava conforms to the <a href="http://semver.org/">Semantic
105+
* Versioning</a> specification.
106+
* </p>
107+
*
108+
* @return The application version, in {@code major.minor.micro} format.
109+
*/
110+
@Override
111+
String getVersion();
112+
109113
}

src/main/java/org/scijava/util/POM.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,15 @@
4242

4343
import javax.xml.parsers.ParserConfigurationException;
4444

45+
import org.scijava.Versioned;
4546
import org.xml.sax.SAXException;
4647

4748
/**
4849
* Helper class for working with Maven POMs.
4950
*
5051
* @author Curtis Rueden
5152
*/
52-
public class POM extends XML implements Comparable<POM> {
53+
public class POM extends XML implements Comparable<POM>, Versioned {
5354

5455
/** Parses a POM from the given file. */
5556
public POM(final File file) throws ParserConfigurationException,
@@ -93,13 +94,6 @@ public String getArtifactId() {
9394
return cdata("//project/artifactId");
9495
}
9596

96-
/** Gets the POM's version. */
97-
public String getVersion() {
98-
final String version = cdata("//project/version");
99-
if (version != null) return version;
100-
return cdata("//project/parent/version");
101-
}
102-
10397
/** Gets the project name. */
10498
public String getProjectName() {
10599
return cdata("//project/name");
@@ -146,6 +140,16 @@ public int compareTo(final POM pom) {
146140
return compareVersions(getVersion(), pom.getVersion());
147141
}
148142

143+
// -- Versioned methods --
144+
145+
/** Gets the POM's version. */
146+
@Override
147+
public String getVersion() {
148+
final String version = cdata("//project/version");
149+
if (version != null) return version;
150+
return cdata("//project/parent/version");
151+
}
152+
149153
// -- Utility methods --
150154

151155
/**

0 commit comments

Comments
 (0)