You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Duncan Jones (JIRA)" <ji...@apache.org> on 2014/10/22 09:55:34 UTC
[jira] [Commented] (LANG-1054) Support java.util.regex.Pattern in
EqualsBuilder and HashCodeBuilder
[ https://issues.apache.org/jira/browse/LANG-1054?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14179693#comment-14179693 ]
Duncan Jones commented on LANG-1054:
------------------------------------
We wouldn't want to extend {{EqualsBuilder}} with support for arbitrary objects that don't implement {{equals()}} or {{hashCode()}}. That's a never-ending road.
Instead, you could consider passing fields from the pattern into the builder, e.g. the result of {{pattern()}} and {{flags()}}. Of course, you'd need to check the values are not null first (or design a class in which that's not a possibility.
Or create your own class that uses composition to include a Pattern, but has support for {{equals()}} etc.
> Support java.util.regex.Pattern in EqualsBuilder and HashCodeBuilder
> --------------------------------------------------------------------
>
> Key: LANG-1054
> URL: https://issues.apache.org/jira/browse/LANG-1054
> Project: Commons Lang
> Issue Type: Wish
> Components: lang.builder.*
> Reporter: Markus Malkusch
> Priority: Minor
>
> Hi
> Pattern is an annoyance because it doesn't implement equals() nor hashCode(). I.e. EqualsBuilder.append(Object, Object) will never set EqualsBuilder.isEquals to true for e.g.:
> {code}
> builder.append(Pattern.compile("foo"), Pattern.compile("foo"));
> {code}
> It would be nice to have an EqualsBuilder which compares Pattern.pattern and Pattern.flags instead of calling Pattern.equals().
> Same for HashCodeBuilder.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)