Effective Java



Download 2,19 Mb.
Pdf ko'rish
bet183/341
Sana11.07.2022
Hajmi2,19 Mb.
#776765
1   ...   179   180   181   182   183   184   185   186   ...   341
Bog'liq
Effective Java



ITEM 44: FAVOR THE USE OF STANDARD FUNCTIONAL INTERFACES
201
There are nine additional variants of the 
Function
interface, for use when the
result type is primitive. The source and result types always differ, because a func-
tion from a type to itself is a 
UnaryOperator
. If both the source and result types are
primitive, prefix 
Function
with 
Src
To
Result
, for example 
LongToIntFunction
(six variants). If the source is a primitive and the result is an object reference, prefix
Function
with
ToObj
, for example 
DoubleToObjFunction
(three variants). 
There are two-argument versions of the three basic functional interfaces for
which it makes sense to have them: 
BiPredicate

BiFunction
,
and 
BiConsumer
. There are also 
BiFunction
variants returning the three
relevant primitive types: 
ToIntBiFunction

ToLongBiFunction
, and
ToDoubleBiFunction
. There are two-argument variants of 
Consumer
that
take one object reference and one primitive type: 
ObjDoubleConsumer
,
ObjIntConsumer
, and 
ObjLongConsumer
. In total, there are nine two-
argument versions of the basic interfaces.
Finally, there is the 
BooleanSupplier
interface, a variant of 
Supplier
that
returns 
boolean
values. This is the only explicit mention of the 
boolean
type in
any of the standard functional interface names, but 
boolean
return values are
supported via 
Predicate
and its four variant forms. The 
BooleanSupplier
interface and the forty-two interfaces described in the previous paragraphs
account for all forty-three standard functional interfaces. Admittedly, this is a lot
to swallow, and not terribly orthogonal. On the other hand, the bulk of the
functional interfaces that you’ll need have been written for you and their names
are regular enough that you shouldn’t have too much trouble coming up with one
when you need it.
Most of the standard functional interfaces exist only to provide support for
primitive types. 

Download 2,19 Mb.

Do'stlaringiz bilan baham:
1   ...   179   180   181   182   183   184   185   186   ...   341




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish