{"id":3140,"date":"2025-12-24T10:00:32","date_gmt":"2025-12-24T15:00:32","guid":{"rendered":"https:\/\/www.mymiller.name\/wordpress\/?p=3140"},"modified":"2025-12-24T10:00:32","modified_gmt":"2025-12-24T15:00:32","slug":"listutils-iterate","status":"publish","type":"post","link":"https:\/\/www.mymiller.name\/wordpress\/lists\/listutils-iterate\/","title":{"rendered":"ListUtils.iterate()"},"content":{"rendered":"\n<p>Ever have one of those objects that want to give you an iterator and don&#8217;t have a method for getting it as a list?  Well created another new method for my ListUtils class.  ListUtils::iteratre()  it takes an iterator and converts it into a List for you.  <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>    \/**\r\n     * Convert and Iterator of E to a List of E\r\n     * @param iterator Iterator of E to convert\r\n     * @param &lt;E> Type to iterate over\r\n     * @return List of E converted.\r\n     *\/\r\n    public static &lt;E> List&lt;E> iterate(Iterator&lt;E> iterator) {\r\n        Iterable&lt;E> iterable = () -> iterator;\r\n        return  StreamSupport.stream(iterable.spliterator(), false).collect(Collectors.toList());\r\n    }<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ever have one of those objects that want to give you an iterator and don&#8217;t have a method for getting it as a list? Well created another new method for my ListUtils class. ListUtils::iteratre() it takes an iterator and converts it into a List for you.<\/p>\n","protected":false},"author":1,"featured_media":3141,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[455],"tags":[69],"series":[287],"class_list":["post-3140","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-lists","tag-java-2","series-listutils"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2022\/01\/castles-ga8e4bd9a6_640.jpg?fit=640%2C360&ssl=1","jetpack-related-posts":[{"id":3179,"url":"https:\/\/www.mymiller.name\/wordpress\/java_extra\/understanding-json-data-processing-with-java-exploring-the-jsonfieldprocessor-class\/","url_meta":{"origin":3140,"position":0},"title":"Understanding JSON Data Processing with Java: Exploring the JsonFieldProcessor Class","author":"Jeffery Miller","date":"January 15, 2026","format":false,"excerpt":"In today's digital era, data comes in various formats, with JSON (JavaScript Object Notation) being one of the most popular for representing structured data. Manipulating and processing JSON data efficiently is crucial for many software applications, from web development to data analysis. In this article, we'll delve into the workings\u2026","rel":"","context":"In &quot;Java Extras&quot;","block_context":{"text":"Java Extras","link":"https:\/\/www.mymiller.name\/wordpress\/category\/java_extra\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2024\/04\/data-7798787_640.png?fit=640%2C640&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2024\/04\/data-7798787_640.png?fit=640%2C640&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2024\/04\/data-7798787_640.png?fit=640%2C640&ssl=1&resize=525%2C300 1.5x"},"classes":[]},{"id":3225,"url":"https:\/\/www.mymiller.name\/wordpress\/java_extra\/caching-objects\/","url_meta":{"origin":3140,"position":1},"title":"Caching Objects","author":"Jeffery Miller","date":"December 24, 2025","format":false,"excerpt":"Sometimes you need to maintain a large number of objects in memory. If it is strings you may want to take a look at StringCache, which is based on my Cache class presented here. Now the Cache workers simply call create an instance of Cache: Cache<Person> peopleCache = new Cache<>();\u2026","rel":"","context":"In &quot;Java Extras&quot;","block_context":{"text":"Java Extras","link":"https:\/\/www.mymiller.name\/wordpress\/category\/java_extra\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2022\/02\/geocache-gd1a671d59_640.jpg?fit=640%2C360&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2022\/02\/geocache-gd1a671d59_640.jpg?fit=640%2C360&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2022\/02\/geocache-gd1a671d59_640.jpg?fit=640%2C360&ssl=1&resize=525%2C300 1.5x"},"classes":[]},{"id":2459,"url":"https:\/\/www.mymiller.name\/wordpress\/java_tips\/not-returning-null\/","url_meta":{"origin":3140,"position":2},"title":"Not Returning Null","author":"Jeffery Miller","date":"December 23, 2025","format":false,"excerpt":"We all have done it, in fact, I'm in the process of changing my APIs over to not do.\u00a0 Returning NULL for a return type.\u00a0 After doing some work with streams, I see that return NULL often adds additional complexity to the code.\u00a0 In this article, we are going to\u2026","rel":"","context":"In &quot;Java Tips&quot;","block_context":{"text":"Java Tips","link":"https:\/\/www.mymiller.name\/wordpress\/category\/java_tips\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2018\/11\/paper-3204064_640.jpg?fit=640%2C372&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2018\/11\/paper-3204064_640.jpg?fit=640%2C372&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2018\/11\/paper-3204064_640.jpg?fit=640%2C372&ssl=1&resize=525%2C300 1.5x"},"classes":[]},{"id":2736,"url":"https:\/\/www.mymiller.name\/wordpress\/lists\/listutils-safe\/","url_meta":{"origin":3140,"position":3},"title":"ListUtils.safe()","author":"Jeffery Miller","date":"December 24, 2025","format":false,"excerpt":"Sometimes you need to guarantee a list is safe to use. A simple method can make sure your safe to use the list, or have an empty list that would be safe for use. \/** * Guarantees a list will be safe to use, even if null. * @param list\u2026","rel":"","context":"In &quot;Lists&quot;","block_context":{"text":"Lists","link":"https:\/\/www.mymiller.name\/wordpress\/category\/lists\/"},"img":{"alt_text":"Keeping Containers Safe","src":"https:\/\/i0.wp.com\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2020\/04\/rappelling-755399_640.jpg?fit=640%2C480&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2020\/04\/rappelling-755399_640.jpg?fit=640%2C480&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2020\/04\/rappelling-755399_640.jpg?fit=640%2C480&ssl=1&resize=525%2C300 1.5x"},"classes":[]},{"id":2739,"url":"https:\/\/www.mymiller.name\/wordpress\/lists\/listutils-page\/","url_meta":{"origin":3140,"position":4},"title":"ListUtils Page","author":"Jeffery Miller","date":"December 24, 2025","format":false,"excerpt":"Ever have a list, that you need to paginate through? I certainly have, I created a simple method to ListUtils to make it easier. \/** * Performs pagination on the List, returning the indicated page of elements, or an empty ist. * @param list List to paginate * @param pageSize\u2026","rel":"","context":"In &quot;Lists&quot;","block_context":{"text":"Lists","link":"https:\/\/www.mymiller.name\/wordpress\/category\/lists\/"},"img":{"alt_text":"Pick a page","src":"https:\/\/i0.wp.com\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2020\/04\/books-1245690_640.jpg?fit=640%2C426&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2020\/04\/books-1245690_640.jpg?fit=640%2C426&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2020\/04\/books-1245690_640.jpg?fit=640%2C426&ssl=1&resize=525%2C300 1.5x"},"classes":[]},{"id":2717,"url":"https:\/\/www.mymiller.name\/wordpress\/lists\/listutils-isempty-notempty\/","url_meta":{"origin":3140,"position":5},"title":"ListUtils isEmpty() &#038; notEmpty()","author":"Jeffery Miller","date":"December 23, 2025","format":false,"excerpt":"Standard isEmpty() and notEmpty() methods for a ListUtils class. Nothing fancy, just simple methods and functionality. See the entire ListUtils series.","rel":"","context":"In &quot;Lists&quot;","block_context":{"text":"Lists","link":"https:\/\/www.mymiller.name\/wordpress\/category\/lists\/"},"img":{"alt_text":"empty container?","src":"https:\/\/i0.wp.com\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2020\/04\/soda-4017612_640.jpg?fit=640%2C429&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2020\/04\/soda-4017612_640.jpg?fit=640%2C429&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.mymiller.name\/wordpress\/wp-content\/uploads\/2020\/04\/soda-4017612_640.jpg?fit=640%2C429&ssl=1&resize=525%2C300 1.5x"},"classes":[]}],"jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.mymiller.name\/wordpress\/wp-json\/wp\/v2\/posts\/3140","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mymiller.name\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.mymiller.name\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.mymiller.name\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mymiller.name\/wordpress\/wp-json\/wp\/v2\/comments?post=3140"}],"version-history":[{"count":1,"href":"https:\/\/www.mymiller.name\/wordpress\/wp-json\/wp\/v2\/posts\/3140\/revisions"}],"predecessor-version":[{"id":3142,"href":"https:\/\/www.mymiller.name\/wordpress\/wp-json\/wp\/v2\/posts\/3140\/revisions\/3142"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.mymiller.name\/wordpress\/wp-json\/wp\/v2\/media\/3141"}],"wp:attachment":[{"href":"https:\/\/www.mymiller.name\/wordpress\/wp-json\/wp\/v2\/media?parent=3140"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.mymiller.name\/wordpress\/wp-json\/wp\/v2\/categories?post=3140"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.mymiller.name\/wordpress\/wp-json\/wp\/v2\/tags?post=3140"},{"taxonomy":"series","embeddable":true,"href":"https:\/\/www.mymiller.name\/wordpress\/wp-json\/wp\/v2\/series?post=3140"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}