Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions jmsfx-core/src/main/java/io/github/ctgnz/jmsfx/IconLibrary.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,19 @@ static IconLibrary discover() {
return IconLibraries.discover();
}

/**
* Which library this is - {@code Standard}, {@code Hallux}, {@code BattleOrder}.
* <p>
* An application built against jmsfx-core names no library and discovers whichever one is on its classpath, so without this it cannot report what it is running, and a
* deployment cannot be checked from outside beyond inferring it from which symbol sets appear. That is answerable while there is one library and awkward once there are three,
* each deployed to its own subdomain. See jmsfx#111.
* <p>
* Deliberately not {@code getVersion()}: {@link #getVersions()} already means something else here - an APP-6 edition, SIDC positions 1-2 - and two methods a character apart
* meaning different things is a trap. The library's own artifact version is a separate question, and one the generated source cannot answer, since it has no idea what version
* it will be published as.
*/
String getName();

ObservableList<Amplifier> getAmplifiers();

ObservableList<SectorOneModifier> getCommonSectorOneModifiers();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,12 @@ public String getLabel() {
* {@code IconLibrary} implementations' documented behaviour of never returning null.
*/
static class FakeIconLibrary implements IconLibrary {

@Override
public String getName() {
return "Fake";
}

private StandardAmplifierItem defaultAmplifier = unknownAmplifier();
private Context defaultContext = realityContext();
private Entity defaultEntity = entity("00", "Unspecified");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ public class DynamicIconLibrary implements IconLibrary {
public DynamicIconLibrary() {
}

/**
* Not a generated library, so it has no prefix of its own. It is whatever model the editor currently holds, which is the honest answer and stops it being mistaken for one of
* the published libraries if it ever reaches something that reports a name.
*/
@Override
public String getName() {
return "Dynamic";
}

@SuppressWarnings("this-escape")
public DynamicIconLibrary(IconLibrary staticLibrary) {
this.versions.setAll(Lists.transform(Lists.newArrayList(staticLibrary.getVersions()), VersionImpl::new));
Expand Down
6 changes: 6 additions & 0 deletions jmsfx-generator/src/main/resources/templates/IconLibrary.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ public class ${libraryPrefix}IconLibrary implements IconLibrary {
public ${libraryPrefix}IconLibrary() {
}

/** The library prefix this was generated with, which is what names the class too. */
@Override
public String getName() {
return "${libraryPrefix}";
}

@Override
public ObservableList<Amplifier> getAmplifiers() {
return FXCollections.observableArrayList(AmplifierEnum.values());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ public static HalluxIconLibrary instance() {
public HalluxIconLibrary() {
}

/** The library prefix this was generated with, which is what names the class too. */
@Override
public String getName() {
return "Hallux";
}

@Override
public ObservableList<Amplifier> getAmplifiers() {
return FXCollections.observableArrayList(AmplifierEnum.values());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
@RequestMapping("/info")
public class IconGeneratorController {

/** Which library this instance is running. See jmsfx#111. */
@GetMapping("/library")
public LibrarySummary getLibrary() {
return LibrarySummary.of(IconLibrary.discover());
}

/** The symbol sets of whichever library is on the classpath, each carrying the path segment the icon API is reached at. */
@GetMapping("/symbols")
public List<SymbolSetSummary> getSupportedSymbolSets() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package io.github.ctgnz.jmsfx.server.icon;

import io.github.ctgnz.jmsfx.IconLibrary;

/**
* What this instance can say about itself: which symbology library it discovered, and how many symbol sets that library offers.
* <p>
* Since jmsfx#93 the server names no library and runs against whichever one is on its classpath, so the answer is not a property of the build anyone can read off. With an instance
* per library planned, each on its own subdomain, "which library is this one running" needs to be answerable from outside rather than inferred from which symbol sets happen to
* appear in a listing. See jmsfx#111.
*/
public record LibrarySummary(String name, int symbolSets) {

public static LibrarySummary of(IconLibrary library) {
return new LibrarySummary(library.getName(), library.getSymbolSets()
.size());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ public static StandardIconLibrary instance() {
public StandardIconLibrary() {
}

/** The library prefix this was generated with, which is what names the class too. */
@Override
public String getName() {
return "Standard";
}

@Override
public ObservableList<Amplifier> getAmplifiers() {
return FXCollections.observableArrayList(AmplifierEnum.values());
Expand Down
Loading