SHARE
TWEET

Untitled

a guest Jun 26th, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 1 :  public class Main {
  2. 2 :      public static void main(String[] args) {
  3. 3 :         CombinedData combinedData = new CombinedData();
  4. 4 :          List<String> nameList = Arrays.asList("x1","x3","x2");
  5. 5 :          nameList.parallelStream().forEach(name ->{
  6. 6 :              populateDetails(name,combinedData);
  7. 7 :          });
  8. 8 :      }
  9. 9 :      static void log(String str){
  10. 10:          System.out.println(str);
  11. 11:      }
  12. 12:  static void populateDetails(String name,CombinedData combinedData){
  13. 13:      if(combinedData.getOrg()!=null){
  14. 14:          combinedData.setOrg(MyUtil.getOrg(name));
  15. 15:      }
  16. 16:      if(combinedData.getRawData()!=null){
  17. 17:          combinedData.setRawData(combinedData.getRawData()+name);
  18. 18:      }
  19. 19:      combinedData.addToDetails(new Details(name,MyUtil.getAdd(name)));
  20. 20:  }
  21. 21:  }
  22. 22:  class CombinedData{
  23. 23:     private String org;
  24. 24:     private List<Details> details;
  25. 25:     private String rawData;
  26. 26:  
  27. 27:      public String getOrg() {
  28. 28:          return org;
  29. 29:      }
  30. 30:  
  31. 31:      public void setOrg(String org) {
  32. 32:          this.org = org;
  33. 33:      }
  34. 34:      public void addToDetails(Details details){
  35. 35:          this.details.add(details);
  36. 36:      }
  37. 37:  
  38. 38:      public List<Details> getDetails() {
  39. 39:          return details;
  40. 40:      }
  41. 41:  
  42. 42:      public void setDetails(List<Details> details) {
  43. 43:          this.details = details;
  44. 44:      }
  45. 45:  
  46. 46:      public String getRawData() {
  47. 47:          return rawData;
  48. 48:      }
  49. 49:  
  50. 50:      public void setRawData(String rawData) {
  51. 51:          this.rawData = rawData;
  52. 52:      }
  53. 53:  }
  54. 54:  
  55. 55:  class Details
  56. 56:  {
  57. 57:      private String name;
  58. 58:      private String address;
  59. 59:  
  60. 60:      public Details(
  61. 61:              String name,
  62. 62:              String address) {
  63. 63:          this.name = name;
  64. 64:          this.address = address;
  65. 65:      }
  66. 66:  
  67. 67:      public String getName() {
  68. 68:          return name;
  69. 69:      }
  70. 70:  
  71. 71:      public void setName(String name) {
  72. 72:          this.name = name;
  73. 73:      }
  74. 74:  
  75. 75:      public String getAddress() {
  76. 76:          return address;
  77. 77:      }
  78. 78:  
  79. 79:      public void setAddress(String address) {
  80. 80:          this.address = address;
  81. 81:      }
  82. 82:  }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top