src/jdk.internal.le/share/classes/jdk/internal/jline/console/completer/EnumCompleter.java
equal
deleted
inserted
replaced
1 /* |
|
2 * Copyright (c) 2002-2016, the original author or authors. |
|
3 * |
|
4 * This software is distributable under the BSD license. See the terms of the |
|
5 * BSD license in the documentation provided with this software. |
|
6 * |
|
7 * http://www.opensource.org/licenses/bsd-license.php |
|
8 */ |
|
9 package jdk.internal.jline.console.completer; |
|
10 |
|
11 import static jdk.internal.jline.internal.Preconditions.checkNotNull; |
|
12 |
|
13 /** |
|
14 * {@link Completer} for {@link Enum} names. |
|
15 * |
|
16 * @author <a href="mailto:jason@planet57.com">Jason Dillon</a> |
|
17 * @since 2.3 |
|
18 */ |
|
19 public class EnumCompleter |
|
20 extends StringsCompleter |
|
21 { |
|
22 public EnumCompleter(Class<? extends Enum<?>> source) { |
|
23 this(source, true); |
|
24 } |
|
25 |
|
26 public EnumCompleter(Class<? extends Enum<?>> source, boolean toLowerCase) { |
|
27 checkNotNull(source); |
|
28 |
|
29 for (Enum<?> n : source.getEnumConstants()) { |
|
30 this.getStrings().add(toLowerCase ? n.name().toLowerCase() : n.name()); |
|
31 } |
|
32 } |
|
33 } |
|