[java] Guava와 관련된 주요 개념들은 무엇인가요?
  1. Immutable Collections: Guava는 변경할 수 없는 (Immutable) 컬렉션 클래스를 제공합니다. 이를 통해 불변성을 지니는 컬렉션을 사용하면 안전하고 효율적인 프로그래밍이 가능해집니다.
ImmutableList<String> names = ImmutableList.of("Alice", "Bob", "Charlie");
  1. Functional Programming: Guava는 함수형 프로그래밍을 지원하며, 함수형 인터페이스와 함수 조합을 제공합니다. 이를 통해 함수형 스타일로 자바 코드를 작성할 수 있습니다.
Function<String, Integer> lengthFunction = String::length;
List<String> names = ImmutableList.of("Alice", "Bob", "Charlie");
List<Integer> nameLengths = Lists.transform(names, lengthFunction);
  1. Preconditions: Guava는 사전조건을 검증하는 Preconditions 클래스를 제공합니다. 이를 사용하여 메소드의 인자나 상태를 검증할 수 있습니다.
public void process(List<String> names, int limit) {
    Preconditions.checkNotNull(names, "Names cannot be null");
    Preconditions.checkArgument(limit > 0, "Limit must be greater than zero");
    // ...
}
  1. Caches: Guava는 메모리 캐싱 기능을 제공합니다. 캐시를 사용하여 자주 사용되는 데이터에 빠르게 접근하고 성능을 향상시킬 수 있습니다.
LoadingCache<Key, Value> cache = CacheBuilder.newBuilder()
    .maximumSize(100)
    .expireAfterWrite(10, TimeUnit.MINUTES)
    .build(
        new CacheLoader<Key, Value>() {
            public Value load(Key key) {
                return createValue(key);
            }
        }
    );

여기서 설명한 개념들은 Guava의 일부에 불과하며, Guava는 더 다양한 기능과 유틸리티 클래스를 제공합니다. Guava의 공식 문서를 참조하면 더 많은 정보를 얻을 수 있습니다.

Guava 공식 문서