@Test public void testToByte() throws Exception { assertEquals("00000101", ByteUtil.toBinaryString(ByteUtil.toByte(true, false, true, false))); assertEquals("11111111", ByteUtil.toBinaryString(ByteUtil.toByte(true, true, true, true, true, true, true, true))); assertEquals("11011011", ByteUtil.toBinaryString(ByteUtil.toByte(true, true, false, true, true, false, true, true))); assertEquals("01111111", ByteUtil.toBinaryString(ByteUtil.toByte(true, true, true, true, true, true, true, false))); }
public static byte toByte(boolean... values) { if (values.length > Byte.SIZE) { throw new IllegalArgumentException( "Expected less or equal to " + Byte.SIZE + " arguments"); } byte b = 0; for (int i = 0; i < values.length; i++) { b |= values[i] ? POWERS[i] : 0; } return b; }
ByteUtil { public static byte toByte(boolean... values) { if (values.length > Byte.SIZE) { throw new IllegalArgumentException( "Expected less or equal to " + Byte.SIZE + " arguments"); } byte b = 0; for (int i = 0; i < values.length; i++) { b |= values[i] ? POWERS[i] : 0; } return b; } }
ByteUtil { public static byte toByte(boolean... values) { if (values.length > Byte.SIZE) { throw new IllegalArgumentException( "Expected less or equal to " + Byte.SIZE + " arguments"); } byte b = 0; for (int i = 0; i < values.length; i++) { b |= values[i] ? POWERS[i] : 0; } return b; } private  ByteUtil(); }
ByteUtil { public static byte toByte(boolean... values) { if (values.length > Byte.SIZE) { throw new IllegalArgumentException( "Expected less or equal to " + Byte.SIZE + " arguments"); } byte b = 0; for (int i = 0; i < values.length; i++) { b |= values[i] ? POWERS[i] : 0; } return b; } private  ByteUtil(); static byte setTrue(final byte number, final int index); static byte setFalse(final byte number, final int index); static boolean isTrue(final byte number, final int index); static boolean isFalse(final byte number, final int index); static byte toByte(boolean... values); static boolean[] fromByte(byte b); static String toBinaryString(final byte number); }
ByteUtil { public static byte toByte(boolean... values) { if (values.length > Byte.SIZE) { throw new IllegalArgumentException( "Expected less or equal to " + Byte.SIZE + " arguments"); } byte b = 0; for (int i = 0; i < values.length; i++) { b |= values[i] ? POWERS[i] : 0; } return b; } private  ByteUtil(); static byte setTrue(final byte number, final int index); static byte setFalse(final byte number, final int index); static boolean isTrue(final byte number, final int index); static boolean isFalse(final byte number, final int index); static byte toByte(boolean... values); static boolean[] fromByte(byte b); static String toBinaryString(final byte number);  }