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 * @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 StudentGroup { 030 private String iType, iReference, iName; 031 032 /** 033 * Constructor 034 * 035 * @param type group type (can be empty) 036 * @param reference group reference 037 * @param name group name 038 */ 039 public StudentGroup(String type, String reference, String name) { 040 iType = type; 041 iReference = reference; 042 iName = name; 043 } 044 045 /** Group type 046 * @return group type reference 047 **/ 048 public String getType() { 049 return iType; 050 } 051 052 /** Group reference 053 * @return group reference 054 **/ 055 public String getReference() { 056 return iReference; 057 } 058 059 /** Group name 060 * @return group name 061 **/ 062 public String getName() { 063 return iName; 064 } 065 066 @Override 067 public int hashCode() { 068 return toString().hashCode(); 069 } 070 071 @Override 072 public boolean equals(Object o) { 073 if (o == null || !(o instanceof StudentGroup)) 074 return false; 075 StudentGroup acm = (StudentGroup) o; 076 return ToolBox.equals(acm.getType(), getType()) && ToolBox.equals(acm.getReference(), getReference()) && ToolBox.equals(acm.getName(), getName()); 077 } 078 079 @Override 080 public String toString() { 081 return getReference() + (getType() == null || getType().isEmpty() ? "" : " (" + getType() + ")"); 082 } 083}