Skip to content

Instantly share code, notes, and snippets.

View Raouf25's full-sized avatar

ABDERRAOUF MAKHLOUF Raouf25

View GitHub Profile
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 Global {
package com.rest.api.covid19.domain;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.util.List;
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
{
"Global": {
"NewConfirmed": 257886,
"TotalConfirmed": 17849120,
"NewDeaths": 5615,
"TotalDeaths": 685038,
"NewRecovered": 222627,
"TotalRecovered": 10552934
},
"Countries": [
List<String> list = new ArrayList<String>();
list.add("hello");
list.add(32);//Compile Time Error
List<String> list = new ArrayList<String>();
list.add("hello");
String s = list.get(0);
List list = new ArrayList();
list.add("hello");
String s = (String) list.get(0);//typecasting
List<Integer> list = new ArrayList<Integer>();
list.add(10);
list.add("10");// compile-time error
List list = new ArrayList();
list.add(10);
list.add("10");
@ControllerAdvice
@CrossOrigin
public class ExceptionHandlerController {
@ExceptionHandler({ClientUnavailableException.class})
public ResponseEntity<ErrorAndCodeResponse> badRequest(BackendException e) {
ErrorAndCodeResponse error = new ErrorAndCodeResponse(e.getCode().name(), e.getCode().getMessage(), e.getAdditionalInfo());
return new ResponseEntity<>(error, HttpStatus.BAD_REQUEST);
}
public Agreement getById(Integer id) throws BackendException {
try {
AgreementDto agreementDto = this.agreementClientService.get(id);
return mapper.map(agreementDto, Agreement.class);
} catch (ResourceAccessException e) {
throw new CatalogClientUnavailableException();
} catch (CatalogException e) {
throw new ResourceNotFoundException(id, "Agreement");
}
}