Last active
October 18, 2019 11:57
-
-
Save j-tim/01fc7804fd6ad447747f16db2a676b9e to your computer and use it in GitHub Desktop.
Spring Boot 2.2 Immutable configuration binding class example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.immutable.configuration.binding; | |
import lombok.Getter; | |
import org.springframework.boot.context.properties.ConfigurationProperties; | |
import org.springframework.boot.context.properties.ConstructorBinding; | |
@Getter | |
@ConfigurationProperties("stock.quote.subscription") | |
public class ImmutableStockQuoteSubscriptionProperties { | |
private final String endpoint; | |
private final String apiKey; | |
private final SubscriptionType subscriptionType; | |
private final boolean enabled; | |
@ConstructorBinding | |
public ImmutableStockQuoteSubscriptionProperties(String endpoint, String apiKey, SubscriptionType subscriptionType, boolean enabled) { | |
this.endpoint = endpoint; | |
this.apiKey = apiKey; | |
this.subscriptionType = subscriptionType; | |
this.enabled = enabled; | |
} | |
enum SubscriptionType { | |
/** | |
* Real time stock quotes | |
*/ | |
REALTIME, | |
/** | |
* Stock quotes that are delayed by 15 minutes | |
*/ | |
DELAYED, | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment