Set resultSet = new HashSet(resultList);
Set resultSet = new HashSet(resultList); Set editedSet = new HashSet(); editedSet.addAll(resultSet);
 Set findDuplicates(Assignment assignment) {   Query query;   List resultList;   try   {     query = session         .createQuery           ("from edu.internet2.middleware.signet.AssignmentImpl"            + " as assignment"            + " where granteeID = :granteeId"            + " and granteeTypeID = :granteeTypeId"            + " and functionID = :functionId"            + " and subsystemID = :subsystemId"            + " and scopeID = :scopeId"            + " and scopeNodeID = :scopeNodeId"            + " and assignmentID != :assignmentId");     query.setString       ("granteeId", assignment.getGrantee().getSubjectId());     query.setString       ("granteeTypeId", assignment.getGrantee().getSubjectTypeId());     query.setString       ("functionId", assignment.getFunction().getId());     query.setString       ("subsystemId", assignment.getFunction().getSubsystem().getId());     query.setString       ("scopeId", assignment.getScope().getTree().getId());     query.setString       ("scopeNodeId", assignment.getScope().getId());     query.setInteger       ("assignmentId",        (assignment.getId() == null ? -1 : assignment.getId().intValue()));     resultList = query.list();   }   catch (HibernateException e)   {     throw new SignetRuntimeException(e);   }   Set resultSet = new HashSet(resultList);   Iterator resultSetIterator = resultSet.iterator();   while (resultSetIterator.hasNext())   {     Assignment matchedAssignment = (Assignment) (resultSetIterator.next());     ((AssignmentImpl) matchedAssignment).setSignet(this);          // Now, let's trim this set of Assignments down further, keeping only     // those Assignments whose LimitValues actually match.          if (!(assignment.getLimitValues()           .equals(matchedAssignment.getLimitValues())))     {       resultSet.remove(matchedAssignment);     }   }   return resultSet; }