1 /**
2 * Copyright 2005-2015 The Kuali Foundation
3 *
4 * Licensed under the Educational Community License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.opensource.org/licenses/ecl2.php
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.kuali.rice.core.api.mo;
17
18 /**
19 * This is an interface that defines a builder. A builder is an object used to
20 * assemble and construct an instance of another object. Typically the object
21 * being constructed will be an immutable object (and therefore does not
22 * contain "setters" which can be used to mutate it's state). The builder
23 * pattern is a creation pattern that can be used to aid in the construction of
24 * these complex immutable objects.
25 *
26 * <p>This interface only defines a common {@link #build()} method which is
27 * used to return an instance of the object once state has been set on the
28 * builder to a point where construction of an object instance is deemed
29 * acceptable by the client code. Definition of type-specific setter methods
30 * are defined by the classes which implement this interface.
31 *
32 * <p>This version of the builder pattern is proposed by Joshua Bloch in his
33 * book "Effective Java". See "Effective Java" 2nd ed. page 15 for more
34 * information.
35 *
36 * @author Kuali Rice Team (rice.collab@kuali.org)
37 *
38 */
39 public interface ModelBuilder {
40
41 /**
42 * Returns an instance of the object being built by this builder based
43 * on the current state of the builder. It should be possible to
44 * invoke this method more than once on the same builder. It should
45 * never return null;
46 *
47 * @return an instance of the object being built by this builder,
48 * should never return null
49 */
50 Object build();
51
52 }