Explicitely add @NonNull to inherited parameters
[deliverable/tracecompass.git] / org.eclipse.tracecompass.tmf.remote.core / src / org / eclipse / tracecompass / internal / tmf / remote / core / shell / CommandInput.java
CommitLineData
364dcfaf
BH
1/**********************************************************************
2 * Copyright (c) 2015 Ericsson
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * Bernd Hufmann - Initial API and implementation
11 **********************************************************************/
12package org.eclipse.tracecompass.internal.tmf.remote.core.shell;
13
14import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
15import static org.eclipse.tracecompass.common.core.NonNullUtils.nullToEmptyString;
16
17import java.util.ArrayList;
18import java.util.List;
19
f4648c68 20import org.eclipse.jdt.annotation.NonNull;
364dcfaf
BH
21import org.eclipse.jdt.annotation.Nullable;
22import org.eclipse.tracecompass.tmf.remote.core.shell.ICommandInput;
23
24import com.google.common.collect.ImmutableList;
25
26/**
27 * Class for defining command input for remote command execution.
28 *
29 * @author Bernd Hufmann
30 */
31public class CommandInput implements ICommandInput {
32
33 // ------------------------------------------------------------------------
34 // Attributes
35 // ------------------------------------------------------------------------
36 /** The input as list of Strings. */
37 private final List<String> fInput = new ArrayList<>();
38
39 // ------------------------------------------------------------------------
40 // Accessors
41 // ------------------------------------------------------------------------
42
43 @Override
44 public List<String> getInput() {
45 return checkNotNull(ImmutableList.copyOf(fInput));
46 }
47
48 // ------------------------------------------------------------------------
49 // Operations
50 // ------------------------------------------------------------------------
51 @Override
52 public void add(@Nullable String segment) {
53 if (segment != null) {
54 fInput.add(segment);
55 }
56 }
57
58 @Override
f4648c68 59 public void addAll(@NonNull List<String> segments) {
364dcfaf
BH
60 for (String segment : segments) {
61 add(segment);
62 }
63 }
64
65 /**
66 * Creates a single command string from a command line list.
67 *
68 * @return single command string
69 */
70 @Override
71 public String toString() {
72 StringBuilder builder = new StringBuilder();
73 for (String segment : getInput()) {
74 builder.append(segment).append(' ');
75 }
76 return nullToEmptyString(builder.toString().trim());
77 }
78}
This page took 0.042074 seconds and 5 git commands to generate.