001    package net.sf.cpsolver.studentsct.model;
002    
003    import net.sf.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.2 (Student Sectioning)<br>
012     *          Copyright (C) 2007 - 2010 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     */
030    public 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        public String getArea() {
048            return iArea;
049        }
050    
051        /** Code */
052        public String getCode() {
053            return iCode;
054        }
055    
056        @Override
057        public int hashCode() {
058            return (iArea + ":" + iCode).hashCode();
059        }
060    
061        @Override
062        public boolean equals(Object o) {
063            if (o == null || !(o instanceof AcademicAreaCode))
064                return false;
065            AcademicAreaCode aac = (AcademicAreaCode) o;
066            return ToolBox.equals(aac.getArea(), getArea()) && ToolBox.equals(aac.getCode(), getCode());
067        }
068    
069        @Override
070        public String toString() {
071            return getArea() + ":" + getCode();
072        }
073    }