Tu'i Fa'amatalaga i Java

Tu'i Fa'amatalaga i Java

Faatasi ai ma le faʻaofiina o Java 8, ua faʻaalia e le faʻasalalauga ni foliga fou se lua e taʻua o faʻamatalaga toe fai ma faʻamatalaga faʻailoga. Seia oo mai i le taimi nei, afai e te manaʻo e faʻaoga faʻamatalaga i Java, e mafai ona e faia i totonu o faʻamatalaga. Faatasi ai ma Java 8, ua mafai nei ona e faʻaopoopo faʻamatalaga i soʻo se ituaiga faʻaoga. Po'o fea lava o lo'o e fa'aogaina ai se ituaiga (e aofia ai ituaiga i ta'utinoga, generics, ma lafo), e mafai ona e fa'atasi ma se fa'amatalaga.

Tu'aiga Fa'amatalaga Fa'asologa

Java 8 e mafai ona faʻaalia faʻamatalaga faʻamatalaga i soʻo se ituaiga faʻaoga. O se tasi faʻataʻitaʻiga o le snippet o loʻo i lalo:

@Encrypted String data; Lisi <@NonNull String> manoa; myGraph = ( @Immutable Graph ) tmpGraph; E mafai lava ona e fa'ailoa mai se fa'amatalaga ituaiga fou. O le faagasologa e tutusa ma le faʻamalamalamaina o se faʻamatalaga ma le ElementType.TYPE_PARAMETER sini, ElementType.TYPE_USE sini, poʻo sini uma e lua: @Target ( { ElementType.TYPE_PARAMETER, ElementType.TYPE_USE } ) public @interface Encrypted { }

O le ElementType.TYPE_PARAMETER sini e fa'ailoa mai e mafai ona e tusia le fa'amatalaga i luga o le ta'utinoga o se ituaiga fesuiaiga (fa'ata'ita'iga vasega MyClass {….}). O le Element.Type.TYPE_USE e faʻaalia ai e mafai ona e tusia le faʻamatalaga i luga o soʻo se ituaiga faʻaoga (faʻapitoa i taʻutinoga, generics, ma lafo).

E mafai ona e fa'asaoina fa'amatalaga i faila o vasega, ae e le afaina pe fa'aaafia ai le fa'atinoina o le polokalame. Mo se faʻataʻitaʻiga, e mafai ona e faʻaalia ni faila faila se lua ma se fesoʻotaʻiga e pei ona faʻaalia i le code i lalo:

Faila faila = ....; @Encryted File encryptedFile = …; @Tatala So'oga so'oga = …; A'o e fa'atinoina le polokalame, e tutusa le i'uga pe afai e te pasi se tasi o faila e lua i le feso'ota'iga send() method. connection.send(file); connection.send(encryptedFile);

 

O Nisi Fa'ata'ita'iga o Fa'amatalaga Ituaiga

@nonNull Lisi Lisi <@NonNull String> str Arrays <@NonNegative Integer> fa'avasega @Encypted File faila @Tatala Feso'ota'iga feso'ota'iga fa'aleaogaina divideInteger (int a, int b) togi @ZeroDivisior ArithmeticException

 

Tuua se faamatalaga

O lenei 'upega tafaʻilagi e faʻaaogaina le Akismet e faʻaitiitia le spam. Aoao pe faapefea ona faʻasoa lau faʻamatalaga faʻamatalaga.