Advertisement
Guest User

Untitled

a guest
May 22nd, 2012
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.94 KB | None | 0 0
  1.     public List<DBInput> getDistinctDBIn() {
  2.         if (distinctIn == null) {
  3.             synchronized(this) {
  4.                 if (getIn() == null)
  5.                     return null;
  6.  
  7.                 List<DBInput> distinctIn = new ArrayList<DBInput>(getIn().size());
  8.  
  9.                 for (DBInput input : getDBIn()) {
  10.  
  11.                     if (input == null)
  12.                         continue;
  13.  
  14.                     if (input.getDBPrevOut() == null) {
  15.                         distinctIn.add(input);
  16.                         continue;
  17.                     }
  18.  
  19.                     boolean found = false;
  20.                     for (DBInput existing : distinctIn) {
  21.  
  22.                         if (existing == null || existing.getDBPrevOut() == null)
  23.                             continue;
  24.  
  25.                         if (existing.getDBPrevOut().getAddress() != null && existing.getDBPrevOut().getAddress().equals(input.getDBPrevOut().getAddress())) {                      
  26.                             found = true;
  27.                             existing.value += input.getPrevOut().value;
  28.                             break;
  29.                         }
  30.                     }
  31.  
  32.                     if (!found) {                  
  33.                         distinctIn.add(input);
  34.                     }
  35.                 }
  36.  
  37.                 this.distinctIn = distinctIn;
  38.             }
  39.         }
  40.  
  41.         return distinctIn;
  42.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement