java - Is it possible to have a 2D array with 2 different datatypes that still takes a {{,},{,}} constructor with typechecking? -


in our current code, have class called mastercodeview:

public class mastercodeview implements serializable {      private string code;     private string description;     //getters , setters } 

then, in each of our business objects, have 1 or more string[][] attributes:

public static final string[][] connectionmodedescriptions = {         { connectionmode_passive + "", mastercodedescriptionkeys.mc_ftpconnectionmode_passive },          { connectionmode_active + "", mastercodedescriptionkeys.mc_ftpconnectionmode_active } }; 

these mastercodeviews used i18n of object-specific data, use in radio button labels, grid table cells,... have around 60 of these.

the translation string[][] list<mastercodeview> done using mastercodeserviceimpl singleton:

private list<mastercodeview> connectionmodedescriptions = new arraylist<mastercodeview>(); // have bunch of these plain list, being // replaced generic lists above whenever possible remove warnings.  private mastercodeserviceimpl() {     object[][] tmp = {         ...         { connectionmodedescriptions, ftp.connectionmodedescriptions },         ... // on 60 lines in total     } ;      (int = 0; < tmp.length; i++) {         list<mastercodeview> list = (list<mastercodeview>)tmp[i][0];         string[][] descriptions = (string[][])tmp[i][1];         (int j = 0; j < descriptions.length; j++) {             mastercodeview mastercodeview = new mastercodeview();             mastercodeview.setcode(descriptions[j][0]);             mastercodeview.setdescription(descriptions[j][1]);             list.add(mastercodeview);         }     } } 

as can see, takes 2d array of objects, means there's message unchecked conversion object list<mastercodeview> on first line within loop. rid of error message. however, want without having edit 60 line mapping array new formatting, , without having change business objects or mastercodeview class.

i preferably want change object[][] else , if needed loop. possible?

you maybe (saves 2d array , looping).

private list<mastercodeview> connectionmodedescriptions = new   private mastercodeserviceimpl() {     connectionmodedescriptions = arrays.aslist( {         ...         new mastercodeview(connectionmodedescriptions, ftp.connectionmodedescription),         ... // on 60 lines in total     } );         } 

Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -