際際滷

際際滷Share a Scribd company logo
Guavaの奮べ圭
2013/04/25
防云 初
Guavaとは
Javaの慌宥I尖をまとめたライブラリ。
麼にGoogleのエンジニアが_kしています。
Apache Commonsがライバル。
Guavaの蒙
? ジェネリクス
? K佩I尖のC嬬がN源
? fluent interface
? 辛i來が互い
? Apache Commonsと穩耽
GuavaのC嬬
? com.google.common.annotations
? com.google.common.base
? com.google.common.cache
? com.google.common.collect
? com.google.common.eventbus
? com.google.common.io
? com.google.common.math
? com.google.common.net
? com.google.common.primitives
? com.google.common.reflect
? com.google.common.util.concurrent
GuavaのC嬬
? com.google.common.annotations
? com.google.common.base
? com.google.common.cache
? com.google.common.collect
? com.google.common.eventbus
? com.google.common.io
? com.google.common.math
? com.google.common.net
? com.google.common.primitives
? com.google.common.reflect
? com.google.common.util.concurrent
collect
? Lists
List<String> list1 = Lists.newArrayList();
List<String> list2 = Lists.newArrayList(^hoge ̄,  ̄fuga ̄);
final List<String> list3 = ImmutableList.of(^tako ̄,  ̄ika ̄);
collect
? Lists
List<User> userList = getUserList();
// ^taro ̄, ̄hanako ̄
List<String> idList = Lists.transform(userList,
new Function<User, String>() {
@Override
public String apply(User user) {
return user.getId();
}
});
collect
? MultiMap
ListMultimap<String, String> map = ArrayListMultiMap.create();
map.put(^pigg ̄, ^life ̄);
map.put(^pigg ̄,  ̄cafe ̄);
map.put(^card ̄,  ̄gf ̄);
// ^life ̄, ̄cafe ̄
List<String> list = map.get(^pigg ̄);
base
? Joiner
List<String> list = Lists.newArrayList(^hoge ̄, null, ^fuga ̄);
// ^hoge,fuga ̄
String join = Joiner.on(^, ̄).skipNulls().join(list);
base
? Splitter
String val = ^apple orange,peach ̄;
CharMatcher matcher = CharMatcher.WHITESPACE
.or(CharMatcher.is(?,?));
// ^apple ̄, ̄orange ̄, ̄peach ̄
Iterable<String> split =
Splitter.on(matcher).omitEmptyStrings().split(val);
base
? Preconditions
Integer val = 10;
Preconditions.checkNotNull(val, ^required. ̄);
Preconditions.checkArgument(val > 10, ^over 10. ̄);
base
? Stopwatch
Stopwatch stopwatch = new Stopwatch().start();
execute();
stopwatch.stop();
// ^elapsed time:12.3ms ̄
log.info(^elapsed time: ̄ + stopwatch);
io
? Files
BufferedReader reader = null;
try {
reader = Files.newReader(
new File(^hoge.txt ̄), Charsets.UTF_8);
} finally {
Closeables.closeQuietly(reader);
}
io
? Files
List<String> lines = Files.readLines(
new File(^fuga.txt ̄), Charsets.UTF_8);
byte[] bytes = Files.toByteArray(new File(^sample.jpg ̄));
util.concurrent
? ListeningFuture
ListeningExecutorService threadPool =
MoreExecutors.listeningDecorator(
Executors.newFixedThreadPool(32));
Callable<String> task = getTask();
ListeningFuture<String> future = theadPool.submit(task);
util.concurrent
? ListeningFuture
Futures.addCallback(future, new FutureCallback<String>() {
@Override
public void onSuccess(String s) {
log.info(^success! result: ̄ + s);
}
@Override
public void onFailure(Throwable throwable) {
log.error(^error! ̄, throwable);
}
});
util.concurrent
? RateLimiter
RateLimiter limiter = RateLimiter.create(100.0);
for (int i = 1; i <= 10000; i++) {
limiter.acquire();
execute();
}
for (byte[] bytes : getBytesList()) {
limiter.acquire(bytes.length);
execute(bytes);
}
まとめ
Guavaを旋喘するとコ`ディングしやすくな
り、
ソ`スの辛i來も鯢呂靴泙后1秬なC嬬がg表
あるので、ぜひ旋喘してみてください。

More Related Content

Recently uploaded (9)

PDF
芦硫 暖, 防和 高. h廠Z崑を楚辛嬬にするためのみ繁垢岑嬬僥氏及4指碧賺а仂浸, 2018.
Matsushita Laboratory
?
PPTX
弼について.pptx .
iPride Co., Ltd.
?
PDF
猟B初AutoPrompt: Eliciting Knowledge from Language Models with Automatically ...
Toru Tamaki
?
PDF
芦硫 暖, 儲旗 圍岻, 防和 高. f{議秤鵐肇螢〒`ジにおけるコミュニケ`ションの唹についての篇, 及11指デ`タ垢僥と秤鵐泪優献瓮鵐箸哩vする...
Matsushita Laboratory
?
PDF
猟B初Unbiasing through Textual Descriptions: Mitigating Representation Bias i...
Toru Tamaki
?
PPTX
Vibe Codingを兵めよう ?Cursorを箭に、ノ`コ`ドでのプログラミング悶Y?
iPride Co., Ltd.
?
PPTX
茶氏_タ`ミナルコマント?秘薦儻堀晒_20250620. pptx. .
iPride Co., Ltd.
?
PDF
Forguncy 10 u瞳古勣Y創 - ノ`コ`ドWebアプリ_kプラットフォ`ム
フォ`ガンシ`
?
PDF
芦硫 暖, 臼翫 誰伏, 防和 高. 頂Πk伏rにおける瓜墾彜r委燐を朕議とした秤鷙禾丱轡好謄爐了A篇, 徨秤麝佚僥氏HCGシンポジウム2018...
Matsushita Laboratory
?
芦硫 暖, 防和 高. h廠Z崑を楚辛嬬にするためのみ繁垢岑嬬僥氏及4指碧賺а仂浸, 2018.
Matsushita Laboratory
?
弼について.pptx .
iPride Co., Ltd.
?
猟B初AutoPrompt: Eliciting Knowledge from Language Models with Automatically ...
Toru Tamaki
?
芦硫 暖, 儲旗 圍岻, 防和 高. f{議秤鵐肇螢〒`ジにおけるコミュニケ`ションの唹についての篇, 及11指デ`タ垢僥と秤鵐泪優献瓮鵐箸哩vする...
Matsushita Laboratory
?
猟B初Unbiasing through Textual Descriptions: Mitigating Representation Bias i...
Toru Tamaki
?
Vibe Codingを兵めよう ?Cursorを箭に、ノ`コ`ドでのプログラミング悶Y?
iPride Co., Ltd.
?
茶氏_タ`ミナルコマント?秘薦儻堀晒_20250620. pptx. .
iPride Co., Ltd.
?
Forguncy 10 u瞳古勣Y創 - ノ`コ`ドWebアプリ_kプラットフォ`ム
フォ`ガンシ`
?
芦硫 暖, 臼翫 誰伏, 防和 高. 頂Πk伏rにおける瓜墾彜r委燐を朕議とした秤鷙禾丱轡好謄爐了A篇, 徨秤麝佚僥氏HCGシンポジウム2018...
Matsushita Laboratory
?

Featured (20)

PDF
2024 Trend Updates: What Really Works In SEO & Content Marketing
Search Engine Journal
?
PDF
Storytelling For The Web: Integrate Storytelling in your Design Process
Chiara Aliotta
?
PDF
Artificial Intelligence, Data and Competition C SCHREPEL C June 2024 OECD dis...
OECD Directorate for Financial and Enterprise Affairs
?
PDF
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
SocialHRCamp
?
PDF
2024 State of Marketing Report C by Hubspot
Marius Sescu
?
PDF
Everything You Need To Know About ChatGPT
Expeed Software
?
PDF
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
?
PDF
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
?
PDF
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
?
PDF
Skeleton Culture Code
Skeleton Technologies
?
PDF
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
?
PDF
Content Methodology: A Best Practices Report (Webinar)
contently
?
PPTX
How to Prepare For a Successful Job Search for 2024
Albert Qian
?
PDF
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
?
PDF
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
?
PDF
5 Public speaking tips from TED - Visualized summary
SpeakerHub
?
PDF
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
?
PDF
Getting into the tech field. what next
Tessa Mero
?
PDF
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
?
PDF
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
?
2024 Trend Updates: What Really Works In SEO & Content Marketing
Search Engine Journal
?
Storytelling For The Web: Integrate Storytelling in your Design Process
Chiara Aliotta
?
Artificial Intelligence, Data and Competition C SCHREPEL C June 2024 OECD dis...
OECD Directorate for Financial and Enterprise Affairs
?
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
SocialHRCamp
?
2024 State of Marketing Report C by Hubspot
Marius Sescu
?
Everything You Need To Know About ChatGPT
Expeed Software
?
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
?
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
?
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
?
Skeleton Culture Code
Skeleton Technologies
?
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
?
Content Methodology: A Best Practices Report (Webinar)
contently
?
How to Prepare For a Successful Job Search for 2024
Albert Qian
?
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
?
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
?
5 Public speaking tips from TED - Visualized summary
SpeakerHub
?
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
?
Getting into the tech field. what next
Tessa Mero
?
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
?
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
?
Ad

赫顎温厩温の胆龍しい奮へ?圭