ByteArrayConverter { public static final void setInstance(@NonNull ByteArrayConverter s) throws IllegalArgumentException { INSTANCE.set(check(Objects.requireNonNull(s))); }  @NonNull static final ByteArrayConverter getInstance(); static final void setInstance(@NonNull ByteArrayConverter s); @NonNull @NewObject byte[] fromDoubleArray(@NonNull double[] input); @NonNull @NewObject double[] toDoubleArray(@NonNull byte[] input); @NonNull static final ByteArrayConverter getDefault(); @NonNull static final ByteArrayConverter getDeflate(int level, boolean nowrap);  }
@Test @SuppressWarnings("null") public void testInstance() { Assertions.assertThatThrownBy(() -> ByteArrayConverter.setInstance(null)) .isInstanceOf(NullPointerException.class); ByteArrayConverter c1 = new ByteArrayConverter() { @Override public byte[] fromDoubleArray(double[] input) { throw new RuntimeException(); } }; Assertions.assertThatThrownBy(() -> ByteArrayConverter.setInstance(c1)) .isInstanceOf(IllegalArgumentException.class) .hasCauseInstanceOf(RuntimeException.class); ByteArrayConverter c2 = new ByteArrayConverter() { @Override public double[] toDoubleArray(byte[] input) { return new double[0]; } }; Assertions.assertThatThrownBy(() -> ByteArrayConverter.setInstance(c2)) .isInstanceOf(IllegalArgumentException.class) .hasNoCause(); }