Skip to content

Instantly share code, notes, and snippets.

View samuelcatalano-zz's full-sized avatar
🏠
Working from home

Samuel Catalano samuelcatalano-zz

🏠
Working from home
View GitHub Profile
package src.main.java;
import java.util.Scanner;
/**
* {@link RGBColors}.
* @author Samuel Catalano
*/
public class RGBColors{
@samuelcatalano-zz
samuelcatalano-zz / ResponseError.java
Last active November 28, 2018 19:41
Returning message error using javax.ws.rs.core.Response
//javax.ws.rs.core.Response return message error
// catch Expection
JsonObject error = new JsonObject();
error.put("erro", e.getMessage());
return Response.status(HttpStatus.SC_BAD_REQUEST).entity(error.toString()).type(MediaType.APPLICATION_JSON).build();
@samuelcatalano-zz
samuelcatalano-zz / BuilderExample.java
Created November 28, 2018 19:40
How to create a Builder
public class ConsumidorBuilder {
private Consumidor consumidor;
public ConsumidorBuilder() {
this.consumidor = new Consumidor();
}
public ConsumidorBuilder idExterno(String idExterno) {
this.consumidor.setIdExterno(idExterno);
final ObjectMapper mapper = new ObjectMapper();
try {
usuario = mapper.writeValueAsString(usuarioRaichu);
final Client client = ClientBuilder.newClient();
response = client
.target(host)
.request().header("Authorization", authToken)
.accept(MediaType.APPLICATION_JSON)
.post(Entity.entity(usuario, "application/json"));
# custom IntelliJ IDEA VM options
-ea
-server
-Xms2G
-Xmx4096M
-Xss16m
-XX:MaxMetaspaceSize=2G
-XX:MetaspaceSize=512m
-XX:ConcGCThreads=6
public static Cache<Integer, List<CountryPublicHolidays>> countryPublicHolidaysCache;
static {
countryPublicHolidaysCache = CacheBuilder.newBuilder()
.maximumSize(1000)
.expireAfterWrite(20, TimeUnit.MINUTES)
.build();
}
var cachedCountryPublicHolidays = countryPublicHolidaysCache.getIfPresent(currentYear);