Improve segmented journal actor metrics
[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
18 /**
19  * An abstract base class for invocation requests. Specialized via {@link ExecuteAction} and {@link ExecuteRpc}.
20  */
21 public abstract class AbstractExecute<T, I extends NormalizedNode> implements Serializable {
22     private static final long serialVersionUID = 1L;
23
24     private final transient @NonNull T type;
25     private final transient I input;
26
27     AbstractExecute(final @NonNull T type, final I input) {
28         this.type = requireNonNull(type);
29         this.input = input;
30     }
31
32     public final @NonNull T getType() {
33         return type;
34     }
35
36     public final I getInput() {
37         return input;
38     }
39
40     @Override
41     public final String toString() {
42         // We want 'type' to be always first
43         return addToStringAttributes(MoreObjects.toStringHelper(this).omitNullValues().add("type", type)).toString();
44     }
45
46     ToStringHelper addToStringAttributes(final ToStringHelper helper) {
47         return helper.add("input", input);
48     }
49
50     abstract Object writeReplace();
51 }