001package org.kuali.common.util.reflection; 002 003import static com.google.common.base.Preconditions.checkArgument; 004 005import org.apache.commons.lang3.StringUtils; 006 007public class Foo { 008 009 private final String bar; 010 011 private Foo(Builder builder) { 012 this.bar = builder.bar; 013 } 014 015 public static class Builder implements org.apache.commons.lang3.builder.Builder<Foo> { 016 017 private String bar; 018 019 public Builder bar(String bar) { 020 this.bar = bar; 021 return this; 022 } 023 024 @Override 025 public Foo build() { 026 Foo instance = new Foo(this); 027 validate(instance); 028 return instance; 029 } 030 031 private static void validate(Foo instance) { 032 checkArgument(!StringUtils.isBlank(instance.bar), "'bar' cannot be blank"); 033 } 034 } 035 036 public static class Builder2 extends Builder implements org.apache.commons.lang3.builder.Builder<Foo> { 037 } 038 039}