Your SlideShare is downloading. ×
0
XKE - Google Guava
XKE - Google Guava
XKE - Google Guava
XKE - Google Guava
XKE - Google Guava
XKE - Google Guava
XKE - Google Guava
XKE - Google Guava
XKE - Google Guava
XKE - Google Guava
XKE - Google Guava
XKE - Google Guava
XKE - Google Guava
XKE - Google Guava
XKE - Google Guava
XKE - Google Guava
XKE - Google Guava
XKE - Google Guava
XKE - Google Guava
XKE - Google Guava
XKE - Google Guava
XKE - Google Guava
XKE - Google Guava
XKE - Google Guava
XKE - Google Guava
XKE - Google Guava
XKE - Google Guava
XKE - Google Guava
XKE - Google Guava
XKE - Google Guava
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

XKE - Google Guava

1,189

Published on

Google Guava overview. …

Google Guava overview.
Given at Xebia during XKE (March 3rd, 2011).

Published in: Technology, Business
0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,189
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
5
Comments
0
Likes
4
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Introduction to Google Guava Romain MATON Google Guava XKE Avril 2011 www.xebia.fr / blog.xebia.fr 1
  • 2. What is Google Guava ?  An API, now in r08  com.google.common.annotations  com.google.common.base  com.google.common.collect  com.google.common.io  com.google.common.net  com.google.common.primitives  com.google.common.util.concurrent www.xebia.fr / blog.xebia.fr 2
  • 3. What is Google Guava ?  An API, now in r08  com.google.common.annotations  com.google.common.base  com.google.common.collect  com.google.common.io  com.google.common.net  com.google.common.primitives  com.google.common.util.concurrent www.xebia.fr / blog.xebia.fr 3
  • 4. And in base and collect ?  Objects  Strings, Ints  Charsets  Preconditions  Joiner, Splitter  Lists, Sets  ListMultiMap  Iterables  Functions  Predicates  Ordering  Example www.xebia.fr / blog.xebia.fr 4
  • 5. Base : Objects www.xebia.fr / blog.xebia.fr 5
  • 6. Base : Objects www.xebia.fr / blog.xebia.fr 6
  • 7. Base : Strings www.xebia.fr / blog.xebia.fr 7
  • 8. Primitives : Ints www.xebia.fr / blog.xebia.fr 8
  • 9. Base : Charsets www.xebia.fr / blog.xebia.fr 9
  • 10. Base : Preconditions // Will throw NPE Preconditions.checkNotNull(lisa.getId()); // Will throw ILE Preconditions.checkState(!lisa.isSick()); // Will throw ILE Preconditions.checkArgument(lisa.getAddress() != null, "No description for customer with id %s",lisa.getId()); www.xebia.fr / blog.xebia.fr 10
  • 11. Base : Joiner www.xebia.fr / blog.xebia.fr 11
  • 12. Base : Splitter www.xebia.fr / blog.xebia.fr 12
  • 13. Question ? ",a,,b,".split(",") returns... (a) "", "a", "", "b", "" (b) null, "a", null, "b", null (c) "a", null, "b" (d) "a", "b" (e) None of the above www.xebia.fr / blog.xebia.fr 13
  • 14. Answer ! ",a,,b,".split(",") returns... (a) "", "a", "", "b", "" (b) null, "a", null, "b", null (c) "a", null, "b" (d) "a", "b" (e) None of the above "", "a", "", "b" www.xebia.fr / blog.xebia.fr 14
  • 15. Puzzler www.xebia.fr / blog.xebia.fr 15
  • 16. Base : Splitter www.xebia.fr / blog.xebia.fr 16
  • 17. Collect : Iterables  cycle(iterable)  concat(Iterable... inputs)  any(iterable, predicate)  all(iterable, predicate)  filter(iterable, predicate)  find(iterable, predicate)  transform(iterable, function)  frequency(iterable, element)  get(iterable, index, default)  ... www.xebia.fr / blog.xebia.fr 17
  • 18. Collect : Iterables www.xebia.fr / blog.xebia.fr 18
  • 19. Collect : Iterables www.xebia.fr / blog.xebia.fr 19
  • 20. Collect : Lists  asList(E, E[])  newArrayList()  newArrayList(E...)  newLinkedList()  newLinkedList(iterable)  partition(iterable, predicate)  transform(iterable, predicate)  ... www.xebia.fr / blog.xebia.fr 20
  • 21. Collect : Lists www.xebia.fr / blog.xebia.fr 21
  • 22. Collect : Sets www.xebia.fr / blog.xebia.fr 22
  • 23. Collect : ListMultiMap www.xebia.fr / blog.xebia.fr 23
  • 24. Base : Functions  compose(Function<B, C>, Function<A, B>) => Function<A, C>  constant(E)  forPredicate(predicate<T>) => Function<T, Boolean>  identity  toStringFunction www.xebia.fr / blog.xebia.fr 24
  • 25. Base : Predicates  alwaysTrue()  alwaysFalse()  contains(pattern)  in(collection)  isNull()  notNull()  not(predicate)  and(...)  or(...) www.xebia.fr / blog.xebia.fr 25
  • 26. Base : Predicates www.xebia.fr / blog.xebia.fr 26
  • 27. Collect : Ordering  sortedCopy(iterable)  onResultOf(function)  nullsFirst()  nullsLast()  usingToString()  natural()  from(comparator)  isOrdered(iterable)  compare(a, b) www.xebia.fr / blog.xebia.fr 27
  • 28. Collect : Ordering www.xebia.fr / blog.xebia.fr 28
  • 29. Last example www.xebia.fr / blog.xebia.fr 29
  • 30. Last example www.xebia.fr / blog.xebia.fr 30

×