    001package org.cpsolver.studentsct.model;
    002
    003import org.cpsolver.ifs.util.ToolBox;
    004
    005/**
    006 * Academic area, classification, and major code. This class is used for
    007 * {@link Student#getAreaClassificationMajors()}. <br>
    008 * <br>
    009 *
    010 * @version StudentSct 1.3 (Student Sectioning)<br>
    011 *          Copyright (C) 2007 - 2014 Tomáš Müller<br>
    012 *          <a href="mailto:muller@unitime.org">muller@unitime.org</a><br>
    013 *          <a href="http://muller.unitime.org">http://muller.unitime.org</a><br>
    014 * <br>
    015 *          This library is free software; you can redistribute it and/or modify
    016 *          it under the terms of the GNU Lesser General Public License as
    017 *          published by the Free Software Foundation; either version 3 of the
    018 *          License, or (at your option) any later version. <br>
    019 * <br>
    020 *          This library is distributed in the hope that it will be useful, but
    021 *          WITHOUT ANY WARRANTY; without even the implied warranty of
    022 *          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    023 *          Lesser General Public License for more details. <br>
    024 * <br>
    025 *          You should have received a copy of the GNU Lesser General Public
    026 *          License along with this library; if not see
    027 *          <a href='http://www.gnu.org/licenses/'>http://www.gnu.org/licenses/</a>.
    028 */
    029public class AreaClassificationMajor {
    030    private String iArea, iClassification, iMajor, iConcentration;
    031    private String iAreaName, iClassificationName, iMajorName, iConcentrationName;
    032    private Double iWeight;
    033    private String iDegree, iDegreeName;
    034    private String iProgram, iProgramName;
    035
    036    /**
    037     * Constructor
    038     *
    039     * @param area academic area
    040     * @param classification academic classification
    041     * @param major major
    042     */
    043    public AreaClassificationMajor(String area, String classification, String major) {
    044        iArea = area;
    045        iClassification = classification;
    046        iMajor = major;
    047    }
    048
    049    /**
    050     * Constructor
    051     *
    052     * @param area academic area
    053     * @param classification academic classification
    054     * @param major major
    055     * @param concentration concentration (optional)
    056     */
    057    public AreaClassificationMajor(String area, String classification, String major, String concentration) {
    058        iArea = area;
    059        iClassification = classification;
    060        iMajor = major;
    061        iConcentration = concentration;
    062    }
    063
    064    /**
    065     * Constructor
    066     *
    067     * @param area academic area
    068     * @param classification academic classification
    069     * @param major major
    070     * @param concentration concentration (optional)
    071     * @param weight weight (optional)
    072     */
    073    public AreaClassificationMajor(String area, String classification, String major, String concentration, Double weight) {
    074        iArea = area;
    075        iClassification = classification;
    076        iMajor = major;
    077        iConcentration = concentration;
    078        iWeight = weight;
    079    }
    080
    081    /**
    082     * Constructor
    083     *
    084     * @param areaCode academic area abbreviation
    085     * @param areaName academic area name
    086     * @param classificationCode academic classificationCode
    087     * @param classificationName academic classificationName
    088     * @param majorCode major code
    089     * @param majorName major name
    090     */
    091    public AreaClassificationMajor(String areaCode, String areaName, String classificationCode, String classificationName, String majorCode, String majorName) {
    092        iArea = areaCode;
    093        iAreaName = areaName;
    094        iClassification = classificationCode;
    095        iClassificationName = classificationName;
    096        iMajor = majorCode;
    097        iMajorName = majorName;
    098    }
    099
    100    /**
    101     * Constructor
    102     *
    103     * @param areaCode academic area abbreviation
    104     * @param areaName academic area name
    105     * @param classificationCode academic classificationCode
    106     * @param classificationName academic classificationName
    107     * @param majorCode major code
    108     * @param majorName major name
    109     * @param concentrationCode concentration (optional)
    110     * @param concentrationName concentration (optional)
    111     */
    112    public AreaClassificationMajor(String areaCode, String areaName, String classificationCode, String classificationName, String majorCode, String majorName, String concentrationCode, String concentrationName) {
    113        iArea = areaCode;
    114        iAreaName = areaName;
    115        iClassification = classificationCode;
    116        iClassificationName = classificationName;
    117        iMajor = majorCode;
    118        iMajorName = majorName;
    119        iConcentration = concentrationCode;
    120        iConcentrationName = concentrationName;
    121    }
    122
    123    /**
    124     * Constructor
    125     *
    126     * @param areaCode academic area abbreviation
    127     * @param areaName academic area name
    128     * @param classificationCode academic classificationCode
    129     * @param classificationName academic classificationName
    130     * @param majorCode major code
    131     * @param majorName major name
    132     * @param concentrationCode concentration (optional)
    133     * @param concentrationName concentration (optional)
    134     * @param weight weight (optional)
    135     */
    136    public AreaClassificationMajor(String areaCode, String areaName, String classificationCode, String classificationName, String majorCode, String majorName, String concentrationCode, String concentrationName, Double weight) {
    137        iArea = areaCode;
    138        iAreaName = areaName;
    139        iClassification = classificationCode;
    140        iClassificationName = classificationName;
    141        iMajor = majorCode;
    142        iMajorName = majorName;
    143        iConcentration = concentrationCode;
    144        iConcentrationName = concentrationName;
    145        iWeight = weight;
    146    }
    147
    148    /**
    149     * Constructor
    150     *
    151     * @param areaCode academic area abbreviation
    152     * @param areaName academic area name
    153     * @param classificationCode academic classificationCode
    154     * @param classificationName academic classificationName
    155     * @param majorCode major code
    156     * @param majorName major name
    157     * @param concentrationCode concentration (optional)
    158     * @param concentrationName concentration (optional)
    159     * @param degreeCode degree (optional)
    160     * @param degreeName degree (optional)
    161     * @param weight weight (optional)
    162     */
    163    public AreaClassificationMajor(
    164            String areaCode, String areaName,
    165            String classificationCode, String classificationName,
    166            String majorCode, String majorName,
    167            String concentrationCode, String concentrationName,
    168            String degreeCode, String degreeName,
    169            Double weight) {
    170        iArea = areaCode;
    171        iAreaName = areaName;
    172        iClassification = classificationCode;
    173        iClassificationName = classificationName;
    174        iMajor = majorCode;
    175        iMajorName = majorName;
    176        iConcentration = concentrationCode;
    177        iConcentrationName = concentrationName;
    178        iDegree = degreeCode;
    179        iDegreeName = degreeName;
    180        iWeight = weight;
    181    }
    182
    183    /**
    184     * Constructor
    185     *
    186     * @param areaCode academic area abbreviation
    187     * @param areaName academic area name
    188     * @param classificationCode academic classificationCode
    189     * @param classificationName academic classificationName
    190     * @param majorCode major code
    191     * @param majorName major name
    192     * @param concentrationCode concentration (optional)
    193     * @param concentrationName concentration (optional)
    194     * @param degreeCode degree (optional)
    195     * @param degreeName degree (optional)
    196     * @param programCode program (optional)
    197     * @param programName program (optional)
    198     * @param weight weight (optional)
    199     */
    200    public AreaClassificationMajor(
    201            String areaCode, String areaName,
    202            String classificationCode, String classificationName,
    203            String majorCode, String majorName,
    204            String concentrationCode, String concentrationName,
    205            String degreeCode, String degreeName,
    206            String programCode, String programName,
    207            Double weight) {
    208        iArea = areaCode;
    209        iAreaName = areaName;
    210        iClassification = classificationCode;
    211        iClassificationName = classificationName;
    212        iMajor = majorCode;
    213        iMajorName = majorName;
    214        iConcentration = concentrationCode;
    215        iConcentrationName = concentrationName;
    216        iDegree = degreeCode;
    217        iDegreeName = degreeName;
    218        iProgram = programCode;
    219        iProgramName = programName;
    220        iWeight = weight;
    221    }
    222
    223    /** Academic area
    224     * @return academic area abbreviation
    225     **/
    226    public String getArea() {
    227        return iArea;
    228    }
    229
    230    /** Academic classification
    231     * @return classification code
    232     **/
    233    public String getClassification() {
    234        return iClassification;
    235    }
    236
    237    /** Major
    238     * @return major code
    239     **/
    240    public String getMajor() {
    241        return iMajor;
    242    }
    243
    244    /** Concentration (optional)
    245     * @return concentration code
    246     **/
    247    public String getConcentration() {
    248        return iConcentration;
    249    }
    250
    251    /** Degree (optional)
    252     * @return degree code
    253     **/
    254    public String getDegree() {
    255        return iDegree;
    256    }
    257
    258    /** Program (optional)
    259     * @return program code
    260     **/
    261    public String getProgram() {
    262        return iProgram;
    263    }
    264
    265    /** Academic area  name
    266     * @return academic area name
    267     **/
    268    public String getAreaName() {
    269        return iAreaName;
    270    }
    271
    272    /** Academic classification name
    273     * @return classification name
    274     **/
    275    public String getClassificationName() {
    276        return iClassificationName;
    277    }
    278
    279    /** Major name
    280     * @return major name
    281     **/
    282    public String getMajorName() {
    283        return iMajorName;
    284    }
    285
    286    /** Concentration (optional)
    287     * @return concentration name
    288     **/
    289    public String getConcentrationName() {
    290        return iConcentrationName;
    291    }
    292
    293    /** Degree (optional)
    294     * @return degree name
    295     **/
    296    public String getDegreeName() {
    297        return iDegreeName;
    298    }
    299
    300    /** Program (optional)
    301     * @return program name
    302     **/
    303    public String getProgramName() {
    304        return iProgramName;
    305    }
    306
    307    /** Weight (optional, defaults to 1.0)
    308     */
    309    public double getWeight() { return iWeight == null ? 1.0 : iWeight.doubleValue(); }
    310
    311    @Override
    312    public int hashCode() {
    313        return toString().hashCode();
    314    }
    315
    316    @Override
    317    public boolean equals(Object o) {
    318        if (o == null || !(o instanceof AreaClassificationMajor))
    319            return false;
    320        AreaClassificationMajor acm = (AreaClassificationMajor) o;
    321        return ToolBox.equals(acm.getArea(), getArea()) && ToolBox.equals(acm.getClassification(), getClassification()) && ToolBox.equals(acm.getMajor(), getMajor());
    322    }
    323
    324    @Override
    325    public String toString() {
    326        return getArea() + "/" + getMajor() + (getConcentration() == null || getConcentration().isEmpty()? "" : "-" + getConcentration()) + " " + getClassification();
    327    }
    328}