Skip to content

Instantly share code, notes, and snippets.

@astericky
Created June 13, 2013 16:25
Show Gist options
  • Save astericky/5775128 to your computer and use it in GitHub Desktop.
Save astericky/5775128 to your computer and use it in GitHub Desktop.
I am trying to turn the commented out line into the whole body of the function. It seems a lot easier than what is here. I tried though and failed to get it to work properly. also note ---> http://www.docjar.com/html/api/java/util/HashMap.java.html#631
public class ResumeRepository
{
private final Map<Integer, List<Resume>> resumes;
public ResumeRepository()
{
this.resumes = new HashMap<>();
}
public Resume saveResume(int jobseekerId, Resume resume)
{
addResumeForJobseeker(jobseekerId, resume);
return resume;
}
public boolean contains(Resume aResume)
{
for(int key : resumes.keySet())
{
for(Resume resume : resumes.get(key))
{
if (aResume.equals(resume)) return true;
}
}
return false;
//return resumes.containsValue(aResume);
}
private void addResumeForJobseeker(int jobseekerId, Resume resume)
{
List<Resume> jsResumes = resumes.get(jobseekerId);
if (jsResumes == null)
{
jsResumes = new ArrayList<>();
}
jsResumes.add(resume);
resumes.put(jobseekerId, jsResumes);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment