#107 Improve Private Class Data example JavaDoc

This commit is contained in:
Ilkka Seppala 2015-08-21 22:38:26 +03:00
parent 2bf00c3b5e
commit c32246e41d
2 changed files with 57 additions and 48 deletions

View File

@ -7,19 +7,23 @@ package com.iluwatar.privateclassdata;
* encapsulating them in single data object. It allows the class designer to * encapsulating them in single data object. It allows the class designer to
* remove write privilege of attributes that are intended to be set only during * remove write privilege of attributes that are intended to be set only during
* construction, even from methods of the target class. * construction, even from methods of the target class.
* * <p>
* In the example we have normal Stew class with some ingredients given in * In the example we have normal {@link Stew} class with some ingredients given in
* constructor. Then we have methods to enumerate the ingredients and to taste * constructor. Then we have methods to enumerate the ingredients and to taste
* the stew. The method for tasting the stew alters the private members of the * the stew. The method for tasting the stew alters the private members of the
* stew class. * {@link Stew} class.
* *
* The problem is solved with the Private Class Data pattern. We introduce * The problem is solved with the Private Class Data pattern. We introduce
* ImmutableStew class that contains StewData. The private data members of * {@link ImmutableStew} class that contains {@link StewData}. The private data members of
* Stew are now in StewData and cannot be altered by ImmutableStew methods. * {@link Stew} are now in {@link StewData} and cannot be altered by {@link ImmutableStew} methods.
* *
*/ */
public class App { public class App {
/**
* Program entry point
* @param args command line args
*/
public static void main( String[] args ) { public static void main( String[] args ) {
// stew is mutable // stew is mutable
Stew stew = new Stew(1, 2, 3, 4); Stew stew = new Stew(1, 2, 3, 4);

View File

@ -4,6 +4,11 @@ import org.junit.Test;
import com.iluwatar.privateclassdata.App; import com.iluwatar.privateclassdata.App;
/**
*
* Application test
*
*/
public class AppTest { public class AppTest {
@Test @Test