I blame the state of debuggers more so than lambdas. I've yet to see a Java debugger that can properly handle any sort of fluent DSL, and lambdas make fluent DSLs far more common now.
On 29 January 2017 at 20:45, Rob Tompkins <chtom...@gmail.com> wrote: > > > > On Jan 29, 2017, at 9:24 PM, Gary Gregory <garydgreg...@gmail.com> > wrote: > > > > I know someone would reply with some Java 8 lamba... but that will never > be > > as easy to ready as a method name like isEmpty or hasSomething... > > > > At my day job a bunch of folks got giddy over the new java 8 functionality > and ended up writing a ton of unreadable non-debugable code. So, I > definitely agree with this sentiment. > > -Rob > > > > Gary > > > >> On Sat, Jan 28, 2017 at 2:33 PM, Matt Benson <gudnabr...@gmail.com> > wrote: > >> > >> Like Bene, this feels a little off to me. Just for argument's sake, > let's > >> look at: > >> > >> Optional.ofNullable(foo).map(Object::toString).filter( > >> StringUtils::isNotBlank).isPresent(); > >> > >> Assuming you're on Java 8, of course. It's a bit long, but not horrible. > >> What about, in a Java 8-compatible version of [lang], an > >> Optionals/OptionalUtils class? > >> > >> public class OptionalUtils { > >> > >> public static Optional<String> toString(Object o) { > >> return map(o, Object::toString); > >> } > >> > >> static <T, R> Optional<R> map(T t, Function<? super T, ? extends R> > fn) { > >> return Optional.ofNullable(t).map(fn); > >> } > >> } > >> > >> Then your test could be shortened to: > >> > >> OptionalUtils.toString(foo).filter(StringUtils:: > isNotBlank).isPresent(); > >> > >> Just thinking "out loud", > >> Matt > >> > >> On Sat, Jan 28, 2017 at 11:08 AM, Gary Gregory <garydgreg...@gmail.com> > >> wrote: > >> > >>> If you look at the link Matt provided, that handles arrays and > >> collection, > >>> but not Object.toString() > >>> > >>> Gary > >>> > >>> On Jan 28, 2017 1:13 AM, "Benedikt Ritter" <brit...@apache.org> wrote: > >>> > >>> > >>>> Am 28.01.2017 um 02:53 schrieb Gary Gregory <garydgreg...@gmail.com>: > >>>> > >>>> The simplest examples I have on hand are instances of Path and URI > >> which > >>>> can be built with an empty string. I want to know if these are > "empty". > >>> For > >>>> the app I am now on for example, a Path or null and "" should be > >> treated > >>>> the same. Same for a URI. > >>> > >>> I don’t think it is a good idea to define emptiness based on the return > >>> value of Object.toString(). Consider the following: > >>> > >>> isEmpty(null) -> true > >>> isEmpty(„“) -> true > >>> isEmpty(new URI(„“)) -> true > >>> > >>> But: > >>> > >>> isEmpty(Collections.emptyList()) -> false > >>> isEmpty(new int[0]) -> false > >>> > >>> This is because toString() has nothing to do with emptiness. For this > >>> reason I think it would be better to have explicitly typed method > >> overloads > >>> for the use cases you’re thinking about: > >>> > >>> boolean isEmpty(Path) > >>> boolean isEmpty(URI) > >>> > >>> I’m not sure whether this belong to [lang]. The first looks like it > >> belongs > >>> to [io] while the second would better fit into [net]… > >>> > >>> Benedikt > >>> > >>>> > >>>> Gary > >>>> > >>>>> On Fri, Jan 27, 2017 at 5:37 PM, Matt Sicker <boa...@gmail.com> > wrote: > >>>>> > >>>>> That's an interesting use case, though I've never come across a > >>> toString() > >>>>> implementation that would be affected. Can you go into more detail? > >>>>> > >>>>> On 27 January 2017 at 16:04, Gary Gregory <garydgreg...@gmail.com> > >>> wrote: > >>>>> > >>>>>> _Like_ that except that our Log4j version does not do the case I > >> want: > >>>>>> object.toString(). > >>>>>> > >>>>>> Gary > >>>>>> > >>>>>> On Fri, Jan 27, 2017 at 1:58 PM, Matt Sicker <boa...@gmail.com> > >> wrote: > >>>>>> > >>>>>>> Something like this? > >>>>>>> > >>>>>>> https://github.com/apache/logging-log4j2/blob/master/ > >>>>>>> log4j-core/src/main/java/org/apache/logging/log4j/core/ > >>>>>>> util/Assert.java#L43 > >>>>>>> > >>>>>>> On 27 January 2017 at 15:54, Gary Gregory <garydgreg...@gmail.com> > >>>>>> wrote: > >>>>>>> > >>>>>>>> Hi All, > >>>>>>>> > >>>>>>>> There are certain kinds of objects, _descriptor_ kind of objects > >> that > >>>>>>> would > >>>>>>>> benefit from isEmpty semantics. These kind of objects can describe > >>>>>>> complex > >>>>>>>> command line arguments and other kind of configuration objects. > >>>>>>>> > >>>>>>>> I'd like to add with this pseudo code: > >>>>>>>> > >>>>>>>> boolean isEmpty(Object) { > >>>>>>>> return object == null ? true : isEmpty(object.toString()); > >>>>>>>> } > >>>>>>>> > >>>>>>>> Thoughts? > >>>>>>>> > >>>>>>>> Same idea of isBlank(), isNotEmpty() and so on. > >>>>>>>> > >>>>>>>> Gary > >>>>>>>> > >>>>>>>> -- > >>>>>>>> E-Mail: garydgreg...@gmail.com | ggreg...@apache.org > >>>>>>>> Java Persistence with Hibernate, Second Edition > >>>>>>>> <https://www.amazon.com/gp/product/1617290459/ref=as_li_ > >>>>>>>> tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1617290459& > >>>>>>>> linkCode=as2&tag=garygregory-20&linkId= > >>>>> cadb800f39946ec62ea2b1af9fe6a2 > >>>>>> b8> > >>>>>>>> > >>>>>>>> <http:////ir-na.amazon-adsystem.com/e/ir?t= > >>>>> garygregory-20&l=am2&o=1&a= > >>>>>>>> 1617290459> > >>>>>>>> JUnit in Action, Second Edition > >>>>>>>> <https://www.amazon.com/gp/product/1935182021/ref=as_li_ > >>>>>>>> tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182021& > >>>>>>>> linkCode=as2&tag=garygregory-20&linkId= > >>>>> 31ecd1f6b6d1eaf8886ac902a24de4 > >>>>>>> 18%22 > >>>>>>>>> > >>>>>>>> > >>>>>>>> <http:////ir-na.amazon-adsystem.com/e/ir?t= > >>>>> garygregory-20&l=am2&o=1&a= > >>>>>>>> 1935182021> > >>>>>>>> Spring Batch in Action > >>>>>>>> <https://www.amazon.com/gp/product/1935182951/ref=as_li_ > >>>>>>>> tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182951& > >>>>>>>> linkCode=%7B%7BlinkCode%7D%7D&tag=garygregory-20&linkId=%7B% > >>>>>>>> 7Blink_id%7D%7D%22%3ESpring+Batch+in+Action> > >>>>>>>> <http:////ir-na.amazon-adsystem.com/e/ir?t= > >>>>> garygregory-20&l=am2&o=1&a= > >>>>>>>> 1935182951> > >>>>>>>> Blog: http://garygregory.wordpress.com > >>>>>>>> Home: http://garygregory.com/ > >>>>>>>> Tweet! http://twitter.com/GaryGregory > >>>>>>>> > >>>>>>> > >>>>>>> > >>>>>>> > >>>>>>> -- > >>>>>>> Matt Sicker <boa...@gmail.com> > >>>>>>> > >>>>>> > >>>>>> > >>>>>> > >>>>>> -- > >>>>>> E-Mail: garydgreg...@gmail.com | ggreg...@apache.org > >>>>>> Java Persistence with Hibernate, Second Edition > >>>>>> <https://www.amazon.com/gp/product/1617290459/ref=as_li_ > >>>>>> tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1617290459& > >>>>>> linkCode=as2&tag=garygregory-20&linkId= > >> cadb800f39946ec62ea2b1af9fe6a2 > >>> b8> > >>>>>> > >>>>>> <http:////ir-na.amazon-adsystem.com/e/ir?t= > >> garygregory-20&l=am2&o=1&a= > >>>>>> 1617290459> > >>>>>> JUnit in Action, Second Edition > >>>>>> <https://www.amazon.com/gp/product/1935182021/ref=as_li_ > >>>>>> tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182021& > >>>>>> linkCode=as2&tag=garygregory-20&linkId= > >> 31ecd1f6b6d1eaf8886ac902a24de4 > >>>>> 18%22 > >>>>>>> > >>>>>> > >>>>>> <http:////ir-na.amazon-adsystem.com/e/ir?t= > >> garygregory-20&l=am2&o=1&a= > >>>>>> 1935182021> > >>>>>> Spring Batch in Action > >>>>>> <https://www.amazon.com/gp/product/1935182951/ref=as_li_ > >>>>>> tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182951& > >>>>>> linkCode=%7B%7BlinkCode%7D%7D&tag=garygregory-20&linkId=%7B% > >>>>>> 7Blink_id%7D%7D%22%3ESpring+Batch+in+Action> > >>>>>> <http:////ir-na.amazon-adsystem.com/e/ir?t= > >> garygregory-20&l=am2&o=1&a= > >>>>>> 1935182951> > >>>>>> Blog: http://garygregory.wordpress.com > >>>>>> Home: http://garygregory.com/ > >>>>>> Tweet! http://twitter.com/GaryGregory > >>>>>> > >>>>> > >>>>> > >>>>> > >>>>> -- > >>>>> Matt Sicker <boa...@gmail.com> > >>>>> > >>>> > >>>> > >>>> > >>>> -- > >>>> E-Mail: garydgreg...@gmail.com | ggreg...@apache.org > >>>> Java Persistence with Hibernate, Second Edition > >>>> <https://www.amazon.com/gp/product/1617290459/ref=as_li_tl? > >>> ie=UTF8&camp=1789&creative=9325&creativeASIN=1617290459&link > >>> Code=as2&tag=garygregory-20&linkId=cadb800f39946ec62ea2b1af9fe6a2b8> > >>>> > >>>> <http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l= > >>> am2&o=1&a=1617290459> > >>>> JUnit in Action, Second Edition > >>>> <https://www.amazon.com/gp/product/1935182021/ref=as_li_tl? > >>> ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182021&link > >>> Code=as2&tag=garygregory-20&linkId=31ecd1f6b6d1eaf8886ac902a24de4 > 18%22> > >>>> > >>>> <http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l= > >>> am2&o=1&a=1935182021> > >>>> Spring Batch in Action > >>>> <https://www.amazon.com/gp/product/1935182951/ref=as_li_tl? > >>> ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182951&link > >>> Code=%7B%7BlinkCode%7D%7D&tag=garygregory-20&linkId=%7B%7Bli > >>> nk_id%7D%7D%22%3ESpring+Batch+in+Action> > >>>> <http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l= > >>> am2&o=1&a=1935182951> > >>>> Blog: http://garygregory.wordpress.com > >>>> Home: http://garygregory.com/ > >>>> Tweet! http://twitter.com/GaryGregory > >>> > >>> > >>> --------------------------------------------------------------------- > >>> To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org > >>> For additional commands, e-mail: dev-h...@commons.apache.org > >>> > >> > > > > > > > > -- > > E-Mail: garydgreg...@gmail.com | ggreg...@apache.org > > Java Persistence with Hibernate, Second Edition > > <https://www.amazon.com/gp/product/1617290459/ref=as_li_ > tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1617290459& > linkCode=as2&tag=garygregory-20&linkId=cadb800f39946ec62ea2b1af9fe6a2b8> > > > > <http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a= > 1617290459> > > JUnit in Action, Second Edition > > <https://www.amazon.com/gp/product/1935182021/ref=as_li_ > tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182021& > linkCode=as2&tag=garygregory-20&linkId=31ecd1f6b6d1eaf8886ac902a24de418%22 > > > > > > <http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a= > 1935182021> > > Spring Batch in Action > > <https://www.amazon.com/gp/product/1935182951/ref=as_li_ > tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182951& > linkCode=%7B%7BlinkCode%7D%7D&tag=garygregory-20&linkId=%7B% > 7Blink_id%7D%7D%22%3ESpring+Batch+in+Action> > > <http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a= > 1935182951> > > Blog: http://garygregory.wordpress.com > > Home: http://garygregory.com/ > > Tweet! http://twitter.com/GaryGregory > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org > For additional commands, e-mail: dev-h...@commons.apache.org > > -- Matt Sicker <boa...@gmail.com>