Java cast base class to an extended class -
i have class used in project sort of field holder. like:
class { private string field = null; private string field2 = null; private string field3 = null; // , generic getters , setters }
in part of code need add additional fields class. did
class b extends { private string fieldinb = null; // , getters , setters }
in function thought
public void foo( a ) { b b = (b)a; }
and have fields written in a
object , set field in b
, use it. seams common problem, don't know how except ugly approach:
public b( a ) { // copy fields 1 @ time }
you use dozer. allows map bean property values 1 bean class another.
Comments
Post a Comment