Class SubmissionQuery<T extends VilleSubmissionFields>

java.lang.Object
studentrepoloader.model.villecsv.util.SubmissionQuery<T>
Type Parameters:
T - A type that extends VilleSubmission

public class SubmissionQuery<T extends VilleSubmissionFields> extends Object
Fluent wrapper for filtering and transforming lists of VilleSubmissionFields objects. Enables expressive, immutable query chaining for CLI and batch processing scenarios.
  • Constructor Details

    • SubmissionQuery

      public SubmissionQuery(List<T> submissions)
      Constructs a new query object from a given list.
      Parameters:
      submissions - the list of submissions to wrap
  • Method Details

    • from

      public static <T extends VilleSubmissionFields> SubmissionQuery<T> from(List<T> submissions)
      Static factory method to begin a fluent query.
      Type Parameters:
      T - type of submission
      Parameters:
      submissions - list of entries to wrap
      Returns:
      a new SubmissionQuery instance
    • filterAfterDate

      public SubmissionQuery<T> filterAfterDate(String deadline)
      Filters submissions after the given ViLLe deadline date (yyyy-MM-dd).
      Parameters:
      deadline - cutoff date as ISO string (inclusive-exclusive boundary)
      Returns:
      filtered query containing only submissions strictly after the given date
    • filterBeforeDate

      public SubmissionQuery<T> filterBeforeDate(String deadline)
      Filters submissions on or before the given ViLLe deadline date.
      Parameters:
      deadline - inclusive cutoff date
      Returns:
      filtered query containing submissions on or before the given date
    • filterIdAtOrBefore

      public SubmissionQuery<T> filterIdAtOrBefore(String upperBound)
      Filters submissions where getID() is less than or equal to the upper bound.
      Parameters:
      upperBound - max string value (case-insensitive)
      Returns:
      filtered query
    • filterIdAtOrAfter

      public SubmissionQuery<T> filterIdAtOrAfter(String lowerBound)
      Filters submissions where getID() is greater than or equal to the lower bound.
      Parameters:
      lowerBound - min string value (case-insensitive)
      Returns:
      filtered query
    • filterIdBetween

      public SubmissionQuery<T> filterIdBetween(String lower, String upper)
      Filters submissions whose getID() falls within a specified inclusive range.

      If lower is null or empty, the range is unbounded below. If upper is null or empty, the range is unbounded above. If both are null or empty, no filtering is applied.

      Parameters:
      lower - inclusive lower bound (nullable/empty to skip)
      upper - inclusive upper bound (nullable/empty to skip)
      Returns:
      filtered query
    • filterFieldContaining

      public SubmissionQuery<T> filterFieldContaining(Function<T,String> getter, String mustContain)
      Filters by whether a specific field contains a given substring.
      Parameters:
      getter - field accessor function
      mustContain - target substring
      Returns:
      filtered query including only entries whose field includes the substring
    • filter

      public SubmissionQuery<T> filter(Predicate<T> condition)
      Applies an arbitrary predicate to the current submission list. This is the general-purpose filtering function used internally by all specific filters.
      Parameters:
      condition - the predicate to apply
      Returns:
      a filtered SubmissionQuery instance
    • filterNot

      public SubmissionQuery<T> filterNot(Predicate<T> condition)
      Applies a negated filter condition to exclude matching entries. This is the inverse of filter(Predicate).
      Parameters:
      condition - predicate whose matches should be excluded
      Returns:
      a filtered SubmissionQuery excluding matching entries
    • sortBy

      public SubmissionQuery<T> sortBy(Function<T,String> getter)
      Sorts submissions by a field (e.g., ID or name).
      Parameters:
      getter - field accessor for sorting
      Returns:
      a sorted query
    • extractColumn

      public <R> List<R> extractColumn(Function<T,R> getter)
      Terminal operation that projects the current filtered list into a single column.

      Applies the given field accessor or transformation function to each submission and returns the resulting values in order. Commonly used for generating summaries, diagnostics, or exporting a specific attribute from the current query result.

      Type Parameters:
      R - the type of values extracted
      Parameters:
      getter - function to extract or transform a field from each submission
      Returns:
      a list of extracted values, one per submission
    • toList

      public List<T> toList()
      Returns the current list of filtered submissions.
      Returns:
      immutable list of query results