Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id E4834200CC3 for ; Fri, 30 Jun 2017 19:36:07 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id E2578160BEB; Fri, 30 Jun 2017 17:36:07 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 35632160BF6 for ; Fri, 30 Jun 2017 19:36:07 +0200 (CEST) Received: (qmail 47850 invoked by uid 500); 30 Jun 2017 17:36:06 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 47786 invoked by uid 99); 30 Jun 2017 17:36:06 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 30 Jun 2017 17:36:06 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id BD049CD92C for ; Fri, 30 Jun 2017 17:36:05 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -100.011 X-Spam-Level: X-Spam-Status: No, score=-100.011 tagged_above=-999 required=6.31 tests=[SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id CFFwQMv54Rka for ; Fri, 30 Jun 2017 17:36:05 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 8CE5060D8C for ; Fri, 30 Jun 2017 17:36:04 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id C4518E090E for ; Fri, 30 Jun 2017 17:36:02 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 7BCD2245F5 for ; Fri, 30 Jun 2017 17:36:00 +0000 (UTC) Date: Fri, 30 Jun 2017 17:36:00 +0000 (UTC) From: "Amey Jadiye (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (TEXT-96) Convenience methods needed for RandomStringGenerator MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Fri, 30 Jun 2017 17:36:08 -0000 [ https://issues.apache.org/jira/browse/TEXT-96?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16070462#comment-16070462 ] Amey Jadiye commented on TEXT-96: --------------------------------- *Yes*, For scope of this JIRA I strongly believe that. what Mr. [~greenth] want can be accommodated easily with flexibility of the API. Ex. for *.randomNumeric()* {code} char [][] ranges = {{'0','9'}}; RandomStringGenerator generator = new RandomStringGenerator.Builder().withinRange(ranges).build(); {code} *.randomAlphabetic()* {code} char [][] ranges = {{'A','Z'}}; // or {{'A','Z'},{'a','z'}} RandomStringGenerator generator = new RandomStringGenerator.Builder().withinRange(ranges).build(); {code} *.randomAlphanumeric()* {code} char [][] ranges = {{'0','9'},{'A','Z'},{'a','b'}}; RandomStringGenerator generator = new RandomStringGenerator.Builder().withinRange(ranges).build(); {code} > Convenience methods needed for RandomStringGenerator > ---------------------------------------------------- > > Key: TEXT-96 > URL: https://issues.apache.org/jira/browse/TEXT-96 > Project: Commons Text > Issue Type: Improvement > Affects Versions: 1.1 > Reporter: Peter Phillips > Priority: Minor > > {{RandomStringGenerator}} is extremely verbose compared to the deprecated commons.lang3 {{RandomStringUtils}}. > Previously we could write: > {code:java} > RandomStringUtils.randomNumeric(10) > {code} > to generate a numeric string whereas this now has become: > {code:java} > new RandomStringGenerator.Builder().withinRange('0', '9').build().generate(10) > {code} > although in practice we would then also use static imports too. > The {{randomAlphabetic}} conversion is even more verbose: > {code:java} > new RandomStringGenerator.Builder().withinRange('A', 'z').filteredBy(new CharacterPredicate() { > @Override > public boolean test(int codePoint) { > return codePoint >= 'a' || codePoint <= 'Z'; > } > }).build().generate(10)) > {code} and at that point I lost enthusiam with trying to replicate {{randomAlphanumeric}}. > I don't think the average java developer would understand what a code point is in the first place so then trying to get our automation testers to use the new API to implement random alphanumeric character generation would be difficult. > I therefore suggest that commons-text should have a copy of {{RandomStringUtils}} which can even delegate to {{RandomStringGenerator}} or alternatively convenience static methods for the common use cases. -- This message was sent by Atlassian JIRA (v6.4.14#64029)