Teach sal-remoterpc-connector to route actions
[controller.git] / opendaylight / md-sal / sal-remoterpc-connector / src / main / java / org / opendaylight / controller / remote / rpc / messages / AbstractExecute.java
1 /*
2  * Copyright (c) 2019 Nordix Foundation.  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 package org.opendaylight.controller.remote.rpc.messages;
9
10 import static java.util.Objects.requireNonNull;
11
12 import com.google.common.base.MoreObjects;
13 import com.google.common.base.MoreObjects.ToStringHelper;
14 import java.io.Serializable;
15 import org.eclipse.jdt.annotation.NonNull;
16 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
17 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
18
19 /**
20  * An abstract base class for invocation requests. Specialized via {@link ExecuteAction} and {@link ExecuteRpc}.
21  */
22 public abstract class AbstractExecute<T extends NormalizedNode<?, ?>> implements Serializable {
23     private static final long serialVersionUID = 1L;
24
25     private final transient @NonNull SchemaPath type;
26     private final transient T input;
27
28     AbstractExecute(final @NonNull SchemaPath type, final T input) {
29         this.type = requireNonNull(type);
30         this.input = input;
31     }
32
33     public final @NonNull SchemaPath getType() {
34         return type;
35     }
36
37     public final T getInput() {
38         return input;
39     }
40
41     @Override
42     public final String toString() {
43         // We want 'type' to be always first
44         return addToStringAttributes(MoreObjects.toStringHelper(this).omitNullValues().add("type", type)).toString();
45     }
46
47     ToStringHelper addToStringAttributes(final ToStringHelper helper) {
48         return helper.add("input", input);
49     }
50
51     abstract Object writeReplace();
52 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.