ae1dfc2110e65d18eb5036716a2c0ab7a457136c
[controller.git] /
1 /*
2  * Copyright (c) 2021 PANTHEON.tech, s.r.o. and others.  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.eos.akka.owner.checker.command;
9
10 import akka.actor.typed.ActorRef;
11 import com.google.common.base.MoreObjects;
12 import org.eclipse.jdt.annotation.NonNull;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.EntityId;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.EntityName;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.EntityType;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.entity.owners.norev.get.entities.output.EntitiesBuilder;
17
18 public abstract class AbstractEntityRequest<T extends StateCheckerReply> extends StateCheckerRequest<T> {
19     private static final long serialVersionUID = 1L;
20
21     private final @NonNull EntityType type;
22     private final @NonNull EntityName name;
23
24     AbstractEntityRequest(final ActorRef<T> replyTo, final EntityId entity) {
25         super(replyTo);
26         type = entity.requireType();
27         name = entity.requireName();
28     }
29
30     public final @NonNull EntityId getEntity() {
31         return new EntitiesBuilder().setType(type).setName(name).build();
32     }
33
34     public final @NonNull EntityType getType() {
35         return type;
36     }
37
38     public final @NonNull EntityName getName() {
39         return name;
40     }
41
42     @Override
43     public final String toString() {
44         return MoreObjects.toStringHelper(this).add("type", type).add("name", name).toString();
45     }
46 }