Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private List<NprDto> getUniqueAccountList(List<NprDto> nonUniqueAccountList) throws Exception {
- Map<Long,NprDto> uniqueAccountsMapList = new HashMap<Long,NprDto>();
- List<NprDto> uniqueAccountsList = null;
- if(nonUniqueAccountList != null && !nonUniqueAccountList.isEmpty()) {
- for(NprDto nprDto : nonUniqueAccountList) {
- uniqueAccountsMapList.put(Long.valueOf(nprDto.getAccountId()), nprDto);
- }
- }
- uniqueAccountsList = new ArrayList<NprDto>(uniqueAccountsMapList.values());
- return uniqueAccountsList;
- }
- class NprDto{
- Long accountId;
- .......
- @Override
- public boolean equals(Object obj) {
- NproDto other=(NproDto) obj;
- return this.accountId==other.accountId;
- }
- @Override
- public int hashCode() {
- return accountId.hashCode();
- }
- }
- private Set<NprDto> getUniqueAccountSet(){
- Map<Long,NprDto> uniqueAccountsMapList = new HashMap<Long,NprDto>();
- Set<NprDto> uniqueAccounts = new HashSet<NprDto>(uniqueAccountsMapList.values());
- return uniqueAccounts;
- }
- private List<NprDto> getUniqueAccountList(List<NprDto> nonUniqueAccountList) {
- return new ArrayList<NprDto>(new LinkedHashSet<NprDto>(nonUniqueAccountList));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement