You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by cezarykluczynski <gi...@git.apache.org> on 2016/10/19 16:12:50 UTC

[GitHub] commons-lang pull request #197: ObjectUtils::xorNull added

GitHub user cezarykluczynski opened a pull request:

    https://github.com/apache/commons-lang/pull/197

    ObjectUtils::xorNull added

    Seems useful. What's your opinion?

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/cezarykluczynski/commons-lang ObjectUtils-xorNull

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/commons-lang/pull/197.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #197
    
----
commit 716bab9625e7e634bfc3f6640c554b9bd38f7eba
Author: Cezary Kluczy\u0144ski <ce...@gmail.com>
Date:   2016-10-19T16:04:57Z

    ObjectUtils::xorNull added

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] commons-lang pull request #197: ObjectUtils::xorNull added

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/commons-lang/pull/197


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] commons-lang issue #197: ObjectUtils::xorNull added

Posted by cezarykluczynski <gi...@git.apache.org>.
Github user cezarykluczynski commented on the issue:

    https://github.com/apache/commons-lang/pull/197
  
    @dmjones500 I'm not sure what you mean by normal application, but here are two examples: https://github.com/cezarykluczynski/stapi/search?utf8=%E2%9C%93&q=xorNull


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] commons-lang issue #197: ObjectUtils::xorNull added

Posted by dmjones500 <gi...@git.apache.org>.
Github user dmjones500 commented on the issue:

    https://github.com/apache/commons-lang/pull/197
  
    @cezarykluczynski Commons Lang solves frequently encountered programming problems by adding methods that are arguably "missing" from `java.lang`. I'm trying to imagine the sort of problem this solves.
    
    You've provided two examples. Looking at them, I'm not sure whether `xorNull` is the best way to solve them.
    
    Based on the name of the method, I would have thought this might work:
    
    ```java
    private void removeBirthNameIfItEqualsName(ActorTemplate actorTemplate) {
        String name = actorTemplate.getName();
        String birthName = actorTemplate.getBirthName();
    
        if (birthName == null) {
            return;
        }
    
        if (birthName.equals(name)) {
            actorTemplate.setBirthName(null);
        }
    }
    ```
    
    In your other example, you could rearrange the conditional statements and remove the need for your method:
    
    ```java
    private LocalDate getIfEqualSkipNulls(LocalDate left, LocalDate right, Page item, boolean dateOfBirth) {
    
        if (left == null && right == null) {
            return null;
        } else if (left != null && right != null) {
            if (left.equals(right)) {
                return left;
            } else {
                String dateType = dateOfBirth ? "birth" : "death";
                log.error(
                        "Date of {} {} from for PageToLifeRangeProcessor does not equal date of {} {} from "
                                + "ActorTemplateToLifeRangeProcessor for {} - setting date to null",
                        dateType, left, dateType, right, item.getTitle());
                return null;
            }
        } else {
            return ObjectUtils.firstNonNull(left, right);
        }
    }
    ```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] commons-lang issue #197: ObjectUtils::xorNull added

Posted by dmjones500 <gi...@git.apache.org>.
Github user dmjones500 commented on the issue:

    https://github.com/apache/commons-lang/pull/197
  
    @cezarykluczynski Can you suggest a few use cases for this functionality in a normal application?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] commons-lang issue #197: ObjectUtils::xorNull added

Posted by PascalSchumacher <gi...@git.apache.org>.
Github user PascalSchumacher commented on the issue:

    https://github.com/apache/commons-lang/pull/197
  
    Thanks for the pull request!
    
    I'm not sure this is generally useful. I do not remember ever needing/using a method like this.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] commons-lang issue #197: ObjectUtils::xorNull added

Posted by coveralls <gi...@git.apache.org>.
Github user coveralls commented on the issue:

    https://github.com/apache/commons-lang/pull/197
  
    
    [![Coverage Status](https://coveralls.io/builds/8413353/badge)](https://coveralls.io/builds/8413353)
    
    Coverage increased (+0.02%) to 93.561% when pulling **716bab9625e7e634bfc3f6640c554b9bd38f7eba on cezarykluczynski:ObjectUtils-xorNull** into **8592cfe496e204ce8540441047d578026b5e0a5c on apache:master**.



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] commons-lang issue #197: ObjectUtils::xorNull added

Posted by coveralls <gi...@git.apache.org>.
Github user coveralls commented on the issue:

    https://github.com/apache/commons-lang/pull/197
  
    
    [![Coverage Status](https://coveralls.io/builds/8413353/badge)](https://coveralls.io/builds/8413353)
    
    Coverage increased (+0.02%) to 93.561% when pulling **716bab9625e7e634bfc3f6640c554b9bd38f7eba on cezarykluczynski:ObjectUtils-xorNull** into **8592cfe496e204ce8540441047d578026b5e0a5c on apache:master**.



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---