Skip to content

Commit

Permalink
refactor(greengrass): add with-ers and remove the return from setters…
Browse files Browse the repository at this point in the history
… which broke compatibility (#223)

In release 1.6.0, we updated the Greengrass data model setters so that they return `this` so that calls could be chained. Unfortunately this broke binary compatibility which is necessary for Greengrass to maintain backward compatibility. This change should be released as version 1.7.0; it is compatible with versions <1.6.0. Users who are using >=1.6.0, will be able to upgrade to this version if they are not using the return value from the setters. They can also simply swap the calls to setX with a call to withX.
  • Loading branch information
MikeDombo authored Mar 1, 2022
1 parent 6b711b1 commit 806162c
Show file tree
Hide file tree
Showing 69 changed files with 686 additions and 152 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,12 @@ public byte[] getMessage() {
return null;
}

public BinaryMessage setMessage(final byte[] message) {
public void setMessage(final byte[] message) {
this.message = Optional.ofNullable(message);
}

public BinaryMessage withMessage(final byte[] message) {
setMessage(message);
return this;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package software.amazon.awssdk.aws.greengrass.model;

import com.google.gson.annotations.Expose;
import java.lang.Object;
import java.lang.Override;
import java.lang.String;
import software.amazon.awssdk.eventstreamrpc.model.EventStreamJsonMessage;

import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import software.amazon.awssdk.eventstreamrpc.model.EventStreamJsonMessage;

public class ComponentDetails implements EventStreamJsonMessage {
public static final String APPLICATION_MODEL_TYPE = "aws.greengrass#ComponentDetails";
Expand Down Expand Up @@ -61,8 +59,12 @@ public String getComponentName() {
return null;
}

public ComponentDetails setComponentName(final String componentName) {
public void setComponentName(final String componentName) {
this.componentName = Optional.ofNullable(componentName);
}

public ComponentDetails withComponentName(final String componentName) {
setComponentName(componentName);
return this;
}

Expand All @@ -73,8 +75,12 @@ public String getVersion() {
return null;
}

public ComponentDetails setVersion(final String version) {
public void setVersion(final String version) {
this.version = Optional.ofNullable(version);
}

public ComponentDetails withVersion(final String version) {
setVersion(version);
return this;
}

Expand All @@ -92,12 +98,21 @@ public String getStateAsString() {
return null;
}

public void setState(final String state) {
this.state = Optional.ofNullable(state);
}

public ComponentDetails withState(final String state) {
setState(state);
return this;
}

public void setState(final LifecycleState state) {
this.state = Optional.ofNullable(state.getValue());
}

public ComponentDetails setState(final String state) {
this.state = Optional.ofNullable(state);
public ComponentDetails withState(final LifecycleState state) {
setState(state);
return this;
}

Expand All @@ -108,8 +123,12 @@ public Map<String, Object> getConfiguration() {
return null;
}

public ComponentDetails setConfiguration(final Map<String, Object> configuration) {
public void setConfiguration(final Map<String, Object> configuration) {
this.configuration = Optional.ofNullable(configuration);
}

public ComponentDetails withConfiguration(final Map<String, Object> configuration) {
setConfiguration(configuration);
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,12 @@ public String getMessage() {
return null;
}

public ComponentNotFoundError setMessage(final String message) {
public void setMessage(final String message) {
this.message = Optional.ofNullable(message);
}

public ComponentNotFoundError withMessage(final String message) {
setMessage(message);
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,17 @@ public PreComponentUpdateEvent getPreUpdateEvent() {
return null;
}

public ComponentUpdatePolicyEvents setPreUpdateEvent(
final PreComponentUpdateEvent preUpdateEvent) {
public void setPreUpdateEvent(final PreComponentUpdateEvent preUpdateEvent) {
if (setUnionMember != null) {
setUnionMember.nullify(this);
}
this.preUpdateEvent = Optional.of(preUpdateEvent);
this.setUnionMember = UnionMember.PRE_UPDATE_EVENT;
}

public ComponentUpdatePolicyEvents withPreUpdateEvent(
final PreComponentUpdateEvent preUpdateEvent) {
setPreUpdateEvent(preUpdateEvent);
return this;
}

Expand All @@ -56,13 +60,17 @@ public PostComponentUpdateEvent getPostUpdateEvent() {
return null;
}

public ComponentUpdatePolicyEvents setPostUpdateEvent(
final PostComponentUpdateEvent postUpdateEvent) {
public void setPostUpdateEvent(final PostComponentUpdateEvent postUpdateEvent) {
if (setUnionMember != null) {
setUnionMember.nullify(this);
}
this.postUpdateEvent = Optional.of(postUpdateEvent);
this.setUnionMember = UnionMember.POST_UPDATE_EVENT;
}

public ComponentUpdatePolicyEvents withPostUpdateEvent(
final PostComponentUpdateEvent postUpdateEvent) {
setPostUpdateEvent(postUpdateEvent);
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,12 @@ public String getComponentName() {
return null;
}

public ConfigurationUpdateEvent setComponentName(final String componentName) {
public void setComponentName(final String componentName) {
this.componentName = Optional.ofNullable(componentName);
}

public ConfigurationUpdateEvent withComponentName(final String componentName) {
setComponentName(componentName);
return this;
}

Expand All @@ -59,8 +63,12 @@ public List<String> getKeyPath() {
return null;
}

public ConfigurationUpdateEvent setKeyPath(final List<String> keyPath) {
public void setKeyPath(final List<String> keyPath) {
this.keyPath = Optional.ofNullable(keyPath);
}

public ConfigurationUpdateEvent withKeyPath(final List<String> keyPath) {
setKeyPath(keyPath);
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,17 @@ public ConfigurationUpdateEvent getConfigurationUpdateEvent() {
return null;
}

public ConfigurationUpdateEvents setConfigurationUpdateEvent(
final ConfigurationUpdateEvent configurationUpdateEvent) {
public void setConfigurationUpdateEvent(final ConfigurationUpdateEvent configurationUpdateEvent) {
if (setUnionMember != null) {
setUnionMember.nullify(this);
}
this.configurationUpdateEvent = Optional.of(configurationUpdateEvent);
this.setUnionMember = UnionMember.CONFIGURATION_UPDATE_EVENT;
}

public ConfigurationUpdateEvents withConfigurationUpdateEvent(
final ConfigurationUpdateEvent configurationUpdateEvent) {
setConfigurationUpdateEvent(configurationUpdateEvent);
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,21 @@ public String getStatusAsString() {
return null;
}

public void setStatus(final String status) {
this.status = Optional.ofNullable(status);
}

public ConfigurationValidityReport withStatus(final String status) {
setStatus(status);
return this;
}

public void setStatus(final ConfigurationValidityStatus status) {
this.status = Optional.ofNullable(status.getValue());
}

public ConfigurationValidityReport setStatus(final String status) {
this.status = Optional.ofNullable(status);
public ConfigurationValidityReport withStatus(final ConfigurationValidityStatus status) {
setStatus(status);
return this;
}

Expand All @@ -76,8 +85,12 @@ public String getDeploymentId() {
return null;
}

public ConfigurationValidityReport setDeploymentId(final String deploymentId) {
public void setDeploymentId(final String deploymentId) {
this.deploymentId = Optional.ofNullable(deploymentId);
}

public ConfigurationValidityReport withDeploymentId(final String deploymentId) {
setDeploymentId(deploymentId);
return this;
}

Expand All @@ -88,8 +101,12 @@ public String getMessage() {
return null;
}

public ConfigurationValidityReport setMessage(final String message) {
public void setMessage(final String message) {
this.message = Optional.ofNullable(message);
}

public ConfigurationValidityReport withMessage(final String message) {
setMessage(message);
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,12 @@ public String getMessage() {
return null;
}

public ConflictError setMessage(final String message) {
public void setMessage(final String message) {
this.message = Optional.ofNullable(message);
}

public ConflictError withMessage(final String message) {
setMessage(message);
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,12 @@ public String getPassword() {
return null;
}

public CreateDebugPasswordResponse setPassword(final String password) {
public void setPassword(final String password) {
this.password = Optional.ofNullable(password);
}

public CreateDebugPasswordResponse withPassword(final String password) {
setPassword(password);
return this;
}

Expand All @@ -80,8 +84,12 @@ public String getUsername() {
return null;
}

public CreateDebugPasswordResponse setUsername(final String username) {
public void setUsername(final String username) {
this.username = Optional.ofNullable(username);
}

public CreateDebugPasswordResponse withUsername(final String username) {
setUsername(username);
return this;
}

Expand All @@ -92,8 +100,12 @@ public Instant getPasswordExpiration() {
return null;
}

public CreateDebugPasswordResponse setPasswordExpiration(final Instant passwordExpiration) {
public void setPasswordExpiration(final Instant passwordExpiration) {
this.passwordExpiration = Optional.ofNullable(passwordExpiration);
}

public CreateDebugPasswordResponse withPasswordExpiration(final Instant passwordExpiration) {
setPasswordExpiration(passwordExpiration);
return this;
}

Expand All @@ -104,8 +116,12 @@ public String getCertificateSHA256Hash() {
return null;
}

public CreateDebugPasswordResponse setCertificateSHA256Hash(final String certificateSHA256Hash) {
public void setCertificateSHA256Hash(final String certificateSHA256Hash) {
this.certificateSHA256Hash = Optional.ofNullable(certificateSHA256Hash);
}

public CreateDebugPasswordResponse withCertificateSHA256Hash(final String certificateSHA256Hash) {
setCertificateSHA256Hash(certificateSHA256Hash);
return this;
}

Expand All @@ -116,8 +132,12 @@ public String getCertificateSHA1Hash() {
return null;
}

public CreateDebugPasswordResponse setCertificateSHA1Hash(final String certificateSHA1Hash) {
public void setCertificateSHA1Hash(final String certificateSHA1Hash) {
this.certificateSHA1Hash = Optional.ofNullable(certificateSHA1Hash);
}

public CreateDebugPasswordResponse withCertificateSHA1Hash(final String certificateSHA1Hash) {
setCertificateSHA1Hash(certificateSHA1Hash);
return this;
}

Expand Down
Loading

0 comments on commit 806162c

Please sign in to comment.