Menu

Protected get methods

Help
2006-10-16
2013-04-25
  • Sheldon Young

    Sheldon Young - 2006-10-16

    Beanlib will use a protected setter method but will not use a protected get method, meaning copyies of the following will always have null as the value for 'foo'l:

    public class Slartibartfast {

        private String foo;

        protected String getFoo() {
             return foo;
        }

        protected void setFoo(String newFoo) {
            foo = newFoo;
        }

    }

    I would recommend protected get methods be used as well to remain orthogonal.  Does anybody have any thoughts?

     
    • Joe D. Velopar

      Joe D. Velopar - 2006-12-03

      Hi Sheldon,

      Have you checked out the class net.sf.beanlibProtectedReaderMethodFinder ?

      You can use the singleton instance of this class to achieve what you need, by plugging it into either BeanPopulator or HibernateBeanReplicator, depending on what you are trying to do.

       
      • Joe D. Velopar

        Joe D. Velopar - 2006-12-03

        typo: net.sf.beanlib.ProtectedReaderMethodFinder

         

Log in to post a comment.