Return-Path: X-Original-To: apmail-cayenne-dev-archive@www.apache.org Delivered-To: apmail-cayenne-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1F27B10581 for ; Fri, 21 Nov 2014 15:03:01 +0000 (UTC) Received: (qmail 99863 invoked by uid 500); 21 Nov 2014 15:03:00 -0000 Delivered-To: apmail-cayenne-dev-archive@cayenne.apache.org Received: (qmail 99836 invoked by uid 500); 21 Nov 2014 15:03:00 -0000 Mailing-List: contact dev-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cayenne.apache.org Delivered-To: mailing list dev@cayenne.apache.org Received: (qmail 99825 invoked by uid 99); 21 Nov 2014 15:03:00 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 21 Nov 2014 15:03:00 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [162.242.166.79] (HELO us-rs09.objectstyle.com) (162.242.166.79) by apache.org (qpsmtpd/0.29) with SMTP; Fri, 21 Nov 2014 15:02:34 +0000 Received: (qmail 25782 invoked by uid 509); 21 Nov 2014 15:02:32 -0000 Received: from unknown (HELO ?192.168.1.35?) (212.98.191.4) by us-rs09.objectstyle.com with SMTP; 21 Nov 2014 15:02:32 -0000 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 8.1 \(1993\)) Subject: Re: Variations of 'like' From: Andrus Adamchik In-Reply-To: Date: Fri, 21 Nov 2014 18:02:31 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: <1C50C7D9-B17F-429B-9A81-53268B73702E@objectstyle.org> References: <1094EEAA-6205-4FAB-B789-E460A3078E4F@objectstyle.org> To: dev@cayenne.apache.org X-Mailer: Apple Mail (2.1993) X-Virus-Checked: Checked by ClamAV on apache.org enum also makes it needlessly verbose :-/=20 But yeah, I take your point.=20 > On Nov 21, 2014, at 5:56 PM, Michael Gentry = wrote: >=20 > I'd avoid true/false for that purpose. We had the same thing in > orderings before I changed it to an enum. I'd specify it in the > method name or use an enum that makes sense when reading it. >=20 > mrg >=20 >=20 > On Fri, Nov 21, 2014 at 9:47 AM, Andrus Adamchik = wrote: >>> So are you thinking something like: >>> Artist.ARTIST_NAME.contains("Van")? >>=20 >> yep. >>=20 >>> Also, what about >>> case-insensitive? >>=20 >> Probably as a second true/false argument? I started to dislike the = look of "likeIgnoreCase" recently :) >>=20 >> Property.contains(string); >> Property.contains(string, true); >> Property.contains(string, false); >>=20 >>=20 >> Andrus >>=20 >>=20 >>> On Nov 21, 2014, at 5:33 PM, Michael Gentry = wrote: >>>=20 >>> I 'like' this. >>>=20 >>> So are you thinking something like: >>> Artist.ARTIST_NAME.contains("Van")? Also, what about >>> case-insensitive? >>>=20 >>> mrg >>>=20 >>>=20 >>> On Fri, Nov 21, 2014 at 7:19 AM, Andrus Adamchik = wrote: >>>> Another API idea that I just had while analyzing boilerplate code = of the client Cayenne apps. An argument to Property.like(..) (or second = argument to ExpressionFactory.likeExp(..)) requires a full pattern to = match against. So people would often write their own utility code to = wrap a String in "%" signs. Cayenne can easily take care of this via the = following methods: >>>>=20 >>>>=20 >>>> Property.contains(string); >>>> // same as Property.like("%" + string + "%"); >>>>=20 >>>> Property.startsWith(string); >>>> // same as Property.like(string + "%"); >>>>=20 >>>> Property.endsWith(string); >>>> // same as Property.like("%" + string); >>>>=20 >>>> In addition to saving the user from String concatenation, these new = methods can do proper symbol escaping, making "like" much safer to use. >>>>=20 >>>> Andrus >>>=20 >>=20 >=20