@Test public void testMask() { MD5IdFactory idFactory = new MD5IdFactory(); for (int i = -128; i < 128; i++) { int val1 = idFactory.mask((byte) i, 0); int val2 = idFactory.mask((byte) i, 1); int val3 = idFactory.mask((byte) i, 2); int val4 = idFactory.mask((byte) i, 3); System.out.println(i + " : " + val1 + " " + val2 + " " + val3 + " " + val4); } }
int mask(byte b, int mask) { switch (mask) { case 0: return (b & ~3); case 1: return (b & ~3) | 1; case 2: return (b & ~3) | 2; default: return (b & ~3) | 3; } }
MD5IdFactory implements IdFactory { int mask(byte b, int mask) { switch (mask) { case 0: return (b & ~3); case 1: return (b & ~3) | 1; case 2: return (b & ~3) | 2; default: return (b & ~3) | 3; } } }
MD5IdFactory implements IdFactory { int mask(byte b, int mask) { switch (mask) { case 0: return (b & ~3); case 1: return (b & ~3) | 1; case 2: return (b & ~3) | 2; default: return (b & ~3) | 3; } } MD5IdFactory(); }
MD5IdFactory implements IdFactory { int mask(byte b, int mask) { switch (mask) { case 0: return (b & ~3); case 1: return (b & ~3) | 1; case 2: return (b & ~3) | 2; default: return (b & ~3) | 3; } } MD5IdFactory(); @Override Long getId(NODE node); @Override Integer getId(Locale locale); }
MD5IdFactory implements IdFactory { int mask(byte b, int mask) { switch (mask) { case 0: return (b & ~3); case 1: return (b & ~3) | 1; case 2: return (b & ~3) | 2; default: return (b & ~3) | 3; } } MD5IdFactory(); @Override Long getId(NODE node); @Override Integer getId(Locale locale);  }