package net.sourceforge.fenixedu.domain.candidacy; import java.io.Serializable; import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.ResourceBundle; import java.util.Set; import org.apache.commons.lang.StringUtils; import net.sourceforge.fenixedu.util.LanguageUtils; import pt.ist.fenixWebFramework.rendererExtensions.util.IPresentableEnum; import pt.ist.fenixWebFramework.renderers.DataProvider; import pt.ist.fenixWebFramework.renderers.components.converters.Converter; public class QualificationsBag implements Serializable { public static class SupportedQualificationsProvider implements DataProvider { public Object provide(Object source, Object currentValue) { return Arrays.asList(SupportedQualification.values()); } public Converter getConverter() { return null; } } public static enum SupportedQualification implements IPresentableEnum { FINISHING_DEGREE, DEGREE, POST_GRADUATION, PHD, MASTER_DEGREE, TECHNICAL_SPECIALIZATION_COURSE, OTHER; public String getLocalizedName() { return ResourceBundle.getBundle("resources.CandidateResources", LanguageUtils.getLocale()).getString( "label.SupportedQualifications." + name()); } } private Set qualifications; public Set getSupportedQualifications() { return this.qualifications; } public QualificationsBag(List qualifications) { this.qualifications = new HashSet(); for (SupportedQualification qualification : qualifications) { this.qualifications.add(qualification); } } public QualificationsBag(String internalizeString) { this.qualifications = new HashSet(); if (!StringUtils.isEmpty(internalizeString)) { String[] values = internalizeString.split("\\."); for (String value : values) { this.qualifications.add(SupportedQualification.valueOf(value)); } } } public String externalize() { StringBuilder builder = new StringBuilder(); for (SupportedQualification qualification : qualifications) { if (builder.length() > 0) { builder.append("."); } builder.append(qualification.name()); } return builder.toString(); } public boolean hasQualification(SupportedQualification qualification) { return qualifications.contains(qualification); } }