> 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=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=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=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