MACAddress { public boolean isMulticast() { if (isBroadcast()) { return false; } return (address[0] & 0x01) != 0; } MACAddress(byte[] address); static MACAddress valueOf(String address); static MACAddress valueOf(byte[] address); static MACAddress valueOf(long address); int length(); byte[] toBytes(); long toLong(); boolean isBroadcast(); boolean isMulticast(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); static final int MAC_ADDRESS_LENGTH; }
@Test public void testIsMulticast() { assertTrue(MACAddress.valueOf("01:80:C2:00:00:00").isMulticast()); assertFalse(MACAddress.valueOf("FF:FF:FF:FF:FF:FF").isMulticast()); assertFalse(MACAddress.valueOf("11:22:33:44:55:66").isBroadcast()); }