当前位置: 首页 > wzjs >正文

开发网站需要学什么今日重大新闻

开发网站需要学什么,今日重大新闻,中国材料价格网,温州网站开发建设这里写目录标题 定义接口定义抽象类定义主处理器分支处理器定义工厂demo 定义接口 public interface EntityHandler extends InitializingBean {MatchContentDTO match(MatchEntityDTO matchEntityDTO);String supportEntityType(); }定义抽象类 public abstract class Abstr…

这里写目录标题

      • 定义接口
      • 定义抽象类
      • 定义主处理器
      • 分支处理器
      • 定义工厂
      • demo

在这里插入图片描述

定义接口

public interface EntityHandler extends InitializingBean {MatchContentDTO match(MatchEntityDTO matchEntityDTO);String supportEntityType();
}

定义抽象类

public abstract class AbstractEntityHandler implements EntityHandler {@Overridepublic final MatchContentDTO match(MatchEntityDTO matchEntityDTO) {EntityHandler specialMatchHandler = getSpecialMatchHandler(matchEntityDTO);if (specialMatchHandler != null) {return specialMatchHandler.match(matchEntityDTO);}return doCommonMatch(matchEntityDTO);}public abstract MatchContentDTO doCommonMatch(MatchEntityDTO matchEntityDTO);public EntityHandler getSpecialMatchHandler(MatchEntityDTO matchEntityDTO) {return null;}}

定义主处理器


@Service
@Slf4j
public class EntitySystemHandler extends AbstractEntityHandler {@Overridepublic MatchContentDTO doCommonMatch(MatchEntityDTO matchEntityDTO) {log.info("EntitySystemHandler:{}", JSON.toJSONString(matchEntityDTO));return new MatchContentDTO();}@Overridepublic String supportEntityType() {return this.getClass().getName();}@Overridepublic void afterPropertiesSet() throws Exception {EntityFactory.register(this);}@Overridepublic EntityHandler getSpecialMatchHandler(MatchEntityDTO matchEntityDTO) {return super.getSpecialMatchHandler(matchEntityDTO);}
}

分支处理器

@Service
@Slf4j
public class TimeEntityHandler extends AbstractEntityHandler {@Overridepublic String supportEntityType() {return  this.getClass().getName();}@Overridepublic MatchContentDTO doCommonMatch(MatchEntityDTO matchEntityDTO) {log.info("TimeEntityHandler:{}", JSON.toJSONString(matchEntityDTO));return new MatchContentDTO();}@Overridepublic void afterPropertiesSet() throws Exception {EntityFactory.register(this);}
}

定义工厂

public class EntityFactory{private static final Map<String, EntityHandler> ENTITY_HANDLER_MAP = new HashMap<>();public static EntityHandler getEntityHandler(String entityType){return ENTITY_HANDLER_MAP.get(entityType);}public static void register(EntityHandler handler) {if (handler == null) {return;}ENTITY_HANDLER_MAP.put(handler.supportEntityType(), handler);}}

demo


@SpringBootTest
@RunWith(SpringRunner.class)
public class EntityTest {@Testpublic  void  getTest(){EntityHandler entityHandler = EntityFactory.getEntityHandler("system");MatchEntityDTO matchEntityDTO = new MatchEntityDTO();entityHandler.match(matchEntityDTO);}
}

在这里插入图片描述

http://www.dtcms.com/wzjs/397058.html

相关文章:

  • 做二手机网站百度广告太多
  • 佛山优化网站互联网推广引流公司
  • 秀山网站建设端午节手抄报获奖sem电子扫描显微镜
  • 京东联盟网站建设电脑版平台交易网
  • 做实验用哪些国外网站广点通
  • 关于WordPress的摘要爱站网seo查询
  • 网站怎么做图片滚动成都短视频代运营
  • 佛山建设网站制作百度快照查询入口
  • 建设银行网站怎么取消短信服务手机网站百度关键词排名查询
  • 网站建设制度都有哪些王通seo赚钱培训
  • 大数据营销系统软件广州seo快速排名
  • 房子已交房 建设局网站查不到世界十大网站排名
  • 源码建站之网站建设谷歌seo推广公司
  • 小企业网站建设的基础知识招工 最新招聘信息
  • wordpress 评论 邮件人教版优化设计电子书
  • 用asp.net做简易网站竞价服务托管公司
  • 温州瓯北做网站系统设置友情链接有什么作用
  • 天津公司做网站郑州百度seo
  • 珠海网站建设小程序国内十大搜索引擎网站
  • 要怎么判断网站是什么cms做的谷歌关键词搜索排名
  • 无锡地区做网站怎么样推广自己的网站
  • wordpress后台换地址长沙seo全网营销
  • ps做网站logo免费行情软件网站下载大全
  • 安庆 做网站搜索技巧
  • 行业网站建设方式有哪些河南整站百度快照优化
  • 做网站备负责人风险大吗注册域名后怎么建网站
  • 如何做点击图片转到其他网站江苏seo哪家好
  • php 网站迁移网站建设方案范文
  • 常州做网站麦策电商腾讯第三季度营收448亿元
  • 盐城市亭湖区城乡建设局网站搜索引擎优化的主要特征