for Java Google Core Libraries An Overview of Guava

For Java Google Core Libraries An Overview Of Guava-Free PDF

  • Date:17 Nov 2020
  • Views:4
  • Downloads:0
  • Pages:63
  • Size:921.87 KB

Share Pdf : For Java Google Core Libraries An Overview Of Guava

Download and Preview : For Java Google Core Libraries An Overview Of Guava


Report CopyRight/DMCA Form For : For Java Google Core Libraries An Overview Of Guava


Transcription:

What s Guava,Free open source library for Java GWT Android. 14 packages chock full of utility classes and methods. annotations io,collect primitives,collect testing reflect. eventbus testing,hash util concurrent,These packages live under com google common. Google Confidential and Proprietary,Where does it come from. We are the Java Core Libraries Team at Google,What do we do.
Why do we release Guava,It s a junk drawer then,Why are you here talking about it. Google Confidential and Proprietary,Actual User Quotes. On any new Java project the first thing I do is add a. dependency to Guava I just know I m going to need it. Writing Java without Guava was like coding with one hand. tied behind my back,Guava makes Java bearable again. We happen to think Java is more than bearable anyway. but still Guava makes writing Java programs easier. paraphrased But I swear people really said these things Honest. Google Confidential and Proprietary,About this presentation. Google Confidential and Proprietary,com google common base.
Google Confidential and Proprietary,String joining. Who here has ever written this utility,public class StringUtil. public static String join,String separator Iterable String pieces. any of 5 common implementations goes here,Google Confidential and Proprietary. String joining 2,But what about all the variations.
What to do with nulls, skip over them skip but leave separator substitute. null or some other string Just die,Joining an Iterable Iterator varargs array. Return a String or append to an Appendable, We could be looking at 18 to 48 different methods here. To cover all these bases we made Joiner,return Joiner on. join one null two three,Google Confidential and Proprietary.
Joiner what s going on here,To get a Joiner,static Joiner on String. static Joiner on char,To get an altered Joiner from that. Joiner skipNulls,Joiner useForNull String,To actually join stuff. String join Itera,String join Object,Appendable appendTo Appendable Itera. Appendable appendTo Object,Google Confidential and Proprietary.
Similar But in the other direction,return Splitter on. omitEmptyStrings,split Harry Ron Hermione,returns Harry Ron Hermione. These classes use what we tentatively call the Utility. Object pattern,Google Confidential and Proprietary. CharMatcher motivation, Once upon a time we had a StringUtil class Soon it was. overflowing with static methods,allAscii collapse collapseControlChars.
collapseWhitespace indexOfChars lastIndexNotOf, numSharedChars removeChars removeCrLf replaceChars. retainAllChars strip stripAndCollapse,stripNonDigits. Each dealt with two orthogonal concerns,a what does it consider a matching character. b what do we do with these matching characters,One static method per combination would not scale. Google Confidential and Proprietary,CharMatcher,Once again we use the Utility Object pattern.
A CharMatcher instance represents the set of matching. characters part a Methods on that instance provide the. operations part b,34 425 becomes 34425,String sanitized. CharMatcher anyOf,removeFrom input,Separates configuration from processing. Google Confidential and Proprietary,Getting a CharMatcher. Use a predefined constant examples,CharMatcher WHITESPACE Unicode. CharMatcher ASCII,CharMatcher ANY,Use a factory method examples.
CharMatcher is x,CharMatcher isNot,CharMatcher oneOf aeiou. CharMatcher inRange a z,or inRange A Z negate,Or subclass CharMatcher implement matches char. Google Confidential and Proprietary,Using your new CharMatcher. boolean matchesAllOf CharSequence,boolean matchesAnyOf CharSequence. boolean matchesNoneOf CharSequence,int indexIn CharSequence int.
int lastIndexIn CharSequence int,int countIn CharSequence. String removeFrom CharSequence,String retainFrom CharSequence. String trimFrom CharSequence,String trimLeadingFrom CharSequence. String trimTrailingFrom CharSequence,String collapseFrom CharSequence char. String trimAndCollapseFrom CharSequence char,String replaceFrom CharSequence char.
Google Confidential and Proprietary,CharMatcher last. Putting it back together to scrub an id number you might. String seriesId,CharMatcher DIGIT or CharMatcher is. retainFrom input, In a loop Move the definition above or to a constant. static final CharMatcher ID CHARS,CharMatcher DIGIT or CharMatcher is. String id SERIES ID CHARS retainFrom input,Google Confidential and Proprietary.
Google Confidential and Proprietary Actual User Quotes On any new Java project the first thing I do is add a dependency to Guava I just know I m going to need it Writing Java without Guava was like coding with one hand tied behind my back Guava makes Java bearable again We happen to think Java is more than bearable

Related Books