@Test public void testUUIDTypeConversionWithNumberArrayInput(){ UUIDTypeConversion uuidTypeConverison = new UUIDTypeConversion(); int[] uuidChars = new int[]{1,2,3,4}; try{ uuidTypeConverison.convert(uuidChars); }catch(Exception e){ assertTrue(e instanceof IllegalArgumentException); assertEquals(e.getMessage(), "Cannot convert to UUID from array of \"int\""); } }
@Override public UUID convert(Object value) { if (value == null) { return null; } else if (value instanceof UUID) { return (UUID)value; } else if (value instanceof String) { return UUID.fromString((String)value); } else if (value.getClass().isArray()) { if (value.getClass().getComponentType() == Byte.TYPE) { return UUID.nameUUIDFromBytes((byte[])value); } else if (value.getClass().getComponentType() == Character.TYPE) { return UUID.fromString(String.valueOf((char[])value)); } else { throw new IllegalArgumentException("Cannot convert to UUID "+ "from array of \""+ value.getClass().getComponentType()+"\""); } } else { return UUID.fromString(value.toString()); } }
UUIDTypeConversion implements TypeConverter.Conversion<UUID> { @Override public UUID convert(Object value) { if (value == null) { return null; } else if (value instanceof UUID) { return (UUID)value; } else if (value instanceof String) { return UUID.fromString((String)value); } else if (value.getClass().isArray()) { if (value.getClass().getComponentType() == Byte.TYPE) { return UUID.nameUUIDFromBytes((byte[])value); } else if (value.getClass().getComponentType() == Character.TYPE) { return UUID.fromString(String.valueOf((char[])value)); } else { throw new IllegalArgumentException("Cannot convert to UUID "+ "from array of \""+ value.getClass().getComponentType()+"\""); } } else { return UUID.fromString(value.toString()); } } }
UUIDTypeConversion implements TypeConverter.Conversion<UUID> { @Override public UUID convert(Object value) { if (value == null) { return null; } else if (value instanceof UUID) { return (UUID)value; } else if (value instanceof String) { return UUID.fromString((String)value); } else if (value.getClass().isArray()) { if (value.getClass().getComponentType() == Byte.TYPE) { return UUID.nameUUIDFromBytes((byte[])value); } else if (value.getClass().getComponentType() == Character.TYPE) { return UUID.fromString(String.valueOf((char[])value)); } else { throw new IllegalArgumentException("Cannot convert to UUID "+ "from array of \""+ value.getClass().getComponentType()+"\""); } } else { return UUID.fromString(value.toString()); } }  }
UUIDTypeConversion implements TypeConverter.Conversion<UUID> { @Override public UUID convert(Object value) { if (value == null) { return null; } else if (value instanceof UUID) { return (UUID)value; } else if (value instanceof String) { return UUID.fromString((String)value); } else if (value.getClass().isArray()) { if (value.getClass().getComponentType() == Byte.TYPE) { return UUID.nameUUIDFromBytes((byte[])value); } else if (value.getClass().getComponentType() == Character.TYPE) { return UUID.fromString(String.valueOf((char[])value)); } else { throw new IllegalArgumentException("Cannot convert to UUID "+ "from array of \""+ value.getClass().getComponentType()+"\""); } } else { return UUID.fromString(value.toString()); } }  @Override Object[] getTypeKeys(); @Override UUID convert(Object value); }
UUIDTypeConversion implements TypeConverter.Conversion<UUID> { @Override public UUID convert(Object value) { if (value == null) { return null; } else if (value instanceof UUID) { return (UUID)value; } else if (value instanceof String) { return UUID.fromString((String)value); } else if (value.getClass().isArray()) { if (value.getClass().getComponentType() == Byte.TYPE) { return UUID.nameUUIDFromBytes((byte[])value); } else if (value.getClass().getComponentType() == Character.TYPE) { return UUID.fromString(String.valueOf((char[])value)); } else { throw new IllegalArgumentException("Cannot convert to UUID "+ "from array of \""+ value.getClass().getComponentType()+"\""); } } else { return UUID.fromString(value.toString()); } }  @Override Object[] getTypeKeys(); @Override UUID convert(Object value);  }