LongToIntFunction
LongToIntFunction (long→int 함수형 인터페이스)
long 값 인자를 받아 int 값 결과를 생성하는 함수를 나타내는 함수형 인터페이스예요. Function의 long-to-int 원시 특수화예요.
본문
LongToIntFunction의 추상 메서드는 applyAsInt(long)으로 long 인자를 받아 int를 반환해요.
@FunctionalInterface
public interface LongToIntFunction
LongToIntFunction cast = n -> (int) n;
LongToIntFunction low32 = n -> (int) (n & 0xFFFF_FFFFL);
int c = cast.applyAsInt(4_000_000_000L); // 변환(절단)
int l = low32.applyAsInt(0x1_0000_0001L); // 1
LongStream의 값을 IntStream으로 변환할 때 사용해요.
IntStream is = LongStream.of(1L, 2L).mapToInt(n -> (int) n);
함수형 메서드는 applyAsInt(long)예요. 코드와 시그니처는 원문 그대로 보존돼요.