    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
    035    /**
    036     * Constructor
    037     *
    038     * @param area academic area
    039     * @param classification academic classification
    040     * @param major major
    041     */
    042    public AreaClassificationMajor(String area, String classification, String major) {
    043        iArea = area;
    044        iClassification = classification;
    045        iMajor = major;
    046    }
    047
    048    /**
    049     * Constructor
    050     *
    051     * @param area academic area
    052     * @param classification academic classification
    053     * @param major major
    054     * @param concentration concentration (optional)
    055     */
    056    public AreaClassificationMajor(String area, String classification, String major, String concentration) {
    057        iArea = area;
    058        iClassification = classification;
    059        iMajor = major;
    060        iConcentration = concentration;
    061    }
    062
    063    /**
    064     * Constructor
    065     *
    066     * @param area academic area
    067     * @param classification academic classification
    068     * @param major major
    069     * @param concentration concentration (optional)
    070     * @param weight weight (optional)
    071     */
    072    public AreaClassificationMajor(String area, String classification, String major, String concentration, Double weight) {
    073        iArea = area;
    074        iClassification = classification;
    075        iMajor = major;
    076        iConcentration = concentration;
    077        iWeight = weight;
    078    }
    079
    080    /**
    081     * Constructor
    082     *
    083     * @param areaCode academic area abbreviation
    084     * @param areaName academic area name
    085     * @param classificationCode academic classificationCode
    086     * @param classificationName academic classificationName
    087     * @param majorCode major code
    088     * @param majorName major name
    089     */
    090    public AreaClassificationMajor(String areaCode, String areaName, String classificationCode, String classificationName, String majorCode, String majorName) {
    091        iArea = areaCode;
    092        iAreaName = areaName;
    093        iClassification = classificationCode;
    094        iClassificationName = classificationName;
    095        iMajor = majorCode;
    096        iMajorName = majorName;
    097    }
    098
    099    /**
    100     * Constructor
    101     *
    102     * @param areaCode academic area abbreviation
    103     * @param areaName academic area name
    104     * @param classificationCode academic classificationCode
    105     * @param classificationName academic classificationName
    106     * @param majorCode major code
    107     * @param majorName major name
    108     * @param concentrationCode concentration (optional)
    109     * @param concentrationName concentration (optional)
    110     */
    111    public AreaClassificationMajor(String areaCode, String areaName, String classificationCode, String classificationName, String majorCode, String majorName, String concentrationCode, String concentrationName) {
    112        iArea = areaCode;
    113        iAreaName = areaName;
    114        iClassification = classificationCode;
    115        iClassificationName = classificationName;
    116        iMajor = majorCode;
    117        iMajorName = majorName;
    118        iConcentration = concentrationCode;
    119        iConcentrationName = concentrationName;
    120    }
    121
    122    /**
    123     * Constructor
    124     *
    125     * @param areaCode academic area abbreviation
    126     * @param areaName academic area name
    127     * @param classificationCode academic classificationCode
    128     * @param classificationName academic classificationName
    129     * @param majorCode major code
    130     * @param majorName major name
    131     * @param concentrationCode concentration (optional)
    132     * @param concentrationName concentration (optional)
    133     * @param weight weight (optional)
    134     */
    135    public AreaClassificationMajor(String areaCode, String areaName, String classificationCode, String classificationName, String majorCode, String majorName, String concentrationCode, String concentrationName, Double weight) {
    136        iArea = areaCode;
    137        iAreaName = areaName;
    138        iClassification = classificationCode;
    139        iClassificationName = classificationName;
    140        iMajor = majorCode;
    141        iMajorName = majorName;
    142        iConcentration = concentrationCode;
    143        iConcentrationName = concentrationName;
    144        iWeight = weight;
    145    }
    146
    147    /**
    148     * Constructor
    149     *
    150     * @param areaCode academic area abbreviation
    151     * @param areaName academic area name
    152     * @param classificationCode academic classificationCode
    153     * @param classificationName academic classificationName
    154     * @param majorCode major code
    155     * @param majorName major name
    156     * @param concentrationCode concentration (optional)
    157     * @param concentrationName concentration (optional)
    158     * @param degreeCode degree (optional)
    159     * @param degreeName degree (optional)
    160     * @param weight weight (optional)
    161     */
    162    public AreaClassificationMajor(
    163            String areaCode, String areaName,
    164            String classificationCode, String classificationName,
    165            String majorCode, String majorName,
    166            String concentrationCode, String concentrationName,
    167            String degreeCode, String degreeName,
    168            Double weight) {
    169        iArea = areaCode;
    170        iAreaName = areaName;
    171        iClassification = classificationCode;
    172        iClassificationName = classificationName;
    173        iMajor = majorCode;
    174        iMajorName = majorName;
    175        iConcentration = concentrationCode;
    176        iConcentrationName = concentrationName;
    177        iDegree = degreeCode;
    178        iDegreeName = degreeName;
    179        iWeight = weight;
    180    }
    181
    182    /** Academic area
    183     * @return academic area abbreviation
    184     **/
    185    public String getArea() {
    186        return iArea;
    187    }
    188
    189    /** Academic classification
    190     * @return classification code
    191     **/
    192    public String getClassification() {
    193        return iClassification;
    194    }
    195
    196    /** Major
    197     * @return major code
    198     **/
    199    public String getMajor() {
    200        return iMajor;
    201    }
    202
    203    /** Concentration (optional)
    204     * @return concentration code
    205     **/
    206    public String getConcentration() {
    207        return iConcentration;
    208    }
    209
    210    /** Degree (optional)
    211     * @return degree code
    212     **/
    213    public String getDegree() {
    214        return iDegree;
    215    }
    216
    217    /** Academic area  name
    218     * @return academic area name
    219     **/
    220    public String getAreaName() {
    221        return iAreaName;
    222    }
    223
    224    /** Academic classification name
    225     * @return classification name
    226     **/
    227    public String getClassificationName() {
    228        return iClassificationName;
    229    }
    230
    231    /** Major name
    232     * @return major name
    233     **/
    234    public String getMajorName() {
    235        return iMajorName;
    236    }
    237
    238    /** Concentration (optional)
    239     * @return concentration name
    240     **/
    241    public String getConcentrationName() {
    242        return iConcentrationName;
    243    }
    244
    245    /** Degree (optional)
    246     * @return degree name
    247     **/
    248    public String getDegreeName() {
    249        return iDegreeName;
    250    }
    251
    252    /** Weight (optional, defaults to 1.0)
    253     */
    254    public double getWeight() { return iWeight == null ? 1.0 : iWeight.doubleValue(); }
    255
    256    @Override
    257    public int hashCode() {
    258        return toString().hashCode();
    259    }
    260
    261    @Override
    262    public boolean equals(Object o) {
    263        if (o == null || !(o instanceof AreaClassificationMajor))
    264            return false;
    265        AreaClassificationMajor acm = (AreaClassificationMajor) o;
    266        return ToolBox.equals(acm.getArea(), getArea()) && ToolBox.equals(acm.getClassification(), getClassification()) && ToolBox.equals(acm.getMajor(), getMajor());
    267    }
    268
    269    @Override
    270    public String toString() {
    271        return getArea() + "/" + getMajor() + (getConcentration() == null || getConcentration().isEmpty()? "" : "-" + getConcentration()) + " " + getClassification();
    272    }
    273}