Verified Commit 1e4434ab authored by Lukas Wiest's avatar Lukas Wiest 🚂
Browse files

refactor(core/TicketBuilder): make assignees setter non abstract and use string

parent e5869d6b
Pipeline #1247 passed with stages
in 2 minutes and 28 seconds
......@@ -20,7 +20,7 @@ public abstract class TicketBuilder<B extends TicketBuilder, T extends Ticket, T
public final TS parent;
protected Set<Integer> assignees;
protected Set<String> assignees;
protected String description;
protected Set<String> labels;
protected String title;
......@@ -37,7 +37,11 @@ public abstract class TicketBuilder<B extends TicketBuilder, T extends Ticket, T
logger.log(Level.FINEST, String.format("%s instantiated", this.getClass().getSimpleName()));
}
public abstract B assignees(String... identifiers);
public B assignees(String... identifiers)
{
this.assignees = new HashSet<>(Arrays.asList(identifiers));
return (B) this;
}
public B description(String description)
{
......
......@@ -29,12 +29,10 @@ public class GitlabTicketBuilder extends TicketBuilder<GitlabTicketBuilder, Gitl
@Override
public GitlabTicketBuilder assignees(String... identifiers)
{
try
{
assignees(Arrays.stream(identifiers)
.mapToInt(Integer::parseInt)
.toArray());
Arrays.stream(identifiers)
.forEach(Integer::parseInt);
} catch (NumberFormatException e)
{
......@@ -42,15 +40,14 @@ public class GitlabTicketBuilder extends TicketBuilder<GitlabTicketBuilder, Gitl
throw new AssertionException(e);
}
return this;
return super.assignees(identifiers);
}
public GitlabTicketBuilder assignees(int... identifiers)
{
assignees = Arrays.stream(identifiers)
.mapToObj(i -> (Integer) i)
.collect(Collectors.toSet());
return this;
return super.assignees(Arrays.stream(identifiers)
.mapToObj(String::valueOf)
.toArray(String[]::new));
}
protected OkHttpClient getHttpClient() { return new OkHttpClient(); }
......@@ -83,7 +80,10 @@ public class GitlabTicketBuilder extends TicketBuilder<GitlabTicketBuilder, Gitl
if (this.assignees != null)
{
ArrayNode ids = body.putArray("assignee_ids");
assignees.forEach(ids::add);
assignees
.stream()
.mapToInt(Integer::parseInt)
.forEach(ids::add);
logger.log(Level.FINEST, "assignees set");
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment