    001package org.cpsolver.studentsct.model;
    002
    003import org.cpsolver.ifs.util.ToolBox;
    004
    005/**
    006 * Student group type, reference and name. This class is used for
    007 * {@link Student#getGroups()}. <br>
    008 * <br>
    009 *
    010 * @author  Tomáš Müller
    011 * @version StudentSct 1.3 (Student Sectioning)<br>
    012 *          Copyright (C) 2007 - 2014 Tomáš Müller<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 StudentGroup {
    031    private String iType, iReference, iName;
    032
    033    /**
    034     * Constructor
    035     *
    036     * @param type group type (can be empty)
    037     * @param reference group reference
    038     * @param name group name
    039     */
    040    public StudentGroup(String type, String reference, String name) {
    041        iType = type;
    042        iReference = reference;
    043        iName = name;
    044    }
    045
    046    /** Group type
    047     * @return group type reference
    048     **/
    049    public String getType() {
    050        return iType;
    051    }
    052
    053    /** Group reference
    054     * @return group reference
    055     **/
    056    public String getReference() {
    057        return iReference;
    058    }
    059
    060    /** Group name
    061     * @return group name
    062     **/
    063    public String getName() {
    064        return iName;
    065    }
    066
    067    @Override
    068    public int hashCode() {
    069        return toString().hashCode();
    070    }
    071
    072    @Override
    073    public boolean equals(Object o) {
    074        if (o == null || !(o instanceof StudentGroup))
    075            return false;
    076        StudentGroup acm = (StudentGroup) o;
    077        return ToolBox.equals(acm.getType(), getType()) && ToolBox.equals(acm.getReference(), getReference()) && ToolBox.equals(acm.getName(), getName());
    078    }
    079
    080    @Override
    081    public String toString() {
    082        return getReference() + (getType() == null || getType().isEmpty() ? "" : " (" + getType() + ")");
    083    }
    084}