Enum Class StudentCsvFormat

java.lang.Object
java.lang.Enum<StudentCsvFormat>
edu.ucsb.cs156.happiercows.helpers.StudentCsvFormat
All Implemented Interfaces:
Serializable, Comparable<StudentCsvFormat>, Constable

public enum StudentCsvFormat extends Enum<StudentCsvFormat>
Different schools export their class rosters with different CSV column layouts. Each format below knows how to recognize its own header row and how to map a data row to a Student.

UCSB_EGRADES matches the header row exported by UCSB's registrar (eGrades); see docs/examples/egrades.csv. CHICO_STATE_ROSTER matches the Canvas roster export used at Chico State (see docs/examples/chico_canvas.csv) and, along with GENERIC, is included as a worked example of how to add support for another school's roster format later (see issue #251); GENERIC is also the format used for courses associated with the "Other" school.

  • Enum Constant Details

  • Method Details

    • values

      public static StudentCsvFormat[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static StudentCsvFormat valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • getHeaders

      public List<String> getHeaders()
    • matchesHeaders

      public boolean matchesHeaders(List<String> candidateHeaders)
    • toStudent

      public Student toStudent(org.apache.commons.csv.CSVRecord row, Long courseId)
    • detect

      public static StudentCsvFormat detect(List<String> candidateHeaders)
      Parameters:
      candidateHeaders - the header row read from an uploaded CSV file
      Returns:
      the matching format, or null if no known format matches