    001package org.cpsolver.instructor.model;
    002
    003/**
    004 * Course of a teaching request. If a course is marked as exclusive, all assignments of an instructor must have
    005 * the same course. It is also possible to mark the course as same common, which require all assignments that are
    006 * given to a single instructor to share the same common part of the course (e.g., the lecture).
    007 *
    008 * @version IFS 1.3 (Instructor Sectioning)<br>
    009 *          Copyright (C) 2016 Tomáš Müller<br>
    010 *          <a href="mailto:muller@unitime.org">muller@unitime.org</a><br>
    011 *          <a href="http://muller.unitime.org">http://muller.unitime.org</a><br>
    012 * <br>
    013 *          This library is free software; you can redistribute it and/or modify
    014 *          it under the terms of the GNU Lesser General Public License as
    015 *          published by the Free Software Foundation; either version 3 of the
    016 *          License, or (at your option) any later version. <br>
    017 * <br>
    018 *          This library is distributed in the hope that it will be useful, but
    019 *          WITHOUT ANY WARRANTY; without even the implied warranty of
    020 *          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    021 *          Lesser General Public License for more details. <br>
    022 * <br>
    023 *          You should have received a copy of the GNU Lesser General Public
    024 *          License along with this library; if not see
    025 *          <a href='http://www.gnu.org/licenses/'>http://www.gnu.org/licenses/</a>.
    026 */
    027public class Course {
    028    private Long iCourseId;
    029    private String iCourseName;
    030
    031    /**
    032     * Constructor
    033     * @param courseId course id
    034     * @param courseName course name
    035     */
    036    public Course(long courseId, String courseName) {
    037        iCourseId = courseId; iCourseName = courseName;
    038    }
    039
    040    /**
    041     * Course id that was provided in the constructor
    042     * @return course id
    043     */
    044    public Long getCourseId() { return iCourseId; }
    045
    046    /**
    047     * Course name that was provided in the constructor
    048     * @return course name
    049     */
    050    public String getCourseName() { return iCourseName == null ? "C" + iCourseId : iCourseName; }
    051
    052    @Override
    053    public int hashCode() {
    054        return getCourseId().hashCode();
    055    }
    056
    057    @Override
    058    public boolean equals(Object o) {
    059        if (o == null || !(o instanceof Course)) return false;
    060        Course c = (Course)o;
    061        return getCourseId().equals(c.getCourseId());
    062    }
    063
    064    @Override
    065    public String toString() { return getCourseName(); }
    066}