Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
†黒魔術† と Annotation と AspectJ
Search
kaiinui
August 23, 2014
Technology
1.2k
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
†黒魔術† と Annotation と AspectJ
Annotation と AspectJ で楽しい黒魔術 (▰╹◡╹▰)
kaiinui
August 23, 2014
More Decks by kaiinui
See All by kaiinui
Black Magic in Java
kaiinui
1
630
API開発自動化と量産
kaiinui
1
470
Other Decks in Technology
See All in Technology
Webアクセシビリティ入門 2026
recruitengineers
PRO
3
530
ボトムアップ文化が強い組織で セキュリティをどう根付かせていくかの現在進行形の話 / Making Security Stick in a Bottom-Up Organization
yamaguchitk333
0
210
【CEDEC2026】『GRANBLUE FANTASY: Relink - Endless Ragnarok』のバトル制作事例 ~最高のキャラゲーを目指して~
cygames
PRO
0
250
強化学習「理論」入門
enakai00
3
3.6k
ブラウザ研修 2026
recruitengineers
PRO
6
920
Cursor Meetup Sapporo - Cursor物語 続編
cocacola917
0
150
【CEDEC2026】ゲームシナリオライターを支援するAIツール開発の実践 ― 設計とプロンプトの工夫 ―
cygames
PRO
1
790
関東Kaggler会発表資料
takoi
1
220
カートの信頼性を担保するWireMockを使ったe2eテスト
ykagano
0
170
個人OSSが、机の上から世界に広がるまでの話
shinyasaita
1
380
[しろおび夏祭り2026] チャットするAIから、作業するAIへ - 使われ方の変化と、その裏側で起きていること
kk0n
0
1.7k
Pavlokで始める電撃駆動開発
sgrsn
0
190
Featured
See All Featured
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
440
Build your cross-platform service in a week with App Engine
jlugia
234
19k
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
660
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
370
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
240
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1.1k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.7k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
750
Code Reviewing Like a Champion
maltzj
528
40k
Utilizing Notion as your number one productivity tool
mfonobong
4
530
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
4.3k
Transcript
†黒魔術† @_kaiinui
=
結論から? (▰╹◡╹▰)
@PotatoTip をつけるだけでトースト
Java の黒魔術: Annotation
Java の黒魔術: Annotation どうみても黒魔術
Java の黒魔術: Annotation Annotation as a code?
良さ? ・宣言的さ ・コードと「宣言」を分離出来る ・コードが短くなったり ・ミスを防止したり(@Nullable)
・ButterKnife の @InjectView ・Support Annotation の @NonNull ・AndroidAnnotations の @UiThread
・Rails の has_many 「する」と「である」を分ける
良い例: ButterKnife の @InjectView
する textView = (TextView) findViewById(R.id.text); である @InjectView(R.id.text) textView;
する runOnUiThread(new Runnable {...}); である @UiThread public void showToast() {..};
さて
Bring your own Annotation!
ツール • AspectJ • java.lang.annotation
初級編 Annotation を普通に使う(AspectJ じゃない)
1. Annotation をつくる(カンタン)
2. 黒魔術
3. 出来た
4. 完成 BananaKnife
中級編 AspectJ でアスペクトを織り込む
1. Annotation をつくる(カンタン)
2. AspectJ で黒魔術
@PotatoTip をつけるだけでトースト
AspectJ の良い例: Hugo
AspectJ の良い例: Hugo あまりに便利なので iOS 版もつくった kaiinui/KILogInjector
一言で? ・Annotation で @Hoge がついたメソッド、フィー ルド、クラスとかを弄れたりする ・AspectJ で処理をフックしてほげほげ、といった 処理がカンタンに書ける。 (▰╹◡╹▰)
きみだけのさいきょう @Annotation をつくろう!
「モデルと API 辛い」周りの話がしたかった あと自分で作るとかどうでもいいので既にある Annotation をまず使おう (▰╹◡╹▰) 最後に