一、UML图
二、实例
1、SubSystemN
package com.designPattern.facade;
/**
* Created by ZhangJintao on 2020/3/12.
*/
public class CollectionData {
public void collectionData(){
System.out.println("我是数据采集层,负责采集数据。");
}
}
package com.designPattern.facade;
/**
* Created by ZhangJintao on 2020/3/12.
*/
public class CalculateData {
public void calculateData(){
System.out.println("我是数据处理层,负责处理数据!");
}
}
package com.designPattern.facade;
/**
* Created by ZhangJintao on 2020/3/12.
*/
public class DataInDb {
public void dataInDb(){
System.out.println("我是数据入关系数据库层!");
}
}
package com.designPattern.facade;
/**
* Created by ZhangJintao on 2020/3/12.
*/
public class DataView {
public void dataView(){
System.out.println("我是数据展示层,负责将数据展示出来!");
}
}
2、Facade
package com.designPattern.facade;
/**
* Created by ZhangJintao on 2020/3/12.
*/
public class DataDealFacade {
private CalculateData calculateData;
private CollectionData collectionData;
private DataInDb dataInDb;
private DataView dataView;
public DataDealFacade() {
this.calculateData = new CalculateData();
this.collectionData = new CollectionData();
this.dataInDb = new DataInDb();
this.dataView = new DataView();
}
public void dealData(){
calculateData.calculateData();
collectionData.collectionData();
dataInDb.dataInDb();
dataView.dataView();
}
}
3、Client
package com.designPattern.facade;
/**
* Created by ZhangJintao on 2020/3/12.
*/
public class main {
public static void main(String[] args) {
DataDealFacade dataDealFacade = new DataDealFacade();
dataDealFacade.dealData();
}
}