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
KotlinでRetrofitを使いやすくするちょっとした工夫
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Shinya Kumagai
February 26, 2016
Programming
590
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
KotlinでRetrofitを使いやすくするちょっとした工夫
2016/02/26 Kotlin Birthday Party #jkug
Shinya Kumagai
February 26, 2016
Other Decks in Programming
See All in Programming
Datadog × OpenTelemetry 入門と実践のあいだ
kn_to_maxpno
1
150
ふつうのFeature Flag実践入門
irof
7
3.7k
The Arts and Crafts of Work in the AI Era — Toward Mastery in Software Development
kuranuki
1
750
エージェンティックRAGにAWSで入門しよう!
har1101
8
1.4k
代数的データ型って何が嬉しいの? #frontend_phpcon_do
kajitack
8
3.4k
AIで効率化できた業務・日常
ochtum
0
130
スマートグラスで並列バイブコーディング
hyshu
0
130
AIチームを指揮するOSS「TAKT」活用術 / How to Use “TAKT,” an OSS Tool for Orchestrating AI Teams
nrslib
6
880
JJUG CCC 2026 Spring: JSpecify で実現する Kotlin フレンドリーな Java API 設計
ternbusty
1
160
Skillsは効率化、Agentsは"自分の拡張"——Builder時代のエージェント編成(CC Night 2026)
wemra
1
120
不変条件と整合性境界—ビジネスが決める設計判断と実現パターン / Invariants and Consistency Boundaries
nrslib
13
3.6k
Oxlintのカスタムルールの現況
syumai
6
1.1k
Featured
See All Featured
Navigating Weather and Climate Data
rabernat
0
220
New Earth Scene 8
popppiees
3
2.3k
How STYLIGHT went responsive
nonsquared
100
6.2k
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
360
The Invisible Side of Design
smashingmag
302
52k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
sira's awesome portfolio website redesign presentation
elsirapls
0
280
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.8k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
330
Docker and Python
trallard
47
3.9k
[SF Ruby Conf 2025] Rails X
palkan
2
1.1k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
Transcript
KotlinͰRetrofitΛ ͍͘͢͢Δ ͪΐͬͱͨ͠ 2015/02/26 Shinya Kumagai(@droibit)
About Me • Shinya Kumagai (۽୩ ৻) 25ࡀ • Twitter,
GitHub - @droibit • λΦιϑτΣΞגࣜձࣾ
Happy Birthday Kotlin!! (ɾ8ɾ)
֓ཁ • connpass API ༻ͷRetrofit ServiceΛର - JavaͰఆٛ͞ΕͨService - KotlinͰServiceΛఆٛ
KotlinͰ͏ͱ͖ͷͪΐͬͱͨ͠ IUUQTRVBSFHJUIVCJPSFUSPpU
Connpass API • ݕࡧΫΤϦ - keyword … Ωʔϫʔυ - order
… ݁Ռͷදࣔॱ (1:ߋ৽ॱ, 2…) - ymd … Πϕϯτ։࠵ (yyyymmdd) • ϨεϙϯεJSON ?keyword=kotlin&order=1&ymd=20150226 IUUQDPOOQBTTDPNBCPVUBQJ
JavaͰఆٛ͞ΕͨService public interface ConnpassService { // ※ @Get, @Query লུ
Response searchEvent(@NonNull String keyword, @Nullable Integer order, @Nullable String ymd); } // શΫΤϦΛࢦఆ service.searchEvent(“kotlin”, 1, "20160226"); // ΩʔϫʔυͷΈͷ߹ service.searchEvent("kotlin", null, null);
// ֦ுؔΛఆٛ + σϑΥϧτҾ fun ConnpassService.searchEventExt( keyword: String, order: Order?
= null, ymd: String? = null ) = searchEvent(keyword, order?.index, ymd) // ݕࡧ݁Ռͷදࣔॱͷྻڍମ enum class Order(val index: Int) { UPDATE(1), EVENT(2), NEW(3); override fun toString() = "$index" } // ΩʔϫʔυҎ֎ඞཁͳΫΤϦͷΈ service.searchEventExt("kotlin", order = Order.UPDATE) KotlinͰվળ
KotlinͰServiceΛఆٛ interface ConnpassService { // ※ @Get,@Query লུ fun searchEvent(keyword:
String, order: Order? = null, ymd: String? = null): Response } // ΩʔϫʔυҎ֎ඞཁͳΫΤϦͷΈ service.searchEvent(“kotlin”, order = Order.UPDATE)
// ༻్ʹ߹Θ֦ͤͨுؔΛఆٛ fun ConnpassService.searchEvent( keyword: String, order: Order? = null,
ymd: Date? = null ) = searchEvent(keyword, order, format(ymd)) // DateΛ yyyymmdd ϑΥʔϚοτͷStringʹม fun format(date: Date?): String? = … // ։࠵ʹDateΦϒδΣΫτΛࢦఆ service.searchEvent(“kotlin", ymd = dateFromTimesSquare) վળྫ
·ͱΊ • ൚༻తͳΠϯλʔϑΣʔεʹͳΔ͍͋ɺ σϑΥϧτҾɺ֦ுؔͰγϯϓϧͳ Service fabricͷΑ͏ʹͳΒͳ͍Α͏ʹؾΛ͚ͭ·͠ΐ͏
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠