blob: 0f79c6821ca48a7a2bea28ce62c91eed0414e3fd [file] [log] [blame]
Yuta HIGUCHIdc7374c2014-10-10 11:11:09 -07001package org.onlab.onos.cluster;
Yuta HIGUCHI9ee60f62014-10-09 10:00:01 -07002
3import com.google.common.base.Function;
4
5/**
6 * Function to convert ControllerNode to NodeId.
7 */
8public final class ControllerNodeToNodeId
9 implements Function<ControllerNode, NodeId> {
10
11 private static final ControllerNodeToNodeId INSTANCE = new ControllerNodeToNodeId();
12
13 @Override
14 public NodeId apply(ControllerNode input) {
Yuta HIGUCHIb35a3812014-10-15 23:22:17 -070015 if (input == null) {
16 return null;
17 } else {
18 return input.id();
19 }
Yuta HIGUCHI9ee60f62014-10-09 10:00:01 -070020 }
21
Yuta HIGUCHIdc7374c2014-10-10 11:11:09 -070022 /**
23 * Returns a Function to convert ControllerNode to NodeId.
24 *
25 * @return ControllerNodeToNodeId instance.
26 */
Yuta HIGUCHI9ee60f62014-10-09 10:00:01 -070027 public static ControllerNodeToNodeId toNodeId() {
28 return INSTANCE;
29 }
30}