You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ch...@apache.org on 2017/04/20 15:08:17 UTC

[1/6] [lang] This closes #250

Repository: commons-lang
Updated Branches:
  refs/heads/master ff6b0ada7 -> 8147cc5b3


This closes #250


Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/3072c655
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/3072c655
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/3072c655

Branch: refs/heads/master
Commit: 3072c655e0d163f0f38d610c37fd7f3cc727714e
Parents: 6597c19
Author: MarkDacek <ma...@richmond.edu>
Authored: Sun Mar 5 20:36:39 2017 -0500
Committer: MarkDacek <ma...@richmond.edu>
Committed: Sun Mar 5 20:36:39 2017 -0500

----------------------------------------------------------------------

----------------------------------------------------------------------



[2/6] [lang] Merge remote-tracking branch 'APACHE/master'

Posted by ch...@apache.org.
Merge remote-tracking branch 'APACHE/master'


Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/40b8ecd3
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/40b8ecd3
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/40b8ecd3

Branch: refs/heads/master
Commit: 40b8ecd3faa8df655ee8b4141ff309553eccfc88
Parents: 3072c65 bf80b9e
Author: MarkDacek <ma...@richmond.edu>
Authored: Fri Mar 17 17:43:15 2017 -0400
Committer: MarkDacek <ma...@richmond.edu>
Committed: Fri Mar 17 17:43:15 2017 -0400

----------------------------------------------------------------------
 .travis.yml                                     |   5 +-
 checkstyle.xml                                  |   5 +-
 pom.xml                                         |  16 +-
 src/changes/changes.xml                         |   4 +-
 .../org/apache/commons/lang3/ArrayUtils.java    |   5 +-
 .../apache/commons/lang3/CharSequenceUtils.java |  97 ++++++-
 .../org/apache/commons/lang3/StringUtils.java   | 264 ++++++++++++-------
 .../commons/lang3/concurrent/Computable.java    |   2 +-
 .../concurrent/annotation/package-info.java     |  22 ++
 .../commons/lang3/exception/ExceptionUtils.java |   1 -
 .../apache/commons/lang3/time/DateUtils.java    |   6 +-
 .../apache/commons/lang3/ClassUtilsTest.java    |  86 +++---
 .../lang3/StringUtilsEmptyBlankTest.java        |  55 ++--
 .../lang3/StringUtilsEqualsIndexOfTest.java     |  49 ++++
 .../exception/AbstractExceptionContextTest.java |   4 +-
 15 files changed, 425 insertions(+), 196 deletions(-)
----------------------------------------------------------------------



[4/6] [lang] LANG-1167: Added more test cases for ReflectionToStringBuilderExcludeNullValuesTest

Posted by ch...@apache.org.
LANG-1167: Added more test cases for ReflectionToStringBuilderExcludeNullValuesTest


Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/3c2673e8
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/3c2673e8
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/3c2673e8

Branch: refs/heads/master
Commit: 3c2673e82d33b6c9bef3005a896e5b0d52b108dd
Parents: 661d16d
Author: MarkDacek <ma...@richmond.edu>
Authored: Sat Mar 18 16:00:46 2017 -0400
Committer: MarkDacek <ma...@richmond.edu>
Committed: Sat Mar 18 16:00:46 2017 -0400

----------------------------------------------------------------------
 ...ionToStringBuilderExcludeNullValuesTest.java | 51 ++++++++++++++++++--
 1 file changed, 48 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/3c2673e8/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java
index be368d6..7c0c68a 100644
--- a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java
@@ -72,10 +72,8 @@ public class ReflectionToStringBuilderExcludeNullValuesTest {
     
     @Test
     public void test_ConstructorOption(){
-        ReflectionToStringBuilder builder = new ReflectionToStringBuilder(BOTH_NON_NULL, null, null, null, false, false, false);
-        builder.setExcludeNullValues(true);
+        ReflectionToStringBuilder builder = new ReflectionToStringBuilder(BOTH_NON_NULL, null, null, null, false, false, true);
         assertTrue(builder.isExcludeNullValues());
-        
         String toString = builder.toString();
         assertTrue(toString.contains(INTEGER_FIELD_NAME));
         assertTrue(toString.contains(STRING_FIELD_NAME));
@@ -95,5 +93,52 @@ public class ReflectionToStringBuilderExcludeNullValuesTest {
         assertFalse(toString.contains(INTEGER_FIELD_NAME));
         assertFalse(toString.contains(STRING_FIELD_NAME));
     }
+    
+    @Test
+    public void test_ConstructorOptionNormal(){
+        ReflectionToStringBuilder builder = new ReflectionToStringBuilder(BOTH_NULL, null, null, null, false, false, false);
+        assertFalse(builder.isExcludeNullValues());
+        String toString = builder.toString();
+        assertTrue(toString.contains(STRING_FIELD_NAME));
+        assertTrue(toString.contains(INTEGER_FIELD_NAME));
+        
+        //regression test older constructors
+        ReflectionToStringBuilder oldBuilder = new ReflectionToStringBuilder(BOTH_NULL);
+        toString = oldBuilder.toString();
+        assertTrue(toString.contains(STRING_FIELD_NAME));
+        assertTrue(toString.contains(INTEGER_FIELD_NAME));
+        
+        oldBuilder = new ReflectionToStringBuilder(BOTH_NULL, null, null, null, false, false);
+        toString = oldBuilder.toString();
+        assertTrue(toString.contains(STRING_FIELD_NAME));
+        assertTrue(toString.contains(INTEGER_FIELD_NAME));
+        
+        oldBuilder = new ReflectionToStringBuilder(BOTH_NULL, null, null);
+        toString = oldBuilder.toString();
+        assertTrue(toString.contains(STRING_FIELD_NAME));
+        assertTrue(toString.contains(INTEGER_FIELD_NAME));
+    }
+    
+    @Test
+    public void test_ConstructorOption_ExcludeNull(){
+        ReflectionToStringBuilder builder = new ReflectionToStringBuilder(BOTH_NULL, null, null, null, false, false, false);
+        builder.setExcludeNullValues(true);
+        assertTrue(builder.isExcludeNullValues());
+        String toString = builder.toString();
+        assertFalse(toString.contains(STRING_FIELD_NAME));
+        assertFalse(toString.contains(INTEGER_FIELD_NAME));
+        
+        builder = new ReflectionToStringBuilder(BOTH_NULL, null, null, null, false, false, true);
+        toString = builder.toString();
+        assertFalse(toString.contains(STRING_FIELD_NAME));
+        assertFalse(toString.contains(INTEGER_FIELD_NAME));
+        
+        ReflectionToStringBuilder oldBuilder = new ReflectionToStringBuilder(BOTH_NULL);
+        oldBuilder.setExcludeNullValues(true);
+        assertTrue(oldBuilder.isExcludeNullValues());
+        toString = oldBuilder.toString();
+        assertFalse(toString.contains(STRING_FIELD_NAME));
+        assertFalse(toString.contains(INTEGER_FIELD_NAME));
+    }
 
 }


[5/6] [lang] LANG-1167: Added license to top of ReflectionToStringBuilderExcludeNullValuesTest.java

Posted by ch...@apache.org.
LANG-1167: Added license to top of ReflectionToStringBuilderExcludeNullValuesTest.java


Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/e423b0bc
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/e423b0bc
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/e423b0bc

Branch: refs/heads/master
Commit: e423b0bc2dea4167ad98fffc1afd9243ba73aad6
Parents: 3c2673e
Author: MarkDacek <ma...@richmond.edu>
Authored: Sat Mar 18 18:49:40 2017 -0400
Committer: MarkDacek <ma...@richmond.edu>
Committed: Sat Mar 18 18:49:40 2017 -0400

----------------------------------------------------------------------
 ...ectionToStringBuilderExcludeNullValuesTest.java | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/e423b0bc/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java
index 7c0c68a..0a91609 100644
--- a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java
+++ b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java
@@ -1,3 +1,20 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.apache.commons.lang3.builder;
 
 import static org.junit.Assert.*;


[6/6] [lang] Merge branch 'LANG-1167' of https://github.com/MarkDacek/commons-lang

Posted by ch...@apache.org.
Merge branch 'LANG-1167' of https://github.com/MarkDacek/commons-lang


Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/8147cc5b
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/8147cc5b
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/8147cc5b

Branch: refs/heads/master
Commit: 8147cc5b3de5fa7a3a3e8116355efa44367dc3c5
Parents: ff6b0ad e423b0b
Author: Rob Tompkins <ch...@gmail.com>
Authored: Thu Apr 20 11:08:03 2017 -0400
Committer: Rob Tompkins <ch...@gmail.com>
Committed: Thu Apr 20 11:08:03 2017 -0400

----------------------------------------------------------------------
 .../builder/ReflectionToStringBuilder.java      | 122 +++++++++++++-
 ...ionToStringBuilderExcludeNullValuesTest.java | 161 +++++++++++++++++++
 2 files changed, 282 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/8147cc5b/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java
----------------------------------------------------------------------


[3/6] [lang] LANG-1167: Added isExcludeNullValues to ReflectionToStringBuilder and test

Posted by ch...@apache.org.
LANG-1167: Added isExcludeNullValues to ReflectionToStringBuilder and test


Project: http://git-wip-us.apache.org/repos/asf/commons-lang/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-lang/commit/661d16d1
Tree: http://git-wip-us.apache.org/repos/asf/commons-lang/tree/661d16d1
Diff: http://git-wip-us.apache.org/repos/asf/commons-lang/diff/661d16d1

Branch: refs/heads/master
Commit: 661d16d190708a1a396d8b75ba10738e4574c11d
Parents: 40b8ecd
Author: MarkDacek <ma...@richmond.edu>
Authored: Sat Mar 18 15:47:09 2017 -0400
Committer: MarkDacek <ma...@richmond.edu>
Committed: Sat Mar 18 15:47:09 2017 -0400

----------------------------------------------------------------------
 .../builder/ReflectionToStringBuilder.java      | 122 ++++++++++++++++++-
 ...ionToStringBuilderExcludeNullValuesTest.java |  99 +++++++++++++++
 2 files changed, 220 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-lang/blob/661d16d1/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java b/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java
index d40a838..0b4d7e5 100644
--- a/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java
+++ b/src/main/java/org/apache/commons/lang3/builder/ReflectionToStringBuilder.java
@@ -300,6 +300,64 @@ public class ReflectionToStringBuilder extends ToStringBuilder {
         return new ReflectionToStringBuilder(object, style, null, reflectUpToClass, outputTransients, outputStatics)
                 .toString();
     }
+    
+    /**
+     * <p>
+     * Builds a <code>toString</code> value through reflection.
+     * </p>
+     *
+     * <p>
+     * It uses <code>AccessibleObject.setAccessible</code> to gain access to private fields. This means that it will
+     * throw a security exception if run under a security manager, if the permissions are not set up correctly. It is
+     * also not as efficient as testing explicitly.
+     * </p>
+     *
+     * <p>
+     * If the <code>outputTransients</code> is <code>true</code>, transient fields will be output, otherwise they
+     * are ignored, as they are likely derived fields, and not part of the value of the Object.
+     * </p>
+     *
+     * <p>
+     * If the <code>outputStatics</code> is <code>true</code>, static fields will be output, otherwise they are
+     * ignored.
+     * </p>
+     *
+     * <p>
+     * Superclass fields will be appended up to and including the specified superclass. A null superclass is treated as
+     * <code>java.lang.Object</code>.
+     * </p>
+     *
+     * <p>
+     * If the style is <code>null</code>, the default <code>ToStringStyle</code> is used.
+     * </p>
+     *
+     * @param <T>
+     *            the type of the object
+     * @param object
+     *            the Object to be output
+     * @param style
+     *            the style of the <code>toString</code> to create, may be <code>null</code>
+     * @param outputTransients
+     *            whether to include transient fields
+     * @param outputStatics
+     *            whether to include static fields
+     * @param excludeNulls
+     *            whether to exclude fields whose values are null
+     * @param reflectUpToClass
+     *            the superclass to reflect up to (inclusive), may be <code>null</code>
+     * @return the String result
+     * @throws IllegalArgumentException
+     *             if the Object is <code>null</code>
+     * 
+     * @see ToStringExclude
+     * @since 2.1
+     */
+    public static <T> String toString(
+            final T object, final ToStringStyle style, final boolean outputTransients,
+            final boolean outputStatics, boolean excludeNulls, final Class<? super T> reflectUpToClass) {
+        return new ReflectionToStringBuilder(object, style, null, reflectUpToClass, outputTransients, outputStatics, excludeNulls)
+                .toString();
+    }
 
     /**
      * Builds a String for a toString method excluding the given field names.
@@ -379,6 +437,11 @@ public class ReflectionToStringBuilder extends ToStringBuilder {
      * Whether or not to append transient fields.
      */
     private boolean appendTransients = false;
+    
+    /**
+     * Whether or not to append fields that are null.
+     */
+    private boolean excludeNullValues;
 
     /**
      * Which field names to exclude from output. Intended for fields like <code>"password"</code>.
@@ -483,6 +546,38 @@ public class ReflectionToStringBuilder extends ToStringBuilder {
         this.setAppendTransients(outputTransients);
         this.setAppendStatics(outputStatics);
     }
+    
+    /**
+     * Constructor.
+     *
+     * @param <T>
+     *            the type of the object
+     * @param object
+     *            the Object to build a <code>toString</code> for
+     * @param style
+     *            the style of the <code>toString</code> to create, may be <code>null</code>
+     * @param buffer
+     *            the <code>StringBuffer</code> to populate, may be <code>null</code>
+     * @param reflectUpToClass
+     *            the superclass to reflect up to (inclusive), may be <code>null</code>
+     * @param outputTransients
+     *            whether to include transient fields
+     * @param outputStatics
+     *            whether to include static fields
+     * @param excludeNullValues
+     *            whether to exclude fields who value is null
+     * @since 2.1
+     */
+    public <T> ReflectionToStringBuilder(
+            final T object, final ToStringStyle style, final StringBuffer buffer,
+            final Class<? super T> reflectUpToClass, final boolean outputTransients, final boolean outputStatics,
+            final boolean excludeNullValues) {
+        super(checkNotNull(object), style, buffer);
+        this.setUpToClass(reflectUpToClass);
+        this.setAppendTransients(outputTransients);
+        this.setAppendStatics(outputStatics);
+        this.setExcludeNullValues(excludeNullValues);
+    }
 
     /**
      * Returns whether or not to append the given <code>Field</code>.
@@ -547,7 +642,9 @@ public class ReflectionToStringBuilder extends ToStringBuilder {
                     // Warning: Field.get(Object) creates wrappers objects
                     // for primitive types.
                     final Object fieldValue = this.getValue(field);
-                    this.append(fieldName, fieldValue);
+                    if(!excludeNullValues || fieldValue != null){
+                        this.append(fieldName, fieldValue);
+                    }
                 } catch (final IllegalAccessException ex) {
                     //this can't happen. Would get a Security exception
                     // instead
@@ -619,6 +716,17 @@ public class ReflectionToStringBuilder extends ToStringBuilder {
     public boolean isAppendTransients() {
         return this.appendTransients;
     }
+    
+    /**
+     * <p>
+     * Gets whether or not to append fields whose values are null.
+     * </p>
+     *
+     * @return Whether or not to append fields whose values are null.
+     */
+    public boolean isExcludeNullValues() {
+        return this.excludeNullValues;
+    }
 
     /**
      * <p>
@@ -658,6 +766,18 @@ public class ReflectionToStringBuilder extends ToStringBuilder {
     public void setAppendTransients(final boolean appendTransients) {
         this.appendTransients = appendTransients;
     }
+    
+    /**
+     * <p>
+     * Sets whether or not to append fields whose values are null.
+     * </p>
+     *
+     * @param excludeNullValues
+     *            Whether or not to append fields whose values are null.
+     */
+    public void setExcludeNullValues(final boolean excludeNullValues) {
+        this.excludeNullValues = excludeNullValues;
+    }
 
     /**
      * Sets the field names to exclude.

http://git-wip-us.apache.org/repos/asf/commons-lang/blob/661d16d1/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java
new file mode 100644
index 0000000..be368d6
--- /dev/null
+++ b/src/test/java/org/apache/commons/lang3/builder/ReflectionToStringBuilderExcludeNullValuesTest.java
@@ -0,0 +1,99 @@
+package org.apache.commons.lang3.builder;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class ReflectionToStringBuilderExcludeNullValuesTest {
+
+    class TestFixture{
+        private Integer testIntegerField;
+        private String testStringField;
+        
+        public TestFixture(Integer a, String b){
+            this.testIntegerField = a;
+            this.testStringField = b;
+        }
+    }
+    
+    private static final String INTEGER_FIELD_NAME = "testIntegerField";
+    private static final String STRING_FIELD_NAME = "testStringField";
+    private final TestFixture BOTH_NON_NULL = new TestFixture(0, "str");
+    private final TestFixture FIRST_NULL = new TestFixture(null, "str");
+    private final TestFixture SECOND_NULL = new TestFixture(0, null);
+    private final TestFixture BOTH_NULL = new TestFixture(null, null);
+    
+    @Test
+    public void test_NonExclude(){
+        //normal case=
+        String toString = ReflectionToStringBuilder.toString(BOTH_NON_NULL, null, false, false, false, null);
+        assertTrue(toString.contains(INTEGER_FIELD_NAME));
+        assertTrue(toString.contains(STRING_FIELD_NAME));
+        
+        //make one null
+        toString = ReflectionToStringBuilder.toString(FIRST_NULL, null, false, false, false, null);
+        assertTrue(toString.contains(INTEGER_FIELD_NAME));
+        assertTrue(toString.contains(STRING_FIELD_NAME));
+        
+        //other one null
+        toString = ReflectionToStringBuilder.toString(SECOND_NULL, null, false, false, false, null);
+        assertTrue(toString.contains(INTEGER_FIELD_NAME));
+        assertTrue(toString.contains(STRING_FIELD_NAME));
+
+        //make the both null
+        toString = ReflectionToStringBuilder.toString(BOTH_NULL, null, false, false, false, null);
+        assertTrue(toString.contains(INTEGER_FIELD_NAME));
+        assertTrue(toString.contains(STRING_FIELD_NAME));
+    }
+    
+    @Test
+    public void test_excludeNull(){
+        
+        //test normal case
+        String toString = ReflectionToStringBuilder.toString(BOTH_NON_NULL, null, false, false, true, null);
+        assertTrue(toString.contains(INTEGER_FIELD_NAME));
+        assertTrue(toString.contains(STRING_FIELD_NAME));
+        
+        //make one null
+        toString = ReflectionToStringBuilder.toString(FIRST_NULL, null, false, false, true, null);
+        assertFalse(toString.contains(INTEGER_FIELD_NAME));
+        assertTrue(toString.contains(STRING_FIELD_NAME));
+        
+        //other one null
+        toString = ReflectionToStringBuilder.toString(SECOND_NULL, null, false, false, true, null);
+        assertTrue(toString.contains(INTEGER_FIELD_NAME));
+        assertFalse(toString.contains(STRING_FIELD_NAME));
+        
+        //both null
+        toString = ReflectionToStringBuilder.toString(BOTH_NULL, null, false, false, true, null);
+        assertFalse(toString.contains(INTEGER_FIELD_NAME));
+        assertFalse(toString.contains(STRING_FIELD_NAME));
+    }
+    
+    @Test
+    public void test_ConstructorOption(){
+        ReflectionToStringBuilder builder = new ReflectionToStringBuilder(BOTH_NON_NULL, null, null, null, false, false, false);
+        builder.setExcludeNullValues(true);
+        assertTrue(builder.isExcludeNullValues());
+        
+        String toString = builder.toString();
+        assertTrue(toString.contains(INTEGER_FIELD_NAME));
+        assertTrue(toString.contains(STRING_FIELD_NAME));
+        
+        builder = new ReflectionToStringBuilder(FIRST_NULL, null, null, null, false, false, true);
+        toString = builder.toString();
+        assertFalse(toString.contains(INTEGER_FIELD_NAME));
+        assertTrue(toString.contains(STRING_FIELD_NAME));
+        
+        builder = new ReflectionToStringBuilder(SECOND_NULL, null, null, null, false, false, true);
+        toString = builder.toString();
+        assertTrue(toString.contains(INTEGER_FIELD_NAME));
+        assertFalse(toString.contains(STRING_FIELD_NAME));
+        
+        builder = new ReflectionToStringBuilder(BOTH_NULL, null, null, null, false, false, true);
+        toString = builder.toString();
+        assertFalse(toString.contains(INTEGER_FIELD_NAME));
+        assertFalse(toString.contains(STRING_FIELD_NAME));
+    }
+
+}