package net.gcdc.geonetworking;

import java.math.BigInteger;
import java.nio.ByteBuffer;
import java.util.Arrays;

public class MacAddress {
    @Override public String toString() {
        return "MacAddress[" + address + "]";
    }

    private final long address;

    public MacAddress(long address) {
        if ((address & 0xffff_0000_0000_0000L) != 0) {
            throw new IllegalArgumentException("address is longer than 6 bytes: " + address);
        }
        this.address = address;
    }

    public long value() { return address; }

    /** Returns 6-bytes array representing this address. */
    public byte[] asBytes() {
        return Arrays.copyOfRange(ByteBuffer.allocate(8).putLong(address).array(), 2, 8);
    }

    public static MacAddress fromBytes(byte[] bytes) {
        if (bytes.length > 6) {
            throw new IllegalArgumentException("Address is too long: " + bytes.length + "bytes");
        }
        return new MacAddress(new BigInteger(+1, bytes).longValue());
    }

    @Override public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + (int) (address ^ (address >>> 32));
        return result;
    }

    @Override public boolean equals(Object obj) {
        if (this == obj) return true;
        if (obj == null) return false;
        if (getClass() != obj.getClass()) return false;
        MacAddress other = (MacAddress) obj;
        if (address != other.address) return false;
        return true;
    }
}

@@ -490,32 +490,111 @@
 address;%0A    %7D%0A%0A
+    public MacAddress(String str) %7B%0A        this(parseFromString(str));%0A    %7D%0A%0A
     public long 
@@ -1265,32 +1265,342 @@
  result;%0A    %7D%0A%0A
+    public static long parseFromString(String s) %7B%0A        String%5B%5D bytes = s.split(%22:%22);%0A        if (bytes.length != 6) %7B%0A            throw new IllegalArgumentException(%22Malformed MAC, expected xx:xx:xx:xx:xx:xx, got %22 + s);%0A        %7D%0A        return new BigInteger(s.replace(%22:%22, %22%22), 16).longValue();%0A    %7D%0A%0A
     @Override pu

Add MacAddress String constructor