001package org.cpsolver.studentsct.model;
002
003import org.cpsolver.ifs.util.ToolBox;
004
005/**
006 * Academic area and code. This class is used for
007 * {@link Student#getAcademicAreaClasiffications()}, {@link Student#getMajors()}
008 * , and {@link Student#getMinors()}. <br>
009 * <br>
010 * 
011 * @version StudentSct 1.3 (Student Sectioning)<br>
012 *          Copyright (C) 2007 - 2014 Tomas Muller<br>
013 *          <a href="mailto:muller@unitime.org">muller@unitime.org</a><br>
014 *          <a href="http://muller.unitime.org">http://muller.unitime.org</a><br>
015 * <br>
016 *          This library is free software; you can redistribute it and/or modify
017 *          it under the terms of the GNU Lesser General Public License as
018 *          published by the Free Software Foundation; either version 3 of the
019 *          License, or (at your option) any later version. <br>
020 * <br>
021 *          This library is distributed in the hope that it will be useful, but
022 *          WITHOUT ANY WARRANTY; without even the implied warranty of
023 *          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
024 *          Lesser General Public License for more details. <br>
025 * <br>
026 *          You should have received a copy of the GNU Lesser General Public
027 *          License along with this library; if not see
028 *          <a href='http://www.gnu.org/licenses/'>http://www.gnu.org/licenses/</a>.
029 */
030public class AcademicAreaCode {
031    private String iArea, iCode;
032
033    /**
034     * Constructor
035     * 
036     * @param area
037     *            academic area
038     * @param code
039     *            code
040     */
041    public AcademicAreaCode(String area, String code) {
042        iArea = area;
043        iCode = code;
044    }
045
046    /** Academic area 
047     * @return academic area abbreviation
048     **/
049    public String getArea() {
050        return iArea;
051    }
052
053    /** Code 
054     * @return classification code
055     **/
056    public String getCode() {
057        return iCode;
058    }
059
060    @Override
061    public int hashCode() {
062        return (iArea + ":" + iCode).hashCode();
063    }
064
065    @Override
066    public boolean equals(Object o) {
067        if (o == null || !(o instanceof AcademicAreaCode))
068            return false;
069        AcademicAreaCode aac = (AcademicAreaCode) o;
070        return ToolBox.equals(aac.getArea(), getArea()) && ToolBox.equals(aac.getCode(), getCode());
071    }
072
073    @Override
074    public String toString() {
075        return getArea() + ":" + getCode();
076    }
077}