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

西安seo服务外包seo如何优化

西安seo服务外包,seo如何优化,安徽软件定制开发,wordpress 进后台白屏组合模式 1、组合模式解决这样的问题,当我们的要处理的对象可以生成一颗树形结构,而我们要对树上的节点和叶子进行操作时,它能够提供一致的方式,而不用考虑它是节点还是叶子。 示意图如下 2、 原理结构图 Data public abstrac…

组合模式

1、组合模式解决这样的问题,当我们的要处理的对象可以生成一颗树形结构,而我们要对树上的节点和叶子进行操作时,它能够提供一致的方式,而不用考虑它是节点还是叶子。
示意图如下
2、在这里插入图片描述

原理结构图
在这里插入图片描述

@Data
public abstract  class OrganizationComponent {//名字private String name;//说明private String description;protected void add(OrganizationComponent organizationComponent) {//默认实现throw new UnsupportedOperationException();}protected void remove(OrganizationComponent organizationComponent) {//默认实现throw new UnsupportedOperationException();}//构造器public OrganizationComponent(String name, String description) {this.name = name;this.description = description;}//方法打印 做成抽象的protected abstract void print();
}
@Slf4j
public class University extends OrganizationComponent {List<OrganizationComponent> organizationComponents = new ArrayList<OrganizationComponent>();public University(String name, String description) {super(name, description);}//重写@Overrideprotected void add(OrganizationComponent organizationComponent) {organizationComponents.add(organizationComponent);}//重写@Overrideprotected void remove(OrganizationComponent organizationComponent) {organizationComponents.remove(organizationComponent);}//重写@Overrideprotected void print() {log.info("================大学【{}】================", getName());for (OrganizationComponent organizationComponent : organizationComponents) {organizationComponent.print();}}@Overridepublic String getName() {return super.getName();}@Overridepublic String getDescription() {return super.getDescription();}
}
@Slf4j
public class College extends OrganizationComponent {//List中存放的是departmentList<OrganizationComponent> organizationComponents = new ArrayList<OrganizationComponent>();public College(String name, String description) {super(name, description);}//重写@Overrideprotected void add(OrganizationComponent organizationComponent) {//将来实际业务中,College的add方法和University的add方法不一定完全相同organizationComponents.add(organizationComponent);}//重写@Overrideprotected void remove(OrganizationComponent organizationComponent) {organizationComponents.remove(organizationComponent);}//重写@Overrideprotected void print() {log.info("============学院:{}=============", getName());for (OrganizationComponent organizationComponent : organizationComponents) {organizationComponent.print();}}@Overridepublic String getName() {return super.getName();}@Overridepublic String getDescription() {return super.getDescription();}
}
@Slf4j
public class Department extends OrganizationComponent {public Department(String name, String description) {super(name, description);}//重写【add,remove都不用再写了,因为他是叶子结点】@Overrideprotected void print() {log.info("专业:{}", getName());}@Overridepublic String getName() {return super.getName();}@Overridepublic String getDescription() {return super.getDescription();}
}
//============================
@Slf4j
public class Client {public static void main(String[] args) {//从大到小创建对象 学校OrganizationComponent university = new University("清华大学", "中国顶级大学");//创建学院College computerCollege = new College("计算机学院", "计算机学院");College infoEngineerCollege = new College("信息工程学院", "信息工程学院");//创建各个学院下的专业computerCollege.add(new Department("软件工程", "软件工程不错"));computerCollege.add(new Department("网络工程", "网络工程不错"));computerCollege.add(new Department("计算机科学与技术", "计算机科学与技术是一个老牌的专业"));infoEngineerCollege.add(new Department("通信工程", "通信工程不好学"));infoEngineerCollege.add(new Department("信息工程", "信息工程很好学"));university.add(computerCollege);university.add(infoEngineerCollege);university.print();}
}
  • 打印

大学【清华大学】
学院:计算机学院=
==专业:软件工程
==专业:网络工程
==专业:计算机科学与技术
学院:信息工程学院=
==专业:通信工程
==专业:信息工程

总结

1、简化客户端操作。客户端只需要面对一致的对象而不用考虑整体部分或者节点叶子的问题。
2、具有较强的扩展性。当我们要更改组合对象时,我们只需要调整内部的层次关系,客户端不用做出任何改动。
3、方便创建出复杂的层次结构,客户端不用理会组合里面的组成细节,容易添加剂诶单或者叶子从而创建出复杂的树形结构。
4、需要遍历组织机构,或者处理的对象具有树形结构时,非常适合使用组合模式。
5、要求较高的抽象性,如果节点和叶子有很大的差异性的话,比如很多方法和树形都不一样,不适用于组合模式。

jdk的HashMap使用到了组合模式


public interface Map<K,V> {//add  remove
}
static class Node<K,V> implements Map.Entry<K,V> {final int hash;final K key;V value;Node<K, V> next;
}public class HashMap<K,V> extends AbstractMap<K,V>implements Map<K,V>, Cloneable, Serializable {}
http://www.dtcms.com/wzjs/397452.html

相关文章:

  • 国外哪个网站可以做外贸比较好有人百度看片吗
  • 网页设计软件排名seo公司是什么意思
  • 做网站设计的提成点是多少软文广告属于什么营销
  • 电商网站后台建设广东今天新闻最新消息
  • 网站建设中可能出现的问题海外社交媒体营销
  • 做品牌特卖的网站代写文章价格表
  • 怎么自己建立一个网站后台seo推广专员工作好做吗
  • 专门做租房的网站重庆森林经典台词截图
  • 内蒙古自治区党风廉政建设网站怎么做推广
  • 怎样自己做卖商品的网站交换链接的作用
  • 自己做的微课上传到哪个网站网络营销师主要做什么
  • 丰城市城乡规划建设局网站怎样推广公司的网站
  • 如何做网站的301重定向链接推广
  • 建设共享经济网站的可行性泉州网站seo公司
  • 自建网站需要哪些技术b2b电商平台有哪些
  • 做房产网站不备案可以吗黄冈免费网站推广平台汇总
  • 离线网站制作活动策划公司
  • 做前端网站考虑兼容分辨率宁波网络推广方式
  • 万网可以花钱做网站吗上海排名优化seo
  • 林州网站建设价格南京今天重大新闻事件
  • 国内做设计的网站有哪些上海网站建设关键词排名
  • 主流的外贸平台深圳网络推广优化
  • 辽宁省住房和城乡建设部网站厦门零基础学seo
  • 有ecs怎么做网站百度云官网
  • 开发房地产需要多少钱石家庄seo网络优化的公司
  • 上海比较好的电商公司有哪些seo整站网站推广优化排名
  • 传媒公司网站源码php近日发生的重大新闻
  • 怎么搜索网站内容淘宝关键词搜索量排名
  • z-blog和wordpress哪个好seo排名规则
  • 佛山网站策划公司优化网站关键词的技巧