Annotate API with Spring's @NonNullApi/@Nullable to indicate null/non-null rules

Closes gh-494.
This commit is contained in:
Mark Paluch
2020-09-24 11:43:31 +02:00
parent 59bacc6b73
commit dcd91e200f
27 changed files with 345 additions and 352 deletions

View File

@@ -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;
/**
@@ -34,11 +33,12 @@ public class VaultCassandraProperties implements DatabaseSecretProperties {
/**
* Enable cassandra backend usage.
*/
private boolean enabled = false;
private boolean enabled;
/**
* Role name for credentials.
*/
@Nullable
private String role;
/**
@@ -46,24 +46,21 @@ public class VaultCassandraProperties implements DatabaseSecretProperties {
*
* @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
@@ -76,11 +73,12 @@ public class VaultCassandraProperties implements DatabaseSecretProperties {
}
@Override
@Nullable
public String getRole() {
return this.role;
}
public void setRole(String role) {
public void setRole(@Nullable String role) {
this.role = role;
}

View File

@@ -16,10 +16,8 @@
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.
@@ -27,7 +25,6 @@ import org.springframework.validation.annotation.Validated;
* @author Francis Hitchens
*/
@ConfigurationProperties("spring.cloud.vault.couchbase")
@Validated
public class VaultCouchbaseProperties implements DatabaseSecretProperties {
/**
@@ -38,6 +35,7 @@ public class VaultCouchbaseProperties implements DatabaseSecretProperties {
/**
* Role name for credentials.
*/
@Nullable
private String role;
/**
@@ -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
@@ -74,11 +69,12 @@ public class VaultCouchbaseProperties implements DatabaseSecretProperties {
}
@Override
@Nullable
public String getRole() {
return this.role;
}
public void setRole(String role) {
public void setRole(@Nullable String role) {
this.role = role;
}

View File

@@ -16,10 +16,8 @@
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 Database integration.
@@ -29,7 +27,6 @@ import org.springframework.validation.annotation.Validated;
* @since 2.0
*/
@ConfigurationProperties("spring.cloud.vault.database")
@Validated
public class VaultDatabaseProperties implements DatabaseSecretProperties {
/**
@@ -40,6 +37,7 @@ public class VaultDatabaseProperties implements DatabaseSecretProperties {
/**
* Role name for credentials.
*/
@Nullable
private String role;
/**
@@ -50,19 +48,16 @@ public class VaultDatabaseProperties implements DatabaseSecretProperties {
/**
* Database backend path.
*/
@NotEmpty
private String backend = "database";
/**
* Target property for the obtained username.
*/
@NotEmpty
private String usernameProperty = "spring.datasource.username";
/**
* Target property for the obtained password.
*/
@NotEmpty
private String passwordProperty = "spring.datasource.password";
@Override
@@ -75,11 +70,12 @@ public class VaultDatabaseProperties implements DatabaseSecretProperties {
}
@Override
@Nullable
public String getRole() {
return this.role;
}
public void setRole(String role) {
public void setRole(@Nullable String role) {
this.role = role;
}

View File

@@ -16,10 +16,8 @@
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 Elasticsearch integration.
@@ -28,40 +26,37 @@ import org.springframework.validation.annotation.Validated;
* @since 3.0
*/
@ConfigurationProperties("spring.cloud.vault.elasticsearch")
@Validated
public class VaultElasticsearchProperties implements DatabaseSecretProperties {
/**
* Enable elasticsearch backend usage.
*/
private boolean enabled = false;
private boolean enabled;
/**
* Role name for credentials.
*/
@Nullable
private String role;
/**
* Enable static role usage.
*/
private boolean staticRole = false;
private boolean staticRole;
/**
* Database backend path.
*/
@NotEmpty
private String backend = "database";
/**
* Target property for the obtained username.
*/
@NotEmpty
private String usernameProperty = "spring.elasticsearch.rest.username";
/**
* Target property for the obtained password.
*/
@NotEmpty
private String passwordProperty = "spring.elasticsearch.rest.password";
@Override
@@ -74,11 +69,12 @@ public class VaultElasticsearchProperties implements DatabaseSecretProperties {
}
@Override
@Nullable
public String getRole() {
return this.role;
}
public void setRole(String role) {
public void setRole(@Nullable String role) {
this.role = role;
}

View File

@@ -16,10 +16,8 @@
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 MongoDB integration.
@@ -28,17 +26,17 @@ import org.springframework.validation.annotation.Validated;
* @author Sebastien Nahelou
*/
@ConfigurationProperties("spring.cloud.vault.mongodb")
@Validated
public class VaultMongoProperties implements DatabaseSecretProperties {
/**
* Enable mongodb backend usage.
*/
private boolean enabled = false;
private boolean enabled;
/**
* Role name for credentials.
*/
@Nullable
private String role;
/**
@@ -46,24 +44,21 @@ public class VaultMongoProperties implements DatabaseSecretProperties {
*
* @since 2.2
*/
private boolean staticRole = false;
private boolean staticRole;
/**
* MongoDB backend path.
*/
@NotEmpty
private String backend = "mongodb";
/**
* Target property for the obtained username.
*/
@NotEmpty
private String usernameProperty = "spring.data.mongodb.username";
/**
* Target property for the obtained password.
*/
@NotEmpty
private String passwordProperty = "spring.data.mongodb.password";
@Override
@@ -76,11 +71,12 @@ public class VaultMongoProperties implements DatabaseSecretProperties {
}
@Override
@Nullable
public String getRole() {
return this.role;
}
public void setRole(String role) {
public void setRole(@Nullable String role) {
this.role = role;
}

View File

@@ -16,11 +16,9 @@
package org.springframework.cloud.vault.config.databases;
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 MySQL integration.
@@ -29,7 +27,6 @@ import org.springframework.validation.annotation.Validated;
* @deprecated since 2.0. Use {@link VaultDatabaseProperties}.
*/
@ConfigurationProperties("spring.cloud.vault.mysql")
@Validated
@Deprecated
public class VaultMySqlProperties implements DatabaseSecretProperties, VaultSecretBackendDescriptor {
@@ -41,24 +38,22 @@ public class VaultMySqlProperties implements DatabaseSecretProperties, VaultSecr
/**
* Role name for credentials.
*/
@Nullable
private String role;
/**
* mysql backend path.
*/
@NotEmpty
private String backend = "mysql";
/**
* Target property for the obtained username.
*/
@NotEmpty
private String usernameProperty = "spring.datasource.username";
/**
* Target property for the obtained username.
*/
@NotEmpty
private String passwordProperty = "spring.datasource.password";
@Override
@@ -71,11 +66,12 @@ public class VaultMySqlProperties implements DatabaseSecretProperties, VaultSecr
}
@Override
@Nullable
public String getRole() {
return this.role;
}
public void setRole(String role) {
public void setRole(@Nullable String role) {
this.role = role;
}

View File

@@ -16,10 +16,8 @@
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 PostgreSQL integration.
@@ -28,7 +26,6 @@ import org.springframework.validation.annotation.Validated;
* @deprecated since 2.0. Use {@link VaultDatabaseProperties}.
*/
@ConfigurationProperties("spring.cloud.vault.postgresql")
@Validated
@Deprecated
public class VaultPostgreSqlProperties implements DatabaseSecretProperties {
@@ -41,24 +38,22 @@ public class VaultPostgreSqlProperties implements DatabaseSecretProperties {
/**
* Role name for credentials.
*/
@Nullable
private String role;
/**
* postgresql backend path.
*/
@NotEmpty
private String backend = "postgresql";
/**
* Target property for the obtained username.
*/
@NotEmpty
private String usernameProperty = "spring.datasource.username";
/**
* Target property for the obtained username.
*/
@NotEmpty
private String passwordProperty = "spring.datasource.password";
@Override
@@ -71,11 +66,12 @@ public class VaultPostgreSqlProperties implements DatabaseSecretProperties {
}
@Override
@Nullable
public String getRole() {
return this.role;
}
public void setRole(String role) {
public void setRole(@Nullable String role) {
this.role = role;
}

View File

@@ -18,5 +18,6 @@
* Database integration with Vault.
* @author Mark Paluch
*/
@org.springframework.lang.NonNullApi
@org.springframework.lang.NonNullFields
package org.springframework.cloud.vault.config.databases;