001    package net.sf.cpsolver.studentsct.constraint;
002    
003    import net.sf.cpsolver.studentsct.model.Enrollment;
004    import net.sf.cpsolver.studentsct.model.Section;
005    
006    /**
007     * Abstract single section reservation. 
008     * 
009     * <br><br>
010     * 
011     * @version
012     * StudentSct 1.1 (Student Sectioning)<br>
013     * Copyright (C) 2007 Tomáš Müller<br>
014     * <a href="mailto:muller@unitime.org">muller@unitime.org</a><br>
015     * Lazenska 391, 76314 Zlin, Czech Republic<br>
016     * <br>
017     * This library is free software; you can redistribute it and/or
018     * modify it under the terms of the GNU Lesser General Public
019     * License as published by the Free Software Foundation; either
020     * version 2.1 of the License, or (at your option) any later version.
021     * <br><br>
022     * This library is distributed in the hope that it will be useful,
023     * but WITHOUT ANY WARRANTY; without even the implied warranty of
024     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
025     * Lesser General Public License for more details.
026     * <br><br>
027     * You should have received a copy of the GNU Lesser General Public
028     * License along with this library; if not, write to the Free Software
029     * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
030     */
031    public abstract class ReservationOnSection extends Reservation {
032        private Section iSection = null;
033        
034        /**
035         * Constructor
036         * @param section section on which the reservation is set
037         */
038        public ReservationOnSection(Section section) {
039            super();
040            iSection = section;
041        }
042        
043        /** Return section on which the reservation is set */
044        public Section getSection() {
045            return iSection;
046        }
047        
048        /** 
049         * True, if the enrollment contains the section on which this reservation is set.
050         * See {@link Reservation#isApplicable(Enrollment)} for details.
051         */
052        public boolean isApplicable(Enrollment enrollment) {
053            return enrollment.getAssignments().contains(iSection);
054        }
055        
056        public String toString() {
057            return "Reservation on "+iSection.getLongName();
058        }
059    }