Browse Source

Add nullability annotations to module/spring-boot-sendgrid

See gh-46587
pull/47390/head
Moritz Halbritter 4 months ago
parent
commit
d78d803525
  1. 3
      module/spring-boot-sendgrid/src/main/java/org/springframework/boot/sendgrid/autoconfigure/SendGridAutoConfiguration.java
  2. 30
      module/spring-boot-sendgrid/src/main/java/org/springframework/boot/sendgrid/autoconfigure/SendGridProperties.java
  3. 3
      module/spring-boot-sendgrid/src/main/java/org/springframework/boot/sendgrid/autoconfigure/package-info.java

3
module/spring-boot-sendgrid/src/main/java/org/springframework/boot/sendgrid/autoconfigure/SendGridAutoConfiguration.java

@ -47,7 +47,8 @@ public final class SendGridAutoConfiguration { @@ -47,7 +47,8 @@ public final class SendGridAutoConfiguration {
@Bean
@ConditionalOnMissingBean(SendGridAPI.class)
SendGrid sendGrid(SendGridProperties properties) {
if (properties.isProxyConfigured()) {
if (properties.getProxy() != null && properties.getProxy().getHost() != null
&& properties.getProxy().getPort() != null) {
HttpHost proxy = new HttpHost(properties.getProxy().getHost(), properties.getProxy().getPort());
return new SendGrid(properties.getApiKey(), new Client(HttpClientBuilder.create().setProxy(proxy).build()));
}

30
module/spring-boot-sendgrid/src/main/java/org/springframework/boot/sendgrid/autoconfigure/SendGridProperties.java

@ -16,6 +16,8 @@ @@ -16,6 +16,8 @@
package org.springframework.boot.sendgrid.autoconfigure;
import org.jspecify.annotations.Nullable;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
@ -31,58 +33,54 @@ public class SendGridProperties { @@ -31,58 +33,54 @@ public class SendGridProperties {
/**
* SendGrid API key.
*/
private String apiKey;
private @Nullable String apiKey;
/**
* Proxy configuration.
*/
private Proxy proxy;
private @Nullable Proxy proxy;
public String getApiKey() {
public @Nullable String getApiKey() {
return this.apiKey;
}
public void setApiKey(String apiKey) {
public void setApiKey(@Nullable String apiKey) {
this.apiKey = apiKey;
}
public Proxy getProxy() {
public @Nullable Proxy getProxy() {
return this.proxy;
}
public void setProxy(Proxy proxy) {
public void setProxy(@Nullable Proxy proxy) {
this.proxy = proxy;
}
public boolean isProxyConfigured() {
return this.proxy != null && this.proxy.getHost() != null && this.proxy.getPort() != null;
}
public static class Proxy {
/**
* SendGrid proxy host.
*/
private String host;
private @Nullable String host;
/**
* SendGrid proxy port.
*/
private Integer port;
private @Nullable Integer port;
public String getHost() {
public @Nullable String getHost() {
return this.host;
}
public void setHost(String host) {
public void setHost(@Nullable String host) {
this.host = host;
}
public Integer getPort() {
public @Nullable Integer getPort() {
return this.port;
}
public void setPort(Integer port) {
public void setPort(@Nullable Integer port) {
this.port = port;
}

3
module/spring-boot-sendgrid/src/main/java/org/springframework/boot/sendgrid/autoconfigure/package-info.java

@ -17,4 +17,7 @@ @@ -17,4 +17,7 @@
/**
* Auto-configuration for SendGrid.
*/
@NullMarked
package org.springframework.boot.sendgrid.autoconfigure;
import org.jspecify.annotations.NullMarked;

Loading…
Cancel
Save