Skip to content

Commit

Permalink
Increment version to 2.0.6, refactor version constants to NakshaVersion.
Browse files Browse the repository at this point in the history
  • Loading branch information
xeus2001 committed Jul 13, 2023
1 parent db6a9b6 commit cf18ad7
Show file tree
Hide file tree
Showing 44 changed files with 314 additions and 265 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ mavenPassword=YourPassword
# When updating the version, please as well consider:
# - here-naksha-lib-core/INaksha (static property: latest)
# - here-naksha-lib-psql/resources/naksha_ext.sql (method: naksha_version)
version=2.0.5
version=2.0.6
Original file line number Diff line number Diff line change
Expand Up @@ -78,25 +78,10 @@ final class AdminCollections {
public static final CollectionInfo EXTENSIONS = new CollectionInfo("naksha:extensions", 0L);
}

/**
* Naksha version constant. The last version compatible with XYZ-Hub.
*/
String v0_6 = "0.6.0";

String v2_0_0 = "2.0.0";
String v2_0_3 = "2.0.3";
String v2_0_4 = "2.0.4";
String v2_0_5 = "2.0.5";

/**
* The latest version of the naksha-extension stored in the resources.
*/
NakshaVersion latest = NakshaVersion.of(v2_0_5);

/**
* The reference to the Naksha implementation provided by the host. Rather use the {@link #get()} method to get the instance.
*/
@AvailableSince(v2_0_0)
@AvailableSince(NakshaVersion.v2_0_0)
AtomicReference<@Nullable INaksha> instance = new AtomicReference<>();

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
*/
package com.here.naksha.lib.core;

import static com.here.naksha.lib.core.NakshaVersion.v2_0_3;

import org.jetbrains.annotations.ApiStatus.AvailableSince;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand All @@ -28,15 +31,32 @@
* @param minor the minor version (0-65535).
* @param revision the revision (0-65535).
*/
@AvailableSince(v2_0_3)
public record NakshaVersion(int major, int minor, int revision) implements Comparable<NakshaVersion> {

/**
* Naksha version constant. The last version compatible with XYZ-Hub.
*/
public static final String v0_6 = "0.6.0";
public static final String v2_0_0 = "2.0.0";
public static final String v2_0_3 = "2.0.3";
public static final String v2_0_4 = "2.0.4";
public static final String v2_0_5 = "2.0.5";
public static final String v2_0_6 = "2.0.6";

/**
* The latest version of the naksha-extension stored in the resources.
*/
public static final NakshaVersion latest = of(v2_0_6);

/**
* Parses the given version string and returns the Naksha version.
*
* @param version the version like "2.0.3".
* @return the Naksha version.
* @throws NumberFormatException if the given string is no valid version.
*/
@AvailableSince(v2_0_3)
public static @NotNull NakshaVersion of(@NotNull String version) throws NumberFormatException {
final int majorEnd = version.indexOf('.');
final int minorEnd = version.indexOf('.', majorEnd + 1);
Expand All @@ -46,10 +66,12 @@ public record NakshaVersion(int major, int minor, int revision) implements Compa
Integer.parseInt(version.substring(minorEnd + 1)));
}

@AvailableSince(v2_0_3)
public NakshaVersion(long value) {
this((int) ((value >>> 32) & 0xffff), (int) ((value >>> 16) & 0xffff), (int) (value & 0xffff));
}

@AvailableSince(v2_0_3)
public long toLong() {
return ((major & 0xffffL) << 32) | ((minor & 0xffffL) << 16) | (revision & 0xffffL);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.here.naksha.lib.core.IEventContext;
import com.here.naksha.lib.core.IEventHandler;
import com.here.naksha.lib.core.INaksha;
import com.here.naksha.lib.core.NakshaVersion;
import com.here.naksha.lib.core.exceptions.XyzErrorException;
import com.here.naksha.lib.core.extension.messages.ExtensionMessage;
import com.here.naksha.lib.core.extension.messages.ProcessEventMsg;
Expand All @@ -42,7 +43,7 @@
/**
* A special proxy-handler that is internally used to forward events to a handler running in lib-extension component.
*/
@AvailableSince(INaksha.v2_0_3)
@AvailableSince(NakshaVersion.v2_0_3)
public class ExtensionHandler implements IEventHandler {
// extension: 1234
// className: com.here.dcu.ValidationHandler <-- IEventHandler
Expand All @@ -52,7 +53,7 @@ public class ExtensionHandler implements IEventHandler {
*
* @param connector the connector that must have a valid extension number.
*/
@AvailableSince(INaksha.v2_0_3)
@AvailableSince(NakshaVersion.v2_0_3)
public ExtensionHandler(@NotNull Connector connector) {
final Extension config = INaksha.get().getExtension(connector.getExtension());
if (config == null) {
Expand All @@ -68,7 +69,7 @@ public ExtensionHandler(@NotNull Connector connector) {
* @param connector the connector that must have a valid extension number.
* @param config the configuration to use.
*/
@AvailableSince(INaksha.v2_0_3)
@AvailableSince(NakshaVersion.v2_0_3)
public ExtensionHandler(@NotNull Connector connector, @NotNull Extension config) {
this.connector = connector;
this.config = config;
Expand All @@ -77,7 +78,7 @@ public ExtensionHandler(@NotNull Connector connector, @NotNull Extension config)
private final @NotNull Extension config;
private final @NotNull Connector connector;

@AvailableSince(INaksha.v2_0_3)
@AvailableSince(NakshaVersion.v2_0_3)
@Override
public @NotNull XyzResponse processEvent(@NotNull IEventContext eventContext) throws XyzErrorException {
final Event event = eventContext.getEvent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
package com.here.naksha.lib.core.extension.messages;

import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.here.naksha.lib.core.INaksha;
import com.here.naksha.lib.core.NakshaVersion;
import com.here.naksha.lib.core.models.Typed;
import com.here.naksha.lib.core.util.json.JsonObject;
import org.jetbrains.annotations.ApiStatus.AvailableSince;

/**
* Base class of all Naksha extension protocol messages.
*/
@AvailableSince(INaksha.v2_0_3)
@AvailableSince(NakshaVersion.v2_0_3)
@JsonSubTypes({
@JsonSubTypes.Type(value = ProcessEventMsg.class),
@JsonSubTypes.Type(value = ResponseMsg.class),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.here.naksha.lib.core.INaksha;
import com.here.naksha.lib.core.NakshaVersion;
import com.here.naksha.lib.core.models.features.Connector;
import com.here.naksha.lib.core.models.payload.Event;
import org.jetbrains.annotations.ApiStatus.AvailableSince;
Expand All @@ -30,29 +30,29 @@
/**
* Send from Naksha, when the extension should process an event.
*/
@AvailableSince(INaksha.v2_0_3)
@AvailableSince(NakshaVersion.v2_0_3)
@JsonTypeName(value = "naksha.ext.rpc.v1.processEvent")
public class ProcessEventMsg extends ExtensionMessage {

@AvailableSince(INaksha.v2_0_3)
@AvailableSince(NakshaVersion.v2_0_3)
public static final String CONNECTOR = "connector";

@AvailableSince(INaksha.v2_0_3)
@AvailableSince(NakshaVersion.v2_0_3)
public static final String EVENT = "event";

@JsonCreator
@AvailableSince(INaksha.v2_0_3)
@AvailableSince(NakshaVersion.v2_0_3)
public ProcessEventMsg(
@JsonProperty(CONNECTOR) @NotNull Connector connector, @JsonProperty(EVENT) @NotNull Event event) {
this.connector = connector;
this.event = event;
}

@AvailableSince(INaksha.v2_0_3)
@AvailableSince(NakshaVersion.v2_0_3)
@JsonProperty(CONNECTOR)
public final @NotNull Connector connector;

@AvailableSince(INaksha.v2_0_3)
@AvailableSince(NakshaVersion.v2_0_3)
@JsonProperty(EVENT)
public final @NotNull Event event;
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.here.naksha.lib.core.INaksha;
import com.here.naksha.lib.core.NakshaVersion;
import com.here.naksha.lib.core.models.payload.XyzResponse;
import org.jetbrains.annotations.ApiStatus.AvailableSince;
import org.jetbrains.annotations.NotNull;
Expand All @@ -30,13 +30,13 @@
* Send by the extension to Naksha-Hub, when an extension is done with processing an event. Send as well by Naksha-Hub as response to a
* {@link SendUpstreamMsg}.
*/
@AvailableSince(INaksha.v2_0_3)
@AvailableSince(NakshaVersion.v2_0_3)
@JsonTypeName(value = "naksha.ext.rpc.v1.returnResponse")
public class ResponseMsg extends ExtensionMessage {

public static final String RESPONSE = "response";

@AvailableSince(INaksha.v2_0_3)
@AvailableSince(NakshaVersion.v2_0_3)
@JsonCreator
public ResponseMsg(@JsonProperty(RESPONSE) @NotNull XyzResponse response) {
this.response = response;
Expand All @@ -45,7 +45,7 @@ public ResponseMsg(@JsonProperty(RESPONSE) @NotNull XyzResponse response) {
/**
* The response to return.
*/
@AvailableSince(INaksha.v2_0_3)
@AvailableSince(NakshaVersion.v2_0_3)
@JsonProperty(RESPONSE)
public final @NotNull XyzResponse response;
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.here.naksha.lib.core.INaksha;
import com.here.naksha.lib.core.NakshaVersion;
import com.here.naksha.lib.core.models.payload.Event;
import com.here.naksha.lib.core.models.payload.XyzResponse;
import org.jetbrains.annotations.ApiStatus.AvailableSince;
Expand All @@ -30,7 +30,7 @@
* Send by the extension when Naksha should forward an event through the event-pipeline. Naksha will respond with a
* {@link ResponseMsg response message} holding the {@link XyzResponse}.
*/
@AvailableSince(INaksha.v2_0_3)
@AvailableSince(NakshaVersion.v2_0_3)
@JsonTypeName(value = "naksha.ext.rpc.v1.sendUpdate")
public class SendUpstreamMsg extends ExtensionMessage {

Expand All @@ -40,7 +40,7 @@ public SendUpstreamMsg(@JsonProperty(EVENT) @NotNull Event event) {
this.event = event;
}

@AvailableSince(INaksha.v2_0_3)
@AvailableSince(NakshaVersion.v2_0_3)
@JsonProperty(EVENT)
public final @NotNull Event event;
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.here.naksha.lib.core.INaksha;
import com.here.naksha.lib.core.NakshaVersion;
import com.here.naksha.lib.core.models.geojson.implementation.XyzFeature;
import java.util.ArrayList;
import java.util.Collections;
Expand All @@ -34,10 +34,10 @@
* component is a component, that acts on events send through an event-pipeline.
*/
@SuppressWarnings("unused")
@AvailableSince(INaksha.v2_0_0)
@AvailableSince(NakshaVersion.v2_0_0)
public abstract class PipelineComponent extends XyzFeature {

@AvailableSince(INaksha.v2_0_0)
@AvailableSince(NakshaVersion.v2_0_0)
public static final String EVENT_HANDLERS = "eventHandlers";

/**
Expand All @@ -46,7 +46,7 @@ public abstract class PipelineComponent extends XyzFeature {
* @param id the identifier of this component.
* @param eventHandlers the list of event handler identifiers to form the event-pipeline.
*/
@AvailableSince(INaksha.v2_0_0)
@AvailableSince(NakshaVersion.v2_0_0)
public PipelineComponent(@NotNull String id, @NotNull List<@NotNull String> eventHandlers) {
super(id);
this.eventHandlers = eventHandlers;
Expand All @@ -60,7 +60,7 @@ public PipelineComponent(@NotNull String id, @NotNull List<@NotNull String> even
* event-pipeline.
* @param packages the packages this feature is part of.
*/
@AvailableSince(INaksha.v2_0_0)
@AvailableSince(NakshaVersion.v2_0_0)
public PipelineComponent(
@NotNull String id,
@NotNull List<@NotNull String> eventHandlers,
Expand All @@ -71,7 +71,7 @@ public PipelineComponent(
}

/** The list of event-handler identifiers to be added to the event pipeline, in order. */
@AvailableSince(INaksha.v2_0_0)
@AvailableSince(NakshaVersion.v2_0_0)
@JsonProperty(EVENT_HANDLERS)
public @NotNull List<@NotNull String> eventHandlers;

Expand All @@ -80,7 +80,7 @@ public PipelineComponent(
*
* @return all event-handler identifiers.
*/
@AvailableSince(INaksha.v2_0_0)
@AvailableSince(NakshaVersion.v2_0_0)
@JsonIgnore
public @NotNull List<@NotNull String> getEventHandlers() {
return eventHandlers;
Expand All @@ -91,7 +91,7 @@ public PipelineComponent(
*
* @param eventHandlers the event-handler identifiers.
*/
@AvailableSince(INaksha.v2_0_0)
@AvailableSince(NakshaVersion.v2_0_0)
public void setEventHandlers(@NotNull List<@NotNull String> eventHandlers) {
this.eventHandlers = eventHandlers;
}
Expand All @@ -101,7 +101,7 @@ public void setEventHandlers(@NotNull List<@NotNull String> eventHandlers) {
*
* @param eventHandlerIds the new event-handler identifiers.
*/
@AvailableSince(INaksha.v2_0_0)
@AvailableSince(NakshaVersion.v2_0_0)
public void setEventHandlerIds(@NotNull String... eventHandlerIds) {
this.eventHandlers = new ArrayList<>(eventHandlerIds.length);
Collections.addAll(this.eventHandlers, eventHandlerIds);
Expand Down
Loading

0 comments on commit cf18ad7

Please sign in to comment.