use of org.immutables.criteria.Criteria in project immutables by immutables.
the class JavaBeanModelTest method nullableByDefault.
/**
* JavaBean(s) have nullable types by default (except for primitives / optionals / iterables)
*/
@Test
public void nullableByDefault() {
ValueType valueType = rule.value(Model1.class);
Function<String, ValueAttribute> findFn = name -> valueType.attributes.stream().filter(a -> a.name().equals(name)).findAny().get();
// TODO: generate optional version of criteria ?
check(findFn.apply("dep").isNullable());
// boxed versions are nullable
check(findFn.apply("boxedInteger").isNullable());
// base is string (and can be null)
check(findFn.apply("base").isNullable());
// exclude nullable property from primitives / collections and optionals
// foo is int (primitive)
check(!findFn.apply("foo").isNullable());
// set is boolean
check(!findFn.apply("set").isNullable());
// deps is collection
check(!findFn.apply("deps").isNullable());
}
Aggregations