Repository: apache/kafka
File: trogdor/src/main/java/org/apache/kafka/trogdor/rest/TasksRequest.java (Java)

Code before:
    private final long lastStartMs;

    /**
     * If this is non-zero, only tasks with an endMs at or after this time will be listed.
     */
    private final long firstEndMs;

    /**
     * If this is non-zero, only tasks with an endMs at or before this time will be listed.
     */
    private final long lastEndMs;

    /**
     * The desired state of the tasks.
     * An empty string will match all states.
     */
    private final Optional<TaskStateType> state;

    @JsonCreator
    public TasksRequest(@JsonProperty("taskIds") Collection<String> taskIds,
            @JsonProperty("firstStartMs") long firstStartMs,
            @JsonProperty("lastStartMs") long lastStartMs,
            @JsonProperty("firstEndMs") long firstEndMs,
            @JsonProperty("lastEndMs") long lastEndMs,
            @JsonProperty("state") Optional<TaskStateType> state) {
        this.taskIds = Set.copyOf((taskIds == null) ? new HashSet<>() : new HashSet<>(taskIds));
        this.firstStartMs = Math.max(0, firstStartMs);
        this.lastStartMs = Math.max(0, lastStartMs);
        this.firstEndMs = Math.max(0, firstEndMs);
        this.lastEndMs = Math.max(0, lastEndMs);
        this.state = state == null ? Optional.empty() : state;
    }

    @JsonProperty
    public Collection<String> taskIds() {
        return taskIds;
    }

    @JsonProperty
    public long firstStartMs() {
        return firstStartMs;
    }

    @JsonProperty
    public long lastStartMs() {
        return lastStartMs;
    }

    @JsonProperty
    public long firstEndMs() {
        return firstEndMs;

Review comment (suggestion):
```java
this.taskIds = taskIds == null ? Set.of() : Set.copyOf(taskIds);
```

Code after:

    /**
     * If this is non-zero, only tasks with an endMs at or after this time will be listed.
     */
    private final long firstEndMs;

    /**
     * If this is non-zero, only tasks with an endMs at or before this time will be listed.
     */
    private final long lastEndMs;

    /**
     * The desired state of the tasks.
     * An empty string will match all states.
     */
    private final Optional<TaskStateType> state;

    @JsonCreator
    public TasksRequest(@JsonProperty("taskIds") Collection<String> taskIds,
            @JsonProperty("firstStartMs") long firstStartMs,
            @JsonProperty("lastStartMs") long lastStartMs,
            @JsonProperty("firstEndMs") long firstEndMs,
            @JsonProperty("lastEndMs") long lastEndMs,
            @JsonProperty("state") Optional<TaskStateType> state) {
        this.taskIds = taskIds == null ? Set.of() : Set.copyOf(taskIds);
        this.firstStartMs = Math.max(0, firstStartMs);
        this.lastStartMs = Math.max(0, lastStartMs);
        this.firstEndMs = Math.max(0, firstEndMs);
        this.lastEndMs = Math.max(0, lastEndMs);
        this.state = state == null ? Optional.empty() : state;
    }

    @JsonProperty
    public Collection<String> taskIds() {
        return taskIds;
    }

    @JsonProperty
    public long firstStartMs() {
        return firstStartMs;
    }

    @JsonProperty
    public long lastStartMs() {
        return lastStartMs;
    }

    @JsonProperty
    public long firstEndMs() {
        return firstEndMs;
    }