mkarneim / pojobuilder

A Java Code Generator for Pojo Builders
Other
334 stars 44 forks source link

Why is no optional method generated for primitive fields? #122

Closed Adrodoc closed 7 years ago

Adrodoc commented 7 years ago

For instance the class PojoWithGuavaOptionalBuilder could very well have this additional method:

/**
 * Optionally sets the default value for the {@link PojoWithGuavaOptional#boxedInt} property.
 *
 * @param optionalValue the default value
 * @return this builder
 */
public PojoWithGuavaOptionalBuilder withPrimitiveInt(Optional<Integer> optionalValue) {
  return optionalValue.isPresent()?withPrimitiveInt(optionalValue.get()):self;
}

The generation of such a method is prevented here. For comparison, with-Builder methods are generated for primitive types as you can see in PojoBuilder

mkarneim commented 7 years ago

You are right. I guess I just missed it when I merged this code into PB. Feel free to fix it and send me some pull request. ;-)