feign patch

1 분 소요

https://www.baeldung.com/openfeign-http-patch-request

overview

JDK 5.0 introduced Java Generics with the aim of reducing bugs and adding an extra layer of abstraction over types. This tutorial is a quick intro to Generics in Java, the goal behind them, and how they can improve the quality of our code.

계층 추상화를 위해 제네릭 도입

readability

아래 예제에서 List에 담긴 요소를 꺼낼때 명시적으로 캐스팅필요

List list = new LinkedList();
list.add(new Integer(1)); 
// Integer i = list.iterator().next();
Integer i = (Integer) list.iterator().next();

List에서 꺼낸 요소의 리턴타입을 보장할 수 없음
선언한 List 객체는 어떤 타입의 객체라도 보유할 수 있기 때문
매번 이런 캐스팅작업은 성가시고, 가독성을 저해시킴

List<Integer> list = new LinkedList<>();

By adding the diamond operator <> conntaining the type, we narrow the specialization of this list to only Integer type In other words, we specify the type held inside the list The compiler can enforce the type at compile time …

dimond 연산을 통해 list의 타입을 좁혀 list안에든 요소의 타입을 지정할 수 있고, 코드의 양이 많지 않은경우 사소해보일 수 있지만, 코드의 양이 방대해지는경우 실수 유발 및 가독성을 저해시킬 수 있음

generic methods

reference

https://www.baeldung.com/java-generics

wildcard

와일드카드는 코드의 유연성을 높임 와일드카드를 사용하면 특정 타입뿐만 아니라 해당 타입의 하위 혹은 상위 타입까지 처리할 수 있음 와일드카드는 주로 제네릭 컬렉션이나 메서드의 파라미터 타입으로 사용됨