Skip to content

Commit

Permalink
Use new Immutables Jakarta style to generate jakarta annotations
Browse files Browse the repository at this point in the history
* Add jakarta.annotation-api as a compile-scope dependency, since the
  generated classes will contain jakarta annotations
* Add the "jakarta = true" style to all the classes using Immutables
* Note that Value and TxResponse (which uses Value) must import
  org.immutables.value.Value.Immutable and org.immutables.value.Value.Style
  because otherwise, they conflict with org.kiwiproject.consul.model.kv.Value.
  All other model classes import org.immutables.value.Value and then
  use the annotations as Value.Immutable and Value.Style. I retained this
  semantic, which was how these classes were originally defined well
  before we forked this project.

Closes #283
  • Loading branch information
sleberknight committed Oct 11, 2023
1 parent 9f9a8d4 commit 0049dbf
Show file tree
Hide file tree
Showing 68 changed files with 105 additions and 31 deletions.
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@
<scope>provided</scope>
</dependency>

<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
</dependency>

<!-- Test dependencies -->

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* Provides a unique key for a {@link ServiceHealth} entry in a {@link ServiceHealthCache}
*/
@Value.Immutable
@Value.Style(jakarta = true)
@JsonIgnoreProperties(ignoreUnknown = true)
public abstract class ServiceHealthKey {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.List;

@Value.Immutable
@Value.Style(jakarta = true)
@JsonSerialize(as = ImmutableEventResponse.class)
@JsonDeserialize(as = ImmutableEventResponse.class)
public abstract class EventResponse {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@


@Value.Immutable
@Value.Style(jakarta = true)
@JsonSerialize(as = ImmutableAclResponse.class)
@JsonDeserialize(as = ImmutableAclResponse.class)
@JsonIgnoreProperties(ignoreUnknown = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.Optional;

@Value.Immutable
@Value.Style(jakarta = true)
@JsonSerialize(as = ImmutableAclToken.class)
@JsonDeserialize(as = ImmutableAclToken.class)
@JsonIgnoreProperties(ignoreUnknown = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.immutables.value.Value;

@Value.Immutable
@Value.Style(jakarta = true)
@JsonSerialize(as = ImmutableAclTokenId.class)
@JsonDeserialize(as = ImmutableAclTokenId.class)
@JsonIgnoreProperties(ignoreUnknown = true)
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/kiwiproject/consul/model/acl/Policy.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.Optional;

@Value.Immutable
@Value.Style(jakarta = true)
@JsonSerialize(as = ImmutablePolicy.class)
@JsonDeserialize(as = ImmutablePolicy.class)
@JsonIgnoreProperties(ignoreUnknown = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@


@Value.Immutable
@Value.Style(jakarta = true)
@JsonSerialize(as = ImmutablePolicyListResponse.class)
@JsonDeserialize(as = ImmutablePolicyListResponse.class)
@JsonIgnoreProperties(ignoreUnknown = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@


@Value.Immutable
@Value.Style(jakarta = true)
@JsonSerialize(as = ImmutablePolicyResponse.class)
@JsonDeserialize(as = ImmutablePolicyResponse.class)
@JsonIgnoreProperties(ignoreUnknown = true)
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/kiwiproject/consul/model/acl/Role.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.util.Optional;

@Value.Immutable
@Value.Style(jakarta = true)
@JsonSerialize(as = ImmutableRole.class)
@JsonDeserialize(as = ImmutableRole.class)
@JsonIgnoreProperties(ignoreUnknown = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.immutables.value.Value;

@Value.Immutable
@Value.Style(jakarta = true)
@JsonSerialize(as = ImmutableRoleListResponse.class)
@JsonDeserialize(as = ImmutableRoleListResponse.class)
@JsonIgnoreProperties(ignoreUnknown = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@


@Value.Immutable
@Value.Style(jakarta = true)
@JsonSerialize(as = ImmutableRoleResponse.class)
@JsonDeserialize(as = ImmutableRoleResponse.class)
@JsonIgnoreProperties(ignoreUnknown = true)
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/kiwiproject/consul/model/acl/Token.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.util.Optional;

@Value.Immutable
@Value.Style(jakarta = true)
@JsonSerialize(as = ImmutableToken.class)
@JsonDeserialize(as = ImmutableToken.class)
@JsonIgnoreProperties(ignoreUnknown = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.immutables.value.Value;

@Value.Immutable
@Value.Style(jakarta = true)
@JsonSerialize(as = ImmutableTokenListResponse.class)
@JsonDeserialize(as = ImmutableTokenListResponse.class)
@JsonIgnoreProperties(ignoreUnknown = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.immutables.value.Value;

@Value.Immutable
@Value.Style(jakarta = true)
@JsonSerialize(as = ImmutableTokenResponse.class)
@JsonDeserialize(as = ImmutableTokenResponse.class)
@JsonIgnoreProperties(ignoreUnknown = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.Map;

@Value.Immutable
@Value.Style(jakarta = true)
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonSerialize(as = ImmutableAgent.class)
@JsonDeserialize(as = ImmutableAgent.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.util.Optional;

@Value.Immutable
@Value.Style(jakarta = true)
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonSerialize(as = ImmutableCheck.class)
@JsonDeserialize(as = ImmutableCheck.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.immutables.value.Value;

@Value.Immutable
@Value.Style(jakarta = true)
@JsonSerialize(as = ImmutableConfig.class)
@JsonDeserialize(as = ImmutableConfig.class)
@JsonIgnoreProperties(ignoreUnknown = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.util.Optional;

@Value.Immutable
@Value.Style(jakarta = true)
@JsonSerialize(as = ImmutableFullService.class)
@JsonDeserialize(as = ImmutableFullService.class)
@JsonIgnoreProperties(ignoreUnknown = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.Map;

@Value.Immutable
@Value.Style(jakarta = true)
@JsonSerialize(as = ImmutableMember.class)
@JsonDeserialize(as = ImmutableMember.class)
@JsonIgnoreProperties(ignoreUnknown = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.immutables.value.Value;

@Value.Immutable
@Value.Style(jakarta = true)
@JsonSerialize(as = ImmutablePorts.class)
@JsonDeserialize(as = ImmutablePorts.class)
@JsonIgnoreProperties(ignoreUnknown = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@


@Value.Immutable
@Value.Style(jakarta = true)
@JsonSerialize(as = ImmutableRegistration.class)
@JsonDeserialize(as = ImmutableRegistration.class)
@JsonIgnoreProperties(ignoreUnknown = true)
Expand Down Expand Up @@ -87,7 +88,7 @@ public abstract static class RegCheck {

@JsonProperty("Timeout")
public abstract Optional<String> getTimeout();

@JsonProperty("Notes")
public abstract Optional<String> getNotes();

Expand Down Expand Up @@ -129,7 +130,7 @@ public static RegCheck args(List<String> args, long interval, long timeout) {
.timeout(String.format("%ss", timeout))
.build();
}

public static RegCheck args(List<String> args, long interval, long timeout, String notes) {
return ImmutableRegCheck
.builder()
Expand All @@ -156,7 +157,7 @@ public static RegCheck http(String http, long interval, long timeout) {
.timeout(String.format("%ss", timeout))
.build();
}

public static RegCheck http(String http, long interval, long timeout, String notes) {
return ImmutableRegCheck
.builder()
Expand All @@ -183,7 +184,7 @@ public static RegCheck tcp(String tcp, long interval, long timeout) {
.timeout(String.format("%ss", timeout))
.build();
}

public static RegCheck tcp(String tcp, long interval, long timeout, String notes) {
return ImmutableRegCheck
.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.Map;

@Value.Immutable
@Value.Style(jakarta = true)
@JsonSerialize(as = ImmutableServiceProxy.class)
@JsonDeserialize(as = ImmutableServiceProxy.class)
@JsonIgnoreProperties(ignoreUnknown = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.immutables.value.Value;

@Value.Immutable
@Value.Style(jakarta = true)
@JsonSerialize(as = ImmutableServiceProxyUpstream.class)
@JsonDeserialize(as = ImmutableServiceProxyUpstream.class)
@JsonIgnoreProperties(ignoreUnknown = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@


@Value.Immutable
@Value.Style(jakarta = true)
@JsonSerialize(as = ImmutableTelemetry.class)
@JsonDeserialize(as = ImmutableTelemetry.class)
@JsonIgnoreProperties(ignoreUnknown = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.Optional;

@Value.Immutable
@Value.Style(jakarta = true)
@JsonSerialize(as = ImmutableCatalogDeregistration.class)
@JsonDeserialize(as = ImmutableCatalogDeregistration.class)
@JsonIgnoreProperties(ignoreUnknown = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.Map;

@Value.Immutable
@Value.Style(jakarta = true)
@JsonSerialize(as = ImmutableCatalogNode.class)
@JsonDeserialize(as = ImmutableCatalogNode.class)
@JsonIgnoreProperties(ignoreUnknown = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.util.Optional;

@Value.Immutable
@Value.Style(jakarta = true)
@JsonSerialize(as = ImmutableCatalogRegistration.class)
@JsonDeserialize(as = ImmutableCatalogRegistration.class)
@JsonIgnoreProperties(ignoreUnknown = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.Optional;

@Value.Immutable
@Value.Style(jakarta = true)
@JsonSerialize(as = ImmutableCatalogService.class)
@JsonDeserialize(as = ImmutableCatalogService.class)
@JsonIgnoreProperties(ignoreUnknown = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.immutables.value.Value;

@Value.Immutable
@Value.Style(jakarta = true)
@JsonSerialize(as = ImmutableServiceWeights.class)
@JsonDeserialize(as = ImmutableServiceWeights.class)
@JsonIgnoreProperties(ignoreUnknown = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.Optional;

@Value.Immutable
@Value.Style(jakarta = true)
@JsonSerialize(as = ImmutableTaggedAddresses.class)
@JsonDeserialize(as = ImmutableTaggedAddresses.class)
@JsonIgnoreProperties(ignoreUnknown = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.immutables.value.Value;

@Value.Immutable
@Value.Style(jakarta = true)
@JsonSerialize(as = ImmutableWriteRequest.class)
@JsonDeserialize(as = ImmutableWriteRequest.class)
@JsonIgnoreProperties(ignoreUnknown = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.immutables.value.Value;

@Value.Immutable
@Value.Style(jakarta = true)
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonSerialize(as = ImmutableCoord.class)
@JsonDeserialize(as = ImmutableCoord.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.immutables.value.Value;

@Value.Immutable
@Value.Style(jakarta = true)
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonSerialize(as = ImmutableCoordinate.class)
@JsonDeserialize(as = ImmutableCoordinate.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.List;

@Value.Immutable
@Value.Style(jakarta = true)
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonSerialize(as = ImmutableDatacenter.class)
@JsonDeserialize(as = ImmutableDatacenter.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.Optional;

@Value.Immutable
@Value.Style(jakarta = true)
@JsonSerialize(as = ImmutableEvent.class)
@JsonDeserialize(as = ImmutableEvent.class)
public abstract class Event {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.Optional;

@Value.Immutable
@Value.Style(jakarta = true)
@JsonSerialize(as = ImmutableHealthCheck.class)
@JsonDeserialize(as = ImmutableHealthCheck.class)
@JsonIgnoreProperties(ignoreUnknown = true)
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/kiwiproject/consul/model/health/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.Optional;

@Value.Immutable
@Value.Style(jakarta = true)
@JsonSerialize(as = ImmutableNode.class)
@JsonDeserialize(as = ImmutableNode.class)
@JsonIgnoreProperties(ignoreUnknown = true)
Expand All @@ -21,7 +22,7 @@ public abstract class Node {

@JsonProperty("Address")
public abstract String getAddress();

@JsonProperty("Datacenter")
public abstract Optional<String> getDatacenter();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.util.Optional;

@Value.Immutable
@Value.Style(jakarta = true)
@JsonSerialize(as = ImmutableService.class)
@JsonDeserialize(as = ImmutableService.class)
@JsonIgnoreProperties(ignoreUnknown = true)
Expand All @@ -30,7 +31,7 @@ public abstract class Service {
@JsonProperty("Tags")
@JsonDeserialize(as = ImmutableList.class, contentAs = String.class)
public abstract List<String> getTags();

@JsonProperty("Address")
public abstract String getAddress();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.List;

@Value.Immutable
@Value.Style(jakarta = true)
@JsonSerialize(as = ImmutableServiceCheck.class)
@JsonDeserialize(as = ImmutableServiceCheck.class)
@JsonIgnoreProperties(ignoreUnknown = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import java.util.List;
@Value.Immutable
@Value.Style(jakarta = true)
@JsonSerialize(as = ImmutableServiceHealth.class)
@JsonDeserialize(as = ImmutableServiceHealth.class)
@JsonIgnoreProperties(ignoreUnknown = true)
Expand All @@ -23,5 +24,5 @@ public abstract class ServiceHealth {
@JsonProperty("Checks")
@JsonDeserialize(as = ImmutableList.class, contentAs = HealthCheck.class)
public abstract List<HealthCheck> getChecks();

}
Loading

0 comments on commit 0049dbf

Please sign in to comment.