我们知道java enum类:
我有多个枚举类,如下所示:
enum ResourceState {
RUNNING, STOPPING,STARTTING;//...
void aMethod() {
// ...
}
}
enum ServiceState {
RUNNING, STOPPING,STARTTING,ERROR;//...
void aMethod() {
// ...
}
}
Run Code Online (Sandbox Code Playgroud)
该方法aMethod()
在枚举ResourceState
和ServiceState
是完全一样的.
在OOP中,如果ResourceState
和ServiceState
不是枚举,他们应该将相同的方法抽象为超级抽象类,如下所示:
abstract class AbstractState{
void aMethod() {
// ...
}
}
Run Code Online (Sandbox Code Playgroud)
但是ResourceState无法从AbstractState扩展,你有什么想法可以解决吗?
interface-bounding:Linux 绑定驱动程序提供了一种将多个网络接口聚合为单个逻辑绑定接口的方法。逻辑有界接口将只有一个 MAC 地址,它与原始接口之一有界。ifconfig
将显示所有具有相同 MAC 地址的原始接口。
现在,我要在 Java 中找到每个接口的原始 MAC 地址。如何?
我已经确认我无法找到它们NetworkInterface.getInterfaceAddresses()
并且NetworkInterface.getSubInterfaces()
还有其他方法吗?
更新:
边界前:
在将 eth1 和 eth2 绑定到 bound0 之后:
java代码显示接口信息:
ALL interfaces:[name:bond0 (bond0), name:eth0 (eth0), name:lo (lo)]
they are [{netIf bond0,host 192.168.122.38,mac 525400F801B9,ip 192.168.122.38}, {netIf eth0,host hatest02,mac 5254008C5B48,ip 192.168.10.38}]
Run Code Online (Sandbox Code Playgroud)