Getting Started with Google Guava
Write more robust code that is easier to read and maintain, Learn how to use Preconditions to prevent and find errors faster, Shows how Guava Collections can make working with Java Collections a breezeGetting Started with Google GuavaCopyright o 2013 Packt PublishingAll rights reserved. No part of this book may be reproduced, stored in a retrievalsystem, or transmitted in any form or by any means, without the prior writtenpermission of the publisher, except in the case of brief quotations embedded incritical articles or reviewsEvery effort has been made in the preparation of this book to ensure the accuracyof the information presented. However, the information contained in this book issold without warranty cither express or implied. Neither the author, nor PacktPublishing and its dealers and distributors will be held liable for any damagescaused or alleged to be caused directly or indirectly by this bookPackt Publishing has endeavored to provide trademark information about all of thecompanies and products mentioned in this book by the appropriate use of capitalsHowever, Packt Publishing cannot guarantee the accuracy of this informationFirst published: August 2013Production reference: 1080813Published by Packt Publishing ltdLivery place35 Livery streetBirmingham B3 2PB, UKIsBN9781783280155www.packtpubCoverImagebySureshMogre(sureshmogre.99@gmail.com)CreditsAuthorProject CoordinatorBill BejeckEsha thankReviewersProofreaderJohn drumMario cecereDavid slettenAcquisition EditorMonica Ajmera MehtaProduction CoordinatorCommissioning EditorNitesh thakurPoonam JainCover workTechnical EditorsNitesh thakurNite ShettyAniruddha vanageCopy EditorsGladson monterioInsiya morbiwalaAditya NairAlfida paivaLaxmi subramanianabout the authorBill Bejeck is a senior software engineer with 10 years experience across a widerange of projects. Currently he is working on the storage and analysis of financialdata using hadoop He has a b a in economics from the university of marylandand an M S in Information Systems from Johns Hopkins University. Bill also enjoysblogging at ht=p: //codingjunkienetI would like to thank my wife Beth for her support, encouragement,and patience, making my work on this book possible (not to mentionmaking life easy for me overall!), and my children Allison, Emilyand Brady for their unconditional love and support, and the joy theybring to my life every daAbout the reviewersJohn Drum is a bicoastal software engineer with over 20 years of experiencein industries ranging from e-commerce to financial servicesDavid Sletten is a software engineer at Near Infinity in northern VirginiaHe probably would have learned quite a few things from the author if Bill hadnot left the companyWww. Packtpub. comSupport files, eBooks, discount offers and moreYoumightwanttovisitwww.Packtpub.comforsupportfilesanddownloadsrelatedtookyour booDid you know that Packt offers e Book versions of every book published, with PDF andepubfilesavailableYoucanupgradetotheebookversionatwww.Packtpub.comandas a print book customer, you are entitled to a discount on the eBook copy. Get in touchwith us at service@packtpub com for more detailsAtwww.packtpub.comyoucanalsoreadacollectionoffreetechnicalarticlessignupforarange of free newsletters and receive exclusive discounts and offers on packt books and eBooksPPPACKTLIBhttp://packtlib.Packtpub.comDo you need instant solutions to your it questions? Packtlib is packt's online digital booklibrary. Here, you can access, read and search across Packt' s entire library of booksWhy Subscribe?Fully searchable across every book published by PacktCopy and paste, print and bookmark contentOn demand and accessible via web browserFree Access for packt account holdersIfyouhaveanaccountwithPacktatwww.Packtpub.comyoucanusethistoaccessPacktLib today and view nine entirely free books. Simply use your login credentials forimmediate accessTable of contentsPrefaceChapter 1: Getting StartedIntroducing Google GuavaThe case for using guavaWhat is this book about?Installing GuavaUsing Guava with Maven or gradle5566778Getting the source code for the bookSummary10Chapter 2: Basic Guava UtilitiesUsing the joiner class12Time for a review14Using the splitter class14Time for a reviewWorking with strings in Guava66Using the charsets classUsing the Strings class18Using the Char Matcher class19Using the Preconditions class20object utilitiesGetting help with the toString methodChecking for null valuesGenerating hash codes23Implementing compare ToSummary25Table of contentsChapter 3: Functional Programming with Guava27Using the Function interface28Guidelines for using the Function interface29Using the Functions classUsing the Functions. forMap method30Using the Functions. compose method30Using the Predicate interface32An example of the predicate interface32Using the Predicates class33Using the Predicates and method33Using the Predicates or method34Using the Predicates not method34Using the Predicates compose method34Using the Supplier interface35An example of the Supplier interface35Using the Suppliers class36Using the Suppliers. memoize method37Using the Suppliers. memoize WithExpiration method37Summary38Chapter 4: Working with Collections39The fluentlterable class40Using the Fluentlterable. filter method40Using the fluentiterable transform method41Lists42Using the Lists partition method42Sets42Using the sets. difference method43Using the Sets. symmetricDifference method43Using the Sets intersection method43Using the Sets. union method44Maps44Using the maps. asAp method OdUsing the Maps. uniquelndex methe4545Transforming maps46Multimaps46ArrayListMultimap46Hash Multimap48BiMap49Using the BiMap force Put method49Using the BiMap inverse method50lITable of ContentsTable50Table operations51Table views52Range52Ranges with arbitrary comparable objects53Immutable collections54Creating immutable collection instances54Ordering55Creating an ordering instance55Reverse sorting55Accounting for nu56Secondary sorting56Retrieving minimum and maximum values57Summar58Chapter 5: Concurrency59Synchronizing threads60Monitor61Monitor explained62Monitor best practiceDifferent monitor access methods62Listenable Future63Obtaining a listenable Future interface64Future Callback65Using the FutureCallback65Settable Future66AsyncFunction67Future Fallback68Futures69Asynchronous Transforms69Applying FutureFallbacks69Rate Limiter70SummaryChapter 6: Guava CacheMapMaker74Guava cachesCache74Loading Cache76Loading values76Refreshing values in the cache76Cache Builder77Cache Spec[ⅲi
下载地址
用户评论