2a00101c3d912100f3335b8565c0c18c0b9735b7
[controller.git] / opendaylight / netconf / netconf-cli / src / main / java / org / opendaylight / controller / netconf / cli / reader / impl / LeafListEntryReader.java
1
2 /*
3  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
4  *
5  * This program and the accompanying materials are made available under the
6  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7  * and is available at http://www.eclipse.org/legal/epl-v10.html
8  */
9 package org.opendaylight.controller.netconf.cli.reader.impl;
10
11 import com.google.common.base.Optional;
12 import com.google.common.collect.Lists;
13 import java.util.List;
14 import jline.console.completer.Completer;
15 import org.opendaylight.controller.netconf.cli.io.BaseConsoleContext;
16 import org.opendaylight.controller.netconf.cli.io.ConsoleContext;
17 import org.opendaylight.controller.netconf.cli.io.ConsoleIO;
18 import org.opendaylight.controller.netconf.cli.reader.GenericListEntryReader;
19 import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
20 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
21 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
22
23 class LeafListEntryReader extends BasicDataHolderReader<LeafListSchemaNode> implements
24         GenericListEntryReader<LeafListSchemaNode> {
25
26     public LeafListEntryReader(final ConsoleIO console, final SchemaContext schemaContext) {
27         super(console, schemaContext);
28     }
29
30     public LeafListEntryReader(final ConsoleIO console, final SchemaContext schemaContext, final boolean readConfigNode) {
31         super(console, schemaContext, readConfigNode);
32     }
33
34     @Override
35     protected TypeDefinition<?> getType(final LeafListSchemaNode schemaNode) {
36         return schemaNode.getType();
37     }
38
39     @Override
40     protected ConsoleContext getContext(final LeafListSchemaNode schemaNode) {
41         return new BaseConsoleContext<LeafListSchemaNode>(schemaNode) {
42
43             @Override
44             public Optional<String> getPrompt() {
45                 return Optional.of("[entry]");
46             }
47
48             @Override
49             protected List<Completer> getAdditionalCompleters() {
50                 return Lists.<Completer> newArrayList(getBaseCompleter(getDataSchemaNode()));
51             }
52         };
53     }
54 }