Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id DFCC711B3D for ; Sat, 26 Jul 2014 09:49:40 +0000 (UTC) Received: (qmail 99469 invoked by uid 500); 26 Jul 2014 09:49:40 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 99331 invoked by uid 500); 26 Jul 2014 09:49:40 -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 99195 invoked by uid 99); 26 Jul 2014 09:49:40 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 26 Jul 2014 09:49:40 +0000 Date: Sat, 26 Jul 2014 09:49:40 +0000 (UTC) From: "Benedikt Ritter (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (LANG-1030) StringUtils.same opposite method to StringUtils.differ MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/LANG-1030?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14075318#comment-14075318 ] Benedikt Ritter commented on LANG-1030: --------------------------------------- bq. Should we use the "review patch" label in cases where we don't have a full patch (with tests) attached to the issue? it's more like Discussion :) > StringUtils.same opposite method to StringUtils.differ > ------------------------------------------------------ > > Key: LANG-1030 > URL: https://issues.apache.org/jira/browse/LANG-1030 > Project: Commons Lang > Issue Type: Improvement > Affects Versions: 3.3.2 > Reporter: Michael Bazos > Priority: Trivial > Labels: StringUtils > Fix For: Review Patch, Discussion > > > This is pretty easy to do but I have seen this come up and was surprised to find that StringUtils didn't have a utility method. > The difference() method is described as doing the following: > Compares two Strings, and returns the portion where they differ. > What I am proposing is essentially the opposite of the difference method called same(). This method would compare two String and return a new String when they are the same. > This is essentially the implementation: > {code:java} > public static String same(String str1, String str2) { > if (str1 != null && StringUtils.equalsIgnoreCase(str1, str2)) { > return new String(str1); > } > return null; > } > {code} > {code:java} > StringUtils.same(null, null) = null > StringUtils.same("", "") = ""; > StringUtils.same("123", "") = null > StringUtils.same("123", "123") = "123"; > {code} > If there is already a way to do this using the apache lang library please point me in the right direction. Otherwise I would be more than happy to do the testing, coding and documentation for this. -- This message was sent by Atlassian JIRA (v6.2#6252)