@NonNull @Override public ContentValue<byte[]> convert(@NonNull Inquiry inquiry, @Nullable boolean[] value) throws IOException { if (value == null) return ContentValue.valueOf((byte[]) null); byte[] blob = new byte[value.length]; for (int i = 0; i < value.length; i++) { blob[i] = (byte) (value[i] ? 1 : 0); } return ContentValue.valueOf(blob); }
@Nullable @Override public boolean[] convert( @NonNull Inquiry inquiry, @NonNull ContentValue<byte[]> value, @NonNull Class<? extends boolean[]> fieldType) throws IOException { byte[] blob = value.getContent(); if (blob == null) return null; boolean[] booleans = new boolean[value.getContent().length]; for (int i = 0; i < blob.length; i++) { booleans[i] = blob[i] == 1; } return booleans; }
@Nullable @Override public Serializable convert( @NonNull Inquiry inquiry, @NonNull ContentValue<byte[]> value, @NonNull Class<? extends Serializable> fieldType) throws IOException { try { byte[] blob = value.getContent(); return blob == null ? null : deserializeObject(blob, fieldType); } catch (IllegalArgumentException e) { throw new IOException(e); } }
@NonNull @Override public ContentValue<byte[]> convert(@NonNull Inquiry inquiry, @Nullable Serializable value) throws IOException { return ContentValue.valueOf(value == null ? null : serializeObject(value)); }