org.cpsolver.studentsct.model

## Class Subpart

- java.lang.Object
- - org.cpsolver.studentsct.model.Subpart

- All Implemented Interfaces:
    Comparable<Subpart>

      public class Subpart
      extends Object
      implements Comparable<Subpart>

  Representation of a scheduling subpart. Each scheduling subpart contains id, instructional type, name, instructional offering configuration, and a list of sections. Optionally, parent-child relation between subparts can be defined.
  Version:
    StudentSct 1.3 (Student Sectioning)
    Copyright (C) 2007 - 2014 Tomáš Müller
    muller@unitime.org
    http://muller.unitime.org
    This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
    This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
    You should have received a copy of the GNU Lesser General Public License along with this library; if not see http://www.gnu.org/licenses/.
  Author:
    Tomáš Müller

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Subpart(long id, String itype, String name, Config config, Subpart parent)` Constructor

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `clearReservationCache()` Clear reservation information that was cached on this subpart or below
    `int` | `compareTo(Subpart s)` Compare two subparts: put parents first, use ids if there is no parent-child relation
    `boolean` | `equals(Object o)`
    `List<Subpart>` | `getChildren()` Return children subparts
    `Set<Choice>` | `getChoices()` List of available choices of the sections of this subpart.
    `Config` | `getConfig()` Instructional offering configuration to which this subpart belongs
    `String` | `getCredit()` Get credit (Online Student Scheduling only)
    `Float` | `getCreditValue()` Get subpart's credit value (null if not set) return subpart's credit value
    `long` | `getId()` Subpart id
    `String` | `getInstructionalType()` Instructional type, e.g., Lecture, Recitation or Laboratory
    `int` | `getLimit()` Sum of the section limits (unlimited, if one or more sections are unlimited)
    `double` | `getMaxPenalty()` Maximal penalty from `Section.getPenalty()`
    `double` | `getMinPenalty()` Minimal penalty from `Section.getPenalty()`
    `String` | `getName()` Subpart name
    `Subpart` | `getParent()` Parent subpart, if parent-child relation is defined between subparts
    `List<Reservation>` | `getSectionReservations()` Get reservations that require sections of this subpart
    `List<Section>` | `getSections()` List of sections
    `boolean` | `hasCreditValue()` True if this subpart has a credit value defined
    `int` | `hashCode()`
    `boolean` | `hasTime()`
    `boolean` | `isAllowOverlap()` Return true if overlaps are allowed, but the number of overlapping slots should be minimized.
    `boolean` | `isOnline()`
    `boolean` | `isParentOf(Subpart subpart)` True, if this subpart is parent (or parent of a parent etc.) of the given subpart
    `boolean` | `isPast()`
    `void` | `setAllowOverlap(boolean allowOverlap)` Set to true if overlaps are allowed, but the number of overlapping slots should be minimized (defaults to false).
    `void` | `setCredit(String credit)` Set credit (Online Student Scheduling only)
    `void` | `setCreditValue(Float creditValue)` Set subpart's credit value (null if not set)
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### Subpart

          public Subpart(long id,
                         String itype,
                         String name,
                         Config config,
                         Subpart parent)

      Constructor
      Parameters:
        `id` - scheduling subpart unique id
        `itype` - instructional type
        `name` - subpart name
        `config` - instructional offering configuration to which this subpart belongs
        `parent` - parent subpart, if parent-child relation is defined between subparts

  - ### Method Detail

    - #### getId

          public long getId()

      Subpart id
      Returns:
        scheduling subpart unique id

    - #### getInstructionalType

          public String getInstructionalType()

      Instructional type, e.g., Lecture, Recitation or Laboratory
      Returns:
        instructional type

    - #### getName

          public String getName()

      Subpart name
      Returns:
        scheduling subpart name

    - #### getConfig

          public Config getConfig()

      Instructional offering configuration to which this subpart belongs
      Returns:
        instructional offering configuration

    - #### getSections

          public List<Section> getSections()

      List of sections
      Returns:
        classes of this scheduling supart

    - #### getParent

          public Subpart getParent()

      Parent subpart, if parent-child relation is defined between subparts
      Returns:
        parent scheduling subpart

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### isParentOf

          public boolean isParentOf(Subpart subpart)

      True, if this subpart is parent (or parent of a parent etc.) of the given subpart
      Parameters:
        `subpart` - parent scheduling subpart
      Returns:
        true if parent (even indirect)

    - #### compareTo

          public int compareTo(Subpart s)

      Compare two subparts: put parents first, use ids if there is no parent-child relation
      Specified by:
        `compareTo` in interface `Comparable<Subpart>`

    - #### getChoices

          public Set<Choice> getChoices()

      List of available choices of the sections of this subpart.
      Returns:
        set of available choices

    - #### getMinPenalty

          public double getMinPenalty()

      Minimal penalty from `Section.getPenalty()`
      Returns:
        minimal penalty

    - #### getMaxPenalty

          public double getMaxPenalty()

      Maximal penalty from `Section.getPenalty()`
      Returns:
        maximal penalty

    - #### getChildren

          public List<Subpart> getChildren()

      Return children subparts
      Returns:
        children scheduling subparts

    - #### isAllowOverlap

          public boolean isAllowOverlap()

      Return true if overlaps are allowed, but the number of overlapping slots should be minimized.
      Returns:
        true if overlaps of classes of this scheduling subpart are allowed

    - #### setAllowOverlap

          public void setAllowOverlap(boolean allowOverlap)

      Set to true if overlaps are allowed, but the number of overlapping slots should be minimized (defaults to false).
      Parameters:
        `allowOverlap` - are overlaps of classes of this scheduling subpart allowed

    - #### getSectionReservations

          public List<Reservation> getSectionReservations()

      Get reservations that require sections of this subpart
      Returns:
        reservations that require a class of this scheduling subpart

    - #### clearReservationCache

          public void clearReservationCache()

      Clear reservation information that was cached on this subpart or below

    - #### getLimit

          public int getLimit()

      Sum of the section limits (unlimited, if one or more sections are unlimited)
      Returns:
        total class limit

    - #### equals

          public boolean equals(Object o)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### setCredit

          public void setCredit(String credit)

      Set credit (Online Student Scheduling only)
      Parameters:
        `credit` - scheduling subpart credit

    - #### getCredit

          public String getCredit()

      Get credit (Online Student Scheduling only)
      Returns:
        scheduling subpart credit

    - #### hasCreditValue

          public boolean hasCreditValue()

      True if this subpart has a credit value defined
      Returns:
        true if a credit value is set

    - #### setCreditValue

          public void setCreditValue(Float creditValue)

      Set subpart's credit value (null if not set)
      Parameters:
        `creditValue` - subpart's credit value

    - #### getCreditValue

          public Float getCreditValue()

      Get subpart's credit value (null if not set) return subpart's credit value

    - #### isOnline

          public boolean isOnline()

    - #### hasTime

          public boolean hasTime()

    - #### isPast

          public boolean isPast()