Skip to content

Commit 03b78f8

Browse files
committed
Add MutableStringListArgs.
1 parent 536549d commit 03b78f8

2 files changed

Lines changed: 41 additions & 2 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Intake, a command processing library
3+
* Copyright (C) sk89q <http://www.sk89q.com>
4+
* Copyright (C) Intake team and contributors
5+
*
6+
* This program is free software: you can redistribute it and/or modify it
7+
* under the terms of the GNU Lesser General Public License as published by the
8+
* Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful, but WITHOUT
12+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
14+
* for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public License
17+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
20+
package com.sk89q.intake.argument;
21+
22+
import java.util.List;
23+
import java.util.Map;
24+
25+
public class MutableStringListArgs extends StringListArgs {
26+
27+
public MutableStringListArgs(List<String> arguments, Map<Character, String> flags, Namespace namespace) {
28+
super(arguments, flags, namespace);
29+
}
30+
31+
@Override
32+
public void insert(String argument) {
33+
super.insert(argument);
34+
}
35+
}

intake/src/main/java/com/sk89q/intake/argument/StringListArgs.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
package com.sk89q.intake.argument;
2121

22-
import com.google.common.collect.ImmutableList;
22+
import com.google.common.collect.Lists;
2323

2424
import java.util.List;
2525
import java.util.Map;
@@ -37,11 +37,15 @@ class StringListArgs extends AbstractCommandArgs {
3737
checkNotNull(arguments, "arguments");
3838
checkNotNull(flags, "flags");
3939
checkNotNull(namespace, "namespace");
40-
this.arguments = ImmutableList.copyOf(arguments);
40+
this.arguments = Lists.newArrayList(arguments);
4141
this.flags = flags;
4242
this.namespace = namespace;
4343
}
4444

45+
protected void insert(String argument) {
46+
arguments.add(position, argument);
47+
}
48+
4549
@Override
4650
public boolean hasNext() {
4751
return position < arguments.size();

0 commit comments

Comments
 (0)