Skip to content

Instantly share code, notes, and snippets.

@elucash
Created October 13, 2015 03:45
Show Gist options
  • Save elucash/258cae1e7ecc31c02340 to your computer and use it in GitHub Desktop.
Save elucash/258cae1e7ecc31c02340 to your computer and use it in GitHub Desktop.
import com.google.common.collect.ImmutableList;
import com.google.common.base.Optional;
import org.immutables.value.Value;
interface Step {}
@Value.Immutable
interface StepsExtends {
ImmutableList<Step> steps();
public class Builder extends ImmutableStepsExtends.Builder {
public Builder addStep(Optional<Step> step) {
if (step.isPresent()) {
addSteps(step.get());
}
return this;
}
}
}
@Value.Immutable
interface StepsSuper {
ImmutableList<Step> steps();
public class Builder {
public ImmutableStepsSuper.Builder addStep(Optional<Step> step) {
ImmutableStepsSuper.Builder builder = (ImmutableStepsSuper.Builder) this;
if (step.isPresent()) {
builder.addSteps(step.get());
}
return builder;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment