Skip to content

Commit

Permalink
Annotate API with Spring's @NonNullApi/@nullable to indicate null/non…
Browse files Browse the repository at this point in the history
…-null rules

Closes gh-494.
  • Loading branch information
mp911de committed Sep 24, 2020
1 parent f44a525 commit 0972771
Show file tree
Hide file tree
Showing 27 changed files with 335 additions and 342 deletions.
Expand Up @@ -16,85 +16,83 @@

package org.springframework.cloud.vault.config.aws;

import javax.validation.constraints.NotEmpty;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.vault.config.VaultSecretBackendDescriptor;
import org.springframework.validation.annotation.Validated;
import org.springframework.lang.Nullable;

/**
* Configuration properties for Vault using the AWS integration.
*
* @author Mark Paluch
*/
@ConfigurationProperties("spring.cloud.vault.aws")
@Validated
public class VaultAwsProperties implements VaultSecretBackendDescriptor {

/**
* Enable aws backend usage.
*/
private boolean enabled = false;
private boolean enabled;

/**
* Role name for credentials.
*/
@Nullable
private String role;

/**
* aws backend path.
*/
@NotEmpty
private String backend = "aws";

/**
* Target property for the obtained access key.
*/
@NotEmpty
private String accessKeyProperty = "cloud.aws.credentials.accessKey";

/**
* Target property for the obtained secret key.
*/
@NotEmpty
private String secretKeyProperty = "cloud.aws.credentials.secretKey";

@Override
public boolean isEnabled() {
return this.enabled;
}

public String getRole() {
return this.role;
}

public String getBackend() {
return this.backend;
}

public String getAccessKeyProperty() {
return this.accessKeyProperty;
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}

public String getSecretKeyProperty() {
return this.secretKeyProperty;
@Nullable
public String getRole() {
return this.role;
}

public void setEnabled(boolean enabled) {
this.enabled = enabled;
public void setRole(@Nullable String role) {
this.role = role;
}

public void setRole(String role) {
this.role = role;
@Override
public String getBackend() {
return this.backend;
}

public void setBackend(String backend) {
this.backend = backend;
}

public String getAccessKeyProperty() {
return this.accessKeyProperty;
}

public void setAccessKeyProperty(String accessKeyProperty) {
this.accessKeyProperty = accessKeyProperty;
}

public String getSecretKeyProperty() {
return this.secretKeyProperty;
}

public void setSecretKeyProperty(String secretKeyProperty) {
this.secretKeyProperty = secretKeyProperty;
}
Expand Down
Expand Up @@ -18,5 +18,6 @@
* AWS integration with Vault.
* @author Mark Paluch
*/

@org.springframework.lang.NonNullApi
@org.springframework.lang.NonNullFields
package org.springframework.cloud.vault.config.aws;
Expand Up @@ -16,71 +16,70 @@

package org.springframework.cloud.vault.config.consul;

import javax.validation.constraints.NotEmpty;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.vault.config.VaultSecretBackendDescriptor;
import org.springframework.validation.annotation.Validated;
import org.springframework.lang.Nullable;

/**
* Configuration properties for HashiCorp Consul.
*
* @author Mark Paluch
*/
@ConfigurationProperties("spring.cloud.vault.consul")
@Validated
public class VaultConsulProperties implements VaultSecretBackendDescriptor {

/**
* Enable consul backend usage.
*/
private boolean enabled = false;
private boolean enabled;

/**
* Role name for credentials.
*/
@Nullable
private String role;

/**
* Consul backend path.
*/
@NotEmpty
private String backend = "consul";

/**
* Target property for the obtained token.
*/
@NotEmpty
private String tokenProperty = "spring.cloud.consul.token";

@Override
public boolean isEnabled() {
return this.enabled;
}

public String getRole() {
return this.role;
}

public String getBackend() {
return this.backend;
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}

public String getTokenProperty() {
return this.tokenProperty;
@Nullable
public String getRole() {
return this.role;
}

public void setEnabled(boolean enabled) {
this.enabled = enabled;
public void setRole(@Nullable String role) {
this.role = role;
}

public void setRole(String role) {
this.role = role;
@Override
public String getBackend() {
return this.backend;
}

public void setBackend(String backend) {
this.backend = backend;
}

public String getTokenProperty() {
return this.tokenProperty;
}

public void setTokenProperty(String tokenProperty) {
this.tokenProperty = tokenProperty;
}
Expand Down
Expand Up @@ -18,5 +18,6 @@
* Consul integration with Vault.
* @author Mark Paluch
*/

@org.springframework.lang.NonNullApi
@org.springframework.lang.NonNullFields
package org.springframework.cloud.vault.config.consul;
Expand Up @@ -16,9 +16,8 @@

package org.springframework.cloud.vault.config.databases;

import javax.validation.constraints.NotEmpty;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.lang.Nullable;
import org.springframework.validation.annotation.Validated;

/**
Expand All @@ -34,36 +33,34 @@ public class VaultCassandraProperties implements DatabaseSecretProperties {
/**
* Enable cassandra backend usage.
*/
private boolean enabled = false;
private boolean enabled;

/**
* Role name for credentials.
*/
@Nullable
private String role;

/**
* Enable static role usage.
*
* @since 2.2
*/
private boolean staticRole = false;
private boolean staticRole;

/**
* Cassandra backend path.
*/
@NotEmpty
private String backend = "cassandra";

/**
* Target property for the obtained username.
*/
@NotEmpty
private String usernameProperty = "spring.data.cassandra.username";

/**
* Target property for the obtained password.
*/
@NotEmpty
private String passwordProperty = "spring.data.cassandra.password";

@Override
Expand All @@ -76,11 +73,12 @@ public void setEnabled(boolean enabled) {
}

@Override
@Nullable
public String getRole() {
return this.role;
}

public void setRole(String role) {
public void setRole(@Nullable String role) {
this.role = role;
}

Expand Down
Expand Up @@ -16,18 +16,15 @@

package org.springframework.cloud.vault.config.databases;

import javax.validation.constraints.NotEmpty;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.validation.annotation.Validated;
import org.springframework.lang.Nullable;

/**
* Configuration properties for Vault using the Couchbase integration.
*
* @author Francis Hitchens
*/
@ConfigurationProperties("spring.cloud.vault.couchbase")
@Validated
public class VaultCouchbaseProperties implements DatabaseSecretProperties {

/**
Expand All @@ -38,6 +35,7 @@ public class VaultCouchbaseProperties implements DatabaseSecretProperties {
/**
* Role name for credentials.
*/
@Nullable
private String role;

/**
Expand All @@ -49,19 +47,16 @@ public class VaultCouchbaseProperties implements DatabaseSecretProperties {
/**
* Couchbase backend path.
*/
@NotEmpty
private String backend = "database";

/**
* Target property for the obtained username.
*/
@NotEmpty
private String usernameProperty = "spring.couchbase.username";

/**
* Target property for the obtained password.
*/
@NotEmpty
private String passwordProperty = "spring.couchbase.password";

@Override
Expand All @@ -74,11 +69,12 @@ public void setEnabled(boolean enabled) {
}

@Override
@Nullable
public String getRole() {
return this.role;
}

public void setRole(String role) {
public void setRole(@Nullable String role) {
this.role = role;
}

Expand Down

0 comments on commit 0972771

Please sign in to comment.