package com.github.twitch4j.helix.domain;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.Singular;
import lombok.With;
import lombok.extern.jackson.Jacksonized;

import java.util.List;
import java.util.stream.Collectors;

@With
@Data
@Setter(AccessLevel.PRIVATE)
@Builder
@Jacksonized
@NoArgsConstructor
@AllArgsConstructor
@JsonInclude(JsonInclude.Include.NON_NULL)
public class BanUsersInput {

    /**
     * The list of users to ban or put in a timeout.
     * You may specify a maximum of 100 users.
     */
    @Singular
    @JsonProperty("data")
    private List<BanUserInput> actions;

    /**
     * Simplified Constructor
     *
     * @param userIds  The ids of the users to be banned or timed out.
     * @param reason   The reason for the mod action.
     * @param duration Seconds of the timeout period,  or null for a ban.
     */
    public BanUsersInput(List<String> userIds, String reason, Integer duration) {
        this.actions = userIds.stream()
            .map(id -> BanUserInput.builder().userId(id).reason(reason).duration(duration).build())
            .collect(Collectors.toList());
    }

    /**
     * Simplified Constructor
     *
     * @param userIds The ids of the users to be banned.
     * @param reason  The reason for the ban.
     */
    public BanUsersInput(List<String> userIds, String reason) {
        this(userIds, reason, null);
    }

}

@@ -406,16 +406,21 @@
 va.util.
+Array
 List;%0Aim
@@ -438,25 +438,41 @@
 til.
-stream.Collectors
+Collection;%0Aimport java.util.List
 ;%0A%0A@
@@ -1065,17 +1065,16 @@
  period,
- 
  or null
@@ -1110,36 +1110,42 @@
 c BanUsersInput(
-List
+Collection
 %3CString%3E userIds
@@ -1193,62 +1193,137 @@
     
-this.actions = userIds.stream()%0A            .map(id -%3E
+List%3CBanUserInput%3E actions = new ArrayList%3C%3E(userIds.size());%0A        for (String userId : userIds) %7B%0A            actions.add(new
  Ban
@@ -1335,114 +1335,77 @@
 nput
-.builder().
+(
 userId
-(id).
+, 
 reason
-(reason).duration(duration).build())
+, duration));
 %0A      
+  %7D%0A
       
-.collect(Collectors.toList())
+  this.actions = actions
 ;%0A  
@@ -1590,20 +1590,26 @@
 rsInput(
-List
+Collection
 %3CString%3E

optimize user id to ban user input mapping (#475)