Package naming corrections and cleanup.

This commit is contained in:
Ilkka Seppala 2015-09-18 19:59:52 +03:00
parent 570a30099e
commit dd0fcea090
20 changed files with 33 additions and 284 deletions

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<class-diagram version="1.1.8" icons="true" automaticImage="PNG" always-add-relationships="false" generalizations="true"
realizations="true" associations="true" dependencies="false" nesting-relationships="true">
<class id="1" language="java" name="com.iluwatar.fluentinterface.App" project="fluentinterface"
file="/fluentinterface/src/main/java/com/iluwatar/fluentinterface/App.java" binary="false" corner="BOTTOM_RIGHT">
<class id="1" language="java" name="com.iluwatar.fluentinterface.app.App" project="fluentinterface"
file="/fluentinterface/src/main/java/com/iluwatar/fluentinterface/app/App.java" binary="false" corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="289" y="-8"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
@ -55,7 +55,7 @@
</display>
</class>
<interface id="6" language="java" name="java.lang.Iterable" project="fluentinterface"
file="/opt/Softwares/Eclipses/MARS/eclipse/jre/lib/rt.jar" binary="true" corner="BOTTOM_RIGHT">
file="C:/Program Files/Java/jdk1.8.0_25/jre/lib/rt.jar" binary="true" corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="793" y="-163"/>
<display autosize="true" stereotype="true" package="true" initial-value="false" signature="true"
sort-features="false" accessors="true" visibility="true">
@ -64,33 +64,33 @@
</display>
</interface>
<dependency id="7">
<end type="SOURCE" refId="1"/>
<end type="TARGET" refId="2"/>
</dependency>
<realization id="8">
<end type="SOURCE" refId="3"/>
<end type="TARGET" refId="4"/>
</realization>
<dependency id="9">
<end type="SOURCE" refId="3"/>
<end type="TARGET" refId="5"/>
</dependency>
<generalization id="10">
<end type="SOURCE" refId="4"/>
<end type="TARGET" refId="6"/>
</generalization>
<dependency id="11">
<dependency id="8">
<end type="SOURCE" refId="1"/>
<end type="TARGET" refId="3"/>
</dependency>
<dependency id="12">
<dependency id="9">
<end type="SOURCE" refId="1"/>
<end type="TARGET" refId="4"/>
</dependency>
<realization id="13">
<realization id="10">
<end type="SOURCE" refId="2"/>
<end type="TARGET" refId="4"/>
</realization>
<realization id="11">
<end type="SOURCE" refId="3"/>
<end type="TARGET" refId="4"/>
</realization>
<dependency id="12">
<end type="SOURCE" refId="1"/>
<end type="TARGET" refId="2"/>
</dependency>
<generalization id="13">
<end type="SOURCE" refId="4"/>
<end type="TARGET" refId="6"/>
</generalization>
<classifier-display autosize="true" stereotype="true" package="true" initial-value="true" signature="true"
sort-features="false" accessors="true" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>

View File

@ -1,4 +1,4 @@
package com.iluwatar.fluentinterface;
package com.iluwatar.fluentinterface.app;
import com.iluwatar.fluentinterface.fluentiterable.FluentIterable;
import com.iluwatar.fluentinterface.fluentiterable.lazy.LazyFluentIterable;

View File

@ -1,7 +1,9 @@
package com.iluwatar.fluentinterface;
package com.iluwatar.fluentinterface.app;
import org.junit.Test;
import com.iluwatar.fluentinterface.app.App;
public class AppTest {
@Test

View File

@ -1,29 +0,0 @@
package com.iluwatar.model.view.controller.with.observer;
/**
*
* In this second example the model-view relationship is different. This time we use the Observer pattern to notify
* the {@link GiantView} each time the {@link GiantModel} is changed. This way the {@link GiantController} responsibilities
* are narrowed and it only needs to modify the {@link GiantModel} according to the user input.
*
*/
public class App {
/**
* Program entry point
* @param args command line args
*/
public static void main( String[] args ) {
// create model, view and controller
GiantModel giant = new GiantModel(Health.HEALTHY, Fatigue.ALERT, Nourishment.SATURATED);
GiantView view = new GiantView();
GiantController controller = new GiantController(giant, view);
// initial display
controller.updateView();
// controller receives some interactions that affect the giant
// model modifications trigger the view rendering automatically
controller.setHealth(Health.WOUNDED);
controller.setNourishment(Nourishment.HUNGRY);
controller.setFatigue(Fatigue.TIRED);
}
}

View File

@ -1,22 +0,0 @@
package com.iluwatar.model.view.controller.with.observer;
/**
*
* Fatigue enumeration
*
*/
public enum Fatigue {
ALERT("alert"), TIRED("tired"), SLEEPING("sleeping");
private String title;
Fatigue(String title) {
this.title = title;
}
@Override
public String toString() {
return title;
}
}

View File

@ -1,46 +0,0 @@
package com.iluwatar.model.view.controller.with.observer;
/**
*
* GiantController updates the giant model.
*
*/
public class GiantController {
private GiantModel giant;
private GiantView view;
public GiantController(GiantModel giant, GiantView view) {
this.giant = giant;
this.view = view;
this.giant.registerObserver(this.view);
}
public Health getHealth() {
return giant.getHealth();
}
public void setHealth(Health health) {
this.giant.setHealth(health);
}
public Fatigue getFatigue() {
return giant.getFatigue();
}
public void setFatigue(Fatigue fatigue) {
this.giant.setFatigue(fatigue);
}
public Nourishment getNourishment() {
return giant.getNourishment();
}
public void setNourishment(Nourishment nourishment) {
this.giant.setNourishment(nourishment);
}
public void updateView() {
this.view.displayGiant(giant);
}
}

View File

@ -1,63 +0,0 @@
package com.iluwatar.model.view.controller.with.observer;
import java.util.ArrayList;
import java.util.List;
/**
*
* GiantModel contains the giant data.
*
*/
public class GiantModel {
private Health health;
private Fatigue fatigue;
private Nourishment nourishment;
private List<GiantModelObserver> observers = new ArrayList<>();
GiantModel(Health health, Fatigue fatigue, Nourishment nourishment) {
this.health = health;
this.fatigue = fatigue;
this.nourishment = nourishment;
}
public Health getHealth() {
return health;
}
public void setHealth(Health health) {
this.health = health;
notifyObservers();
}
public Fatigue getFatigue() {
return fatigue;
}
public void setFatigue(Fatigue fatigue) {
this.fatigue = fatigue;
notifyObservers();
}
public Nourishment getNourishment() {
return nourishment;
}
public void setNourishment(Nourishment nourishment) {
this.nourishment = nourishment;
notifyObservers();
}
@Override
public String toString() {
return String.format("The giant looks %s, %s and %s.", health, fatigue, nourishment);
}
public void registerObserver(GiantModelObserver observer) {
observers.add(observer);
}
private void notifyObservers() {
observers.stream().forEach((GiantModelObserver o) -> o.modelChanged(this));
}
}

View File

@ -1,12 +0,0 @@
package com.iluwatar.model.view.controller.with.observer;
/**
*
* GiantModelObserver is the interface for delivering update notifications.
*
*/
public interface GiantModelObserver {
void modelChanged(GiantModel model);
}

View File

@ -1,18 +0,0 @@
package com.iluwatar.model.view.controller.with.observer;
/**
*
* GiantView displays the giant
*
*/
public class GiantView implements GiantModelObserver {
public void displayGiant(GiantModel giant) {
System.out.println(giant);
}
@Override
public void modelChanged(GiantModel model) {
displayGiant(model);
}
}

View File

@ -1,22 +0,0 @@
package com.iluwatar.model.view.controller.with.observer;
/**
*
* Health enumeration
*
*/
public enum Health {
HEALTHY("healthy"), WOUNDED("wounded"), DEAD("dead");
private String title;
Health(String title) {
this.title = title;
}
@Override
public String toString() {
return title;
}
}

View File

@ -1,22 +0,0 @@
package com.iluwatar.model.view.controller.with.observer;
/**
*
* Nourishment enumeration
*
*/
public enum Nourishment {
SATURATED("saturated"), HUNGRY("hungry"), STARVING("starving");
private String title;
Nourishment(String title) {
this.title = title;
}
@Override
public String toString() {
return title;
}
}

View File

@ -1,19 +0,0 @@
package com.iluwatar.model.view.controller.with.observer;
import org.junit.Test;
import com.iluwatar.model.view.controller.with.observer.App;
/**
*
* Application test
*
*/
public class AppTest {
@Test
public void test() {
String[] args = {};
App.main(args);
}
}

View File

@ -4,9 +4,9 @@ import java.util.List;
import com.iluwatar.servicelayer.magic.MagicService;
import com.iluwatar.servicelayer.magic.MagicServiceImpl;
import com.iluwatar.servicelayer.servicelayer.spell.Spell;
import com.iluwatar.servicelayer.servicelayer.spell.SpellDao;
import com.iluwatar.servicelayer.servicelayer.spell.SpellDaoImpl;
import com.iluwatar.servicelayer.spell.Spell;
import com.iluwatar.servicelayer.spell.SpellDao;
import com.iluwatar.servicelayer.spell.SpellDaoImpl;
import com.iluwatar.servicelayer.spellbook.Spellbook;
import com.iluwatar.servicelayer.spellbook.SpellbookDao;
import com.iluwatar.servicelayer.spellbook.SpellbookDaoImpl;

View File

@ -3,7 +3,7 @@ package com.iluwatar.servicelayer.hibernate;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import com.iluwatar.servicelayer.servicelayer.spell.Spell;
import com.iluwatar.servicelayer.spell.Spell;
import com.iluwatar.servicelayer.spellbook.Spellbook;
import com.iluwatar.servicelayer.wizard.Wizard;

View File

@ -2,7 +2,7 @@ package com.iluwatar.servicelayer.magic;
import java.util.List;
import com.iluwatar.servicelayer.servicelayer.spell.Spell;
import com.iluwatar.servicelayer.spell.Spell;
import com.iluwatar.servicelayer.spellbook.Spellbook;
import com.iluwatar.servicelayer.wizard.Wizard;

View File

@ -3,8 +3,8 @@ package com.iluwatar.servicelayer.magic;
import java.util.ArrayList;
import java.util.List;
import com.iluwatar.servicelayer.servicelayer.spell.Spell;
import com.iluwatar.servicelayer.servicelayer.spell.SpellDao;
import com.iluwatar.servicelayer.spell.Spell;
import com.iluwatar.servicelayer.spell.SpellDao;
import com.iluwatar.servicelayer.spellbook.Spellbook;
import com.iluwatar.servicelayer.spellbook.SpellbookDao;
import com.iluwatar.servicelayer.wizard.Wizard;

View File

@ -1,4 +1,4 @@
package com.iluwatar.servicelayer.servicelayer.spell;
package com.iluwatar.servicelayer.spell;
import javax.persistence.Column;
import javax.persistence.Entity;

View File

@ -1,4 +1,4 @@
package com.iluwatar.servicelayer.servicelayer.spell;
package com.iluwatar.servicelayer.spell;
import com.iluwatar.servicelayer.common.Dao;

View File

@ -1,4 +1,4 @@
package com.iluwatar.servicelayer.servicelayer.spell;
package com.iluwatar.servicelayer.spell;
import org.hibernate.Criteria;
import org.hibernate.Session;

View File

@ -13,7 +13,7 @@ import javax.persistence.OneToMany;
import javax.persistence.Table;
import com.iluwatar.servicelayer.common.BaseEntity;
import com.iluwatar.servicelayer.servicelayer.spell.Spell;
import com.iluwatar.servicelayer.spell.Spell;
import com.iluwatar.servicelayer.wizard.Wizard;
/**