Skip to content

Commit

Permalink
Move some methods around
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaming32 committed Apr 3, 2022
1 parent d7d3472 commit 5054f51
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions src/main/java/io/github/arrayv/groovyapi/RunSortBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,28 @@ public RunSortBuilder with(Map<String, Object> opts) {
return this;
}

/**
* <p>Put one more option into the options map and run the sort</p>
* Equivalent to {@code with(opt).go()} or {@code with opt go()}
* @param opt The option to add
*/
public void and(Map.Entry<String, Object> opt) {
put(opt);
finish();
}

/**
* Run the sort
*/
public void run(Map<String, Object> opts) {
if (opts != null) {
for (Map.Entry<String, Object> opt : opts.entrySet()) {
put(opt);
}
}
finish();
}

private void put(Map.Entry<String, Object> opt) {
if (!ALLOWED_KEYS.contains(opt.getKey())) {
throw new IllegalArgumentException("Invalid RunSortBuilder key: " + opt.getKey());
Expand Down Expand Up @@ -163,28 +185,6 @@ public double getSpeed() {
return ((Number)opts.getOrDefault("speed", 1.0)).doubleValue();
}

/**
* <p>Put one more option into the options map and run the sort</p>
* Equivalent to {@code with(opt).go()} or {@code with opt go()}
* @param opt The option to add
*/
public void and(Map.Entry<String, Object> opt) {
put(opt);
finish();
}

/**
* Run the sort
*/
public void run(Map<String, Object> opts) {
if (opts != null) {
for (Map.Entry<String, Object> opt : opts.entrySet()) {
put(opt);
}
}
finish();
}

private int calculateLength(int defaultLength, int startingLength) {
if (startingLength != -1) {
return (int)Math.max(defaultLength / 2048d * startingLength, 2);
Expand Down

0 comments on commit 5054f51

Please sign in to comment.