Advertisement
Guest User

Untitled

a guest
Jun 10th, 2011
162
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //****************** Using double brace initialization ********************
  2.  
  3. new BaseRoot() {{
  4.     setChild(new BaseChild() {{
  5.         setName("someChildName");
  6.         getContents().add(new ChildContents() {{
  7.             setName(c.getName());
  8.             setId(c.getId());          
  9.         }});
  10.         setCharacteristics(new ChildCharacteristics() {{
  11.             setDescriptor(new ChildDescriptor() {{
  12.                 setCommonName("someDescriptor");
  13.             }});
  14.             setId(database.getCharId());
  15.             setValue(database.getCharValue());
  16.         }});
  17.     }});
  18.     setName("someName");
  19.     setId(database.getRootId());
  20. }}
  21.  
  22. //******************* Using classic initialization ************************
  23.  
  24. BaseRoot root = new BaseRoot();
  25.  
  26. BaseChild child = new BaseChild();
  27. child.setName("someChildName");
  28.  
  29. ChildContents content = new ChildContents();
  30. content.setName(c.getName());
  31. content.setId(c.getId());
  32. child.getContents().add(content);
  33.  
  34. ChildCharacteristics chars = new ChildCharacteristics();
  35. ChildDescriptor desc = new ChildDescriptor();
  36. desc.setCommonName("someDescriptor");
  37. chars.setDescriptor(desc);
  38.  
  39. chars.setId(database.getCharId());
  40. chars.setValue(database.getCharValue());
  41.  
  42. child.setCharacteristics(chars);
  43.  
  44. root.setChild(child);
  45. root.setName("someName");
  46. root.setId(database.getRootId());
  47.  
  48. //******************* Using weird brace initialization ************************
  49.  
  50. BaseRoot root = new BaseRoot();
  51. {
  52.     BaseChild child = new BaseChild();
  53.     {
  54.         child.setName("someChildName");
  55.  
  56.         ChildContents content = new ChildContents();
  57.         {
  58.             content.setName(c.getName());
  59.             content.setId(c.getId());
  60.         }
  61.         child.getContents().add(content);
  62.  
  63.         ChildCharacteristics chars = new ChildCharacteristics();
  64.         {
  65.             ChildDescriptor desc = new ChildDescriptor();
  66.             {
  67.                 desc.setCommonName("someDescriptor");
  68.             }
  69.             chars.setDescriptor(desc);
  70.  
  71.             chars.setId(database.getCharId());
  72.             chars.setValue(database.getCharValue());
  73.         }
  74.  
  75.         child.setCharacteristics(chars);
  76.     }
  77.  
  78.     root.setChild(child);
  79.     root.setName("someName");
  80.     root.setId(database.getRootId());
  81. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement