Return-Path: X-Original-To: apmail-zest-dev-archive@minotaur.apache.org Delivered-To: apmail-zest-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id DB0C018EBF for ; Sat, 5 Sep 2015 07:50:15 +0000 (UTC) Received: (qmail 49088 invoked by uid 500); 5 Sep 2015 07:50:15 -0000 Delivered-To: apmail-zest-dev-archive@zest.apache.org Received: (qmail 49049 invoked by uid 500); 5 Sep 2015 07:50:15 -0000 Mailing-List: contact dev-help@zest.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@zest.apache.org Delivered-To: mailing list dev@zest.apache.org Received: (qmail 49037 invoked by uid 99); 5 Sep 2015 07:50:15 -0000 Received: from Unknown (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 05 Sep 2015 07:50:15 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 1B52EC000D for ; Sat, 5 Sep 2015 07:50:15 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.98 X-Spam-Level: ** X-Spam-Status: No, score=2.98 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.001, HTML_MESSAGE=3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd4-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id mkBwqu9NgYWS for ; Sat, 5 Sep 2015 07:50:14 +0000 (UTC) Received: from mail-la0-f50.google.com (mail-la0-f50.google.com [209.85.215.50]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with ESMTPS id 8228420382 for ; Sat, 5 Sep 2015 07:50:13 +0000 (UTC) Received: by lagj9 with SMTP id j9so26194129lag.2 for ; Sat, 05 Sep 2015 00:50:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:from:date:message-id:subject:to:content-type; bh=67BgDQXn6otI6oTNaq7p9flTOXpwcHIiPHPqreB24lY=; b=QGF65Cu/WrGCcpjN7pRDl3anMjokL9FGAJmHcTvCWKhnZQFSfgHnNl2Yyiv/P1RDUV e2KugRY/BIkCJY/lX2jUFIgxfSCcPL49WM90bwagWmv1JydDQMzZy7sjeSxCpcdWp+vB DyEfW61DOi5pHEOOsBBnRhlc+77vm499BrrEy2Ehq3BtgGA7vQjparGO1N+xSmh0O8jz 64yYmZh2seNXSw/XKrxq38IfGdl4SFLC1KSGFuXmNZYB2NEOiz/Kw+n9vBL0vuwBuo/o DdGYJcbiJ4dSSfuu2Jem2WIXvGCbgsAlpzYnmiSaoptrUgL4PtnrOMgZdxfEalrBdL7t mz2Q== X-Received: by 10.152.27.100 with SMTP id s4mr7598155lag.122.1441439405876; Sat, 05 Sep 2015 00:50:05 -0700 (PDT) MIME-Version: 1.0 Sender: hedhman@gmail.com Received: by 10.25.133.135 with HTTP; Sat, 5 Sep 2015 00:49:46 -0700 (PDT) From: Niclas Hedhman Date: Sat, 5 Sep 2015 15:49:46 +0800 X-Google-Sender-Auth: DZv43xjzZEnbIW3GP6cNtJEKLL8 Message-ID: Subject: Predicates as Constraints To: dev Content-Type: multipart/alternative; boundary=089e0160b88ec0b045051efb43ac --089e0160b88ec0b045051efb43ac Content-Type: text/plain; charset=UTF-8 Gang, ZEST-36... I think it makes sense to get rid of the Constraint interface and use the Predicate instead. And at the same time support a ConstraintFactory concept, where the Predicate can be created by a factory, to support the CompositeConstraint concept that exists (I didn't know that). So, something like this; public interface Customer { Property name(); @Age Property age(); } @ConstraintDeclaration @Retention( RUNTIME ) @Constraints( AgePredicate.class ) public @interface Age { int min() default 18; int max() default 95; } public static class AgePredicate implements Predicate { private Age range; @Override public boolean test( Integer argument ) { return argument > range.min() && argument < range.max(); } } I will think a little bit more about the ConstrainFactory, but it should probably get access to a bit more than just the Annotation. To make the codebase lean, I would like to remove the Constraint variant completely, although @Constraints remain as previously. WDYT? Cheers -- Niclas Hedhman, Software Developer http://zest.apache.org - New Energy for Java --089e0160b88ec0b045051efb43ac--