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
8 changes: 8 additions & 0 deletions server/src/main/java/org/elasticsearch/TransportVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ public static TransportVersion fromString(String str) {
return TransportVersion.fromId(Integer.parseInt(str));
}

/**
* Returns a string representing the Elasticsearch release version of this transport version,
* if applicable for this deployment, otherwise the raw version number.
*/
public String toReleaseVersion() {
return TransportVersions.VERSION_LOOKUP.apply(id);
}

@Override
public String toString() {
return Integer.toString(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,7 @@ static Collection<TransportVersion> getAllVersions() {
return VERSION_IDS.values();
}

private static final IntFunction<String> VERSION_LOOKUP = ReleaseVersions.generateVersionsLookup(TransportVersions.class);

public static String toReleaseVersion(TransportVersion version) {
return VERSION_LOOKUP.apply(version.id());
}
static final IntFunction<String> VERSION_LOOKUP = ReleaseVersions.generateVersionsLookup(TransportVersions.class);

// no instance
private TransportVersions() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,14 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
return builder.value(id);
}

/**
* Returns a string representing the Elasticsearch release version of this index version,
* if applicable for this deployment, otherwise the raw version number.
*/
public String toReleaseVersion() {
return IndexVersions.VERSION_LOOKUP.apply(id);
}

@Override
public String toString() {
return Integer.toString(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,8 @@ static Collection<IndexVersion> getAllVersions() {
return VERSION_IDS.values();
}

private static final IntFunction<String> VERSION_LOOKUP = ReleaseVersions.generateVersionsLookup(IndexVersions.class);
static final IntFunction<String> VERSION_LOOKUP = ReleaseVersions.generateVersionsLookup(IndexVersions.class);

public static String toReleaseVersion(IndexVersion version) {
return VERSION_LOOKUP.apply(version.id());
}
// no instance
private IndexVersions() {}
}