// Path: core/src/main/java/net/sf/beanlib/provider/collector/ProtectedSetterMethodCollector.java
// public class ProtectedSetterMethodCollector implements BeanMethodCollector {
// 
//     @Override
//     public Method[] collect(Object bean) {
//         Class<?> beanClass = bean.getClass();
//         // Get all methods declared by the class or interface.
//         // This includes public, protected, default (package) access,
//         // and private methods, but excludes inherited methods.
//         Set<Method> set = new HashSet<Method>();
// 
//         while (beanClass != Object.class) {
//             for (Method m : beanClass.getDeclaredMethods()) {
//                 if (!m.getName().startsWith(getMethodPrefix())) {
//                     continue;
//                 }
//                 if (m.getParameterTypes().length != 1) {
//                     continue;
//                 }
//                 final int mod = m.getModifiers();
// 
//                 if (Modifier.isStatic(mod)) {
//                     continue;
//                 }
//                 if (Modifier.isPrivate(mod)) {
//                     continue;
//                 }
//                 // Adds the specified element to the set if it is not already present
//                 set.add(m);
//             }
//             // climb to the super class and repeat
//             beanClass = beanClass.getSuperclass();
//         }
//         return set.toArray(new Method[set.size()]);
//     }
// 
//     @Override
//     public String getMethodPrefix() {
//         return "set";
//     }
// }


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import org.junit.Test;
import junit.framework.JUnit4TestAdapter;
import net.sf.beanlib.provider.collector.ProtectedSetterMethodCollector;
            // Note this is different than if the default transformer is used.
            assertSame(from.getBar(), to.getBar());
        }
        // Default transformer
        {
            Bar from = new Bar("from");
            from.setBoo(true);
            from.setString("foo");
            from.setBarString("barString");
            from.setBar(from);
            Bar to = new Bar("to");
            new BeanPopulator(from, to).populate();
            assertFalse(from.getProtectedSetString().equals(to.getProtectedSetString()));
            assertEquals(from.getString(), to.getString());
            assertEquals(from.isBoo(), to.isBoo());
            assertEquals(from.getBarString(), to.getBarString());
            // Note this is different than if no transformer is used.
            assertSame(to, to.getBar());
        }
    }

    @Test
    public void testProtected() {
        // No transformer
        {
            Foo from = new Foo("from");
            from.setBoo(true);
            from.setString("foo");
            Foo to = new Foo("to");
            assertFalse(from.equals(to));
// Path: core/src/main/java/net/sf/beanlib/provider/collector/ProtectedSetterMethodCollector.java
// public class ProtectedSetterMethodCollector implements BeanMethodCollector {
// 
//     @Override
//     public Method[] collect(Object bean) {
//         Class<?> beanClass = bean.getClass();
//         // Get all methods declared by the class or interface.
//         // This includes public, protected, default (package) access,
//         // and private methods, but excludes inherited methods.
//         Set<Method> set = new HashSet<Method>();
// 
//         while (beanClass != Object.class) {
//             for (Method m : beanClass.getDeclaredMethods()) {
//                 if (!m.getName().startsWith(getMethodPrefix())) {
//                     continue;
//                 }
//                 if (m.getParameterTypes().length != 1) {
//                     continue;
//                 }
//                 final int mod = m.getModifiers();
// 
//                 if (Modifier.isStatic(mod)) {
//                     continue;
//                 }
//                 if (Modifier.isPrivate(mod)) {
//                     continue;
//                 }
//                 // Adds the specified element to the set if it is not already present
//                 set.add(m);
//             }
//             // climb to the super class and repeat
//             beanClass = beanClass.getSuperclass();
//         }
//         return set.toArray(new Method[set.size()]);
//     }
// 
//     @Override
//     public String getMethodPrefix() {
//         return "set";
//     }
// }


// Path: core/src/test/java/net/sf/beanlib/provider/BeanPopulatorTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import org.junit.Test;
import junit.framework.JUnit4TestAdapter;
import net.sf.beanlib.provider.collector.ProtectedSetterMethodCollector;

            // Note this is different than if the default transformer is used.
            assertSame(from.getBar(), to.getBar());
        }
        // Default transformer
        {
            Bar from = new Bar("from");
            from.setBoo(true);
            from.setString("foo");
            from.setBarString("barString");
            from.setBar(from);
            Bar to = new Bar("to");
            new BeanPopulator(from, to).populate();
            assertFalse(from.getProtectedSetString().equals(to.getProtectedSetString()));
            assertEquals(from.getString(), to.getString());
            assertEquals(from.isBoo(), to.isBoo());
            assertEquals(from.getBarString(), to.getBarString());
            // Note this is different than if no transformer is used.
            assertSame(to, to.getBar());
        }
    }

    @Test
    public void testProtected() {
        // No transformer
        {
            Foo from = new Foo("from");
            from.setBoo(true);
            from.setString("foo");
            Foo to = new Foo("to");
            assertFalse(from.equals(to));
            new BeanPopulator(from, to).initSetterMethodCollector(new ProtectedSetterMethodCollector()).initTransformer(null).populate();