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
import java.util.List; | |
public class TaxCalculator { | |
// Define a list of tax brackets | |
private static final List<TaxBracket> taxBrackets = List.of( | |
new TaxBracket(0, 10225, 0.0), | |
new TaxBracket(10225, 26070, 0.11), | |
new TaxBracket(26070, 74545, 0.30), | |
new TaxBracket(74545, 160336, 0.41), |
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
public class TaxCalculator { | |
// Method to calculate the tax based on income | |
public double calculateTax(double income) { | |
double tax; | |
if (income <= 10225) { | |
tax = 0; | |
} else if (income <= 26070) { | |
tax = (income - 10225) * 0.11; | |
} else if (income <= 74545) { |
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
Taxable income fraction | Tax rate to be applied to the bracket | |
---|---|---|
Up to €11.294 | 0% | |
From €11.295 to €28.797 | 11% | |
From €28.798 to €82.341 | 30% | |
From €82.342 to €177.106 | 41% | |
Over €177.106 | 45% |
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
import java.text.Normalizer; | |
public class StringUtils { | |
/** | |
* Remove toda a acentuação da string substituindo por caracteres simples sem acento. | |
*/ | |
public static String unaccent(String src) { | |
return Normalizer | |
.normalize(src, Normalizer.Form.NFD) |
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
docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' container-postgresdb |
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
echo "Step 1- create a docker bridge network database-network " | |
docker network create database-network | |
echo "Step 2- create a docker conatiner: container-postgresdb " | |
docker run --detach \ | |
--network database-network \ | |
--name container-postgresdb \ | |
--publish 5432:5432 \ | |
--env POSTGRES_USER=postgres \ | |
--env POSTGRES_PASSWORD=admin \ |
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
version: '3' | |
services: | |
postgres: | |
container_name: container-postgresdb | |
image: postgres | |
hostname: postgres | |
ports: | |
- "6543:5432" | |
environment: | |
POSTGRES_USER: postgres |
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
// Signature of the HttpClient.get method | |
Mono<JsonObject> get(String url); | |
// The two urls to call | |
String firstUserUrl = "my-api/first-user"; | |
String userDetailsUrl = "my-api/users/details/"; // needs the id at the end | |
// Example with map | |
Mono<Mono<JsonObject>> result = HttpClient.get(firstUserUrl). | |
map(user -> HttpClient.get(userDetailsUrl + user.getId())); |
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.rest.api.covid19; | |
import com.rest.api.covid19.domain.Country; | |
import com.rest.api.covid19.domain.Covid19Statistics; | |
import lombok.extern.slf4j.Slf4j; | |
import org.springframework.boot.ApplicationArguments; | |
import org.springframework.boot.ApplicationRunner; | |
import org.springframework.boot.SpringApplication; | |
import org.springframework.boot.autoconfigure.SpringBootApplication; | |
import org.springframework.web.client.RestTemplate; |
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.rest.api.covid19.domain; | |
import com.fasterxml.jackson.annotation.JsonInclude; | |
import com.fasterxml.jackson.annotation.JsonProperty; | |
import lombok.Data; | |
@Data | |
@JsonInclude(JsonInclude.Include.NON_NULL) | |
public class Country { |
NewerOlder