001package org.cpsolver.studentsct.model; 002 003import org.cpsolver.ifs.util.ToolBox; 004 005/** 006 * Academic area and code. This class is used for 007 * {@link Student#getAcademicAreaClasiffications()}, {@link Student#getMajors()} 008 * , and {@link Student#getMinors()}. <br> 009 * <br> 010 * 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 AcademicAreaCode { 031 private String iArea, iCode, iLabel; 032 033 /** 034 * Constructor 035 * 036 * @param area 037 * academic area 038 * @param code 039 * code 040 */ 041 public AcademicAreaCode(String area, String code) { 042 iArea = area; 043 iCode = code; 044 } 045 046 public AcademicAreaCode(String area, String code, String label) { 047 iArea = area; 048 iCode = code; 049 iLabel = label; 050 } 051 052 /** Academic area 053 * @return academic area abbreviation 054 **/ 055 public String getArea() { 056 return iArea; 057 } 058 059 /** Code 060 * @return classification code 061 **/ 062 public String getCode() { 063 return iCode; 064 } 065 066 public String getLabel() { return iLabel; } 067 068 @Override 069 public int hashCode() { 070 return (iArea + ":" + iCode).hashCode(); 071 } 072 073 @Override 074 public boolean equals(Object o) { 075 if (o == null || !(o instanceof AcademicAreaCode)) 076 return false; 077 AcademicAreaCode aac = (AcademicAreaCode) o; 078 return ToolBox.equals(aac.getArea(), getArea()) && ToolBox.equals(aac.getCode(), getCode()); 079 } 080 081 @Override 082 public String toString() { 083 return getArea() + ":" + getCode(); 084 } 085}