Magnesium platform upgrade
[lispflowmapping.git] / mappingservice / shell / src / main / java / org / opendaylight / lispflowmapping / shell / LispMappings.java
1 /*
2  * Copyright (c) 2015, 2017 Cisco Systems, Inc.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.lispflowmapping.shell;
10
11 import org.apache.karaf.shell.commands.Command;
12 import org.apache.karaf.shell.commands.Option;
13 import org.apache.karaf.shell.console.OsgiCommandSupport;
14 import org.opendaylight.lispflowmapping.interfaces.mappingservice.IMappingServiceShell;
15
16 /**
17  * This class implements the "mappingservice:mappings" Karaf shell command.
18  *
19  * @author Lorand Jakab
20  *
21  */
22 @Command(scope = "mappingservice", name = "mappings", description = "Print mapping database")
23 public class LispMappings  extends OsgiCommandSupport {
24     @Option(name = "-d", aliases = "--debug", description = "Debug output", required = false, multiValued = false)
25     private boolean debug;
26
27     private IMappingServiceShell mappingServiceShell;
28
29     @Override
30     @SuppressWarnings("checkstyle:RegexpSinglelineJava")
31     protected Object doExecute() throws Exception {
32         if (mappingServiceShell != null) {
33             if (debug) {
34                 System.out.print(mappingServiceShell.printMappings());
35             } else {
36                 System.out.print(mappingServiceShell.prettyPrintMappings());
37             }
38         }
39         return null;
40     }
41
42     public void setMappingServiceShell(IMappingServiceShell mappingServiceShell) {
43         this.mappingServiceShell = mappingServiceShell;
44     }
45 }