VAT implements ValueObject { public static VAT valueOf(Integer percentage) { return percentage == null ? null : new VAT(percentage); } @JsonCreator  VAT(int percentage); static VAT valueOf(Integer percentage); @JsonValue int toInteger(); double toDouble(); @NonNull Money addTax(@NonNull Money amount); @NonNull Money subtractTax(@NonNull Money amount); @NonNull Money calculateTax(@NonNull Money amount); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }
@Test public void valueOf_nonNullPercentage_vatCreated() { assertThat(VAT.valueOf(24)).isNotNull(); }
@Test public void valueOf_nullPercentage_nullReturned() { assertThat(VAT.valueOf(null)).isNull(); }