Announcement Announcement Module
Collapse
No announcement yet.
copy class data with same intefrace? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • copy class data with same intefrace?

    hi..

    i have to clases which impement the same interface of getters and setters, is an easy with spring to start copy their content from one to another, instead of specifying each getter setter?

    the issue here that these classes implement several interfaces, and i only need to copy a single interface ,which i will decide on run-time

    so i have i have personOrigin and perTarget, and they both impelment interfaces personRisk and personTech. the i need to cast both classes to either personTech or PersonRisk in run-time accrodging to a value i will get,and then copy both their values

  • #2
    Have a look at the BeanUtils.copyProperties() methods. One of them looks like it would do exactly what you want.

    Regards,
    Andreas

    Comment


    • #3
      thanks that did the trick with
      BeanUtils.copyProperties(org, tar, Class.forName("com.pnx.compass.input.sourcesinterf aces.ApplicationTechDemo"));

      (now all i have to do is to hope they won't change it.
      Last edited by emaayan; Sep 22nd, 2006, 08:44 AM.

      Comment


      • #4
        Fine that it works!

        Just curious: any reason why you do not provide the third parameter as ApplicationTechDemo.class? It should be safer as it fails on compile time if the class does not exist.

        Regards,
        Andreas

        Comment

        Working...
        X