TypeOfAddress { public static TypeOfAddress valueOf(byte b) { int ton = (b & 0x0F); int npi = ((b >> 4) & 0x07); return new TypeOfAddress(Ton.fromInt(ton), Npi.fromInt(npi)); } TypeOfAddress(Ton ton, Npi npi); Ton getTon(); void setTon(Ton ton); Npi getNpi(); void setNpi(Npi npi); byte toByte(); static byte toByte(TypeOfAddress toa); static TypeOfAddress valueOf(byte b); @Override String toString();  }
@Test public void valueOf() { TypeOfAddress toa = TypeOfAddress.valueOf((byte)0x91); Assert.assertEquals(Ton.INTERNATIONAL, toa.getTon()); Assert.assertEquals(Npi.ISDN, toa.getNpi()); TypeOfAddress toa2 = TypeOfAddress.valueOf((byte)0x81); Assert.assertEquals(Ton.INTERNATIONAL, toa2.getTon()); Assert.assertEquals(Npi.UNKNOWN, toa2.getNpi()); }