//实现Comparator接口
public class ComparatorTravelSkyFlights implements Comparator<Map.Entry<String,List<EntityName>>> {
String sortColumn = "";
public ComparatorT() {
}
//传参比较
public ComparatorT(String sortColumn) {
this.sortColumn = sortColumn;
}
//实现compare类,获取实体里面的参数进行比较
@Override
public int compare(Map.Entry<String,List<EntityName>> mapping1,Map.Entry<String,List<EntityName>> mapping2){
if("depTime".equals(this.sortColumn)){
if(mapping1.getValue().size() > 0
&& mapping2.getValue().size() > 0){
if(mapping1.getValue().get(0).getDepDate() != null
&& mapping2.getValue().get(0).getDepDate() !=null){
return mapping1.getValue().get(0).getDepDate().toString().
compareTo(mapping2.getValue().get(0).getDepDate().toString());
}
}
else{
if(mapping1.getValue().size() == 0){
return -1;
}
else{
return 1;
}
}
return -1;
}
}
}
}
//调用方法
List<Map.Entry<String,List<EntityName>>> mappingList = null;
//通过ArrayList构造函数把map.entrySet()转换成list
mappingList = new ArrayList<Map.Entry<String,List<EntityName>>>(entityName.entrySet());
//通过比较器实现比较排序,ordColumn需要排序方式上升或下降
ComparatorTravelSkyFlights comparatorT = new ComparatorTravelSkyFlights(ordColumn);
Collections.sort(mappingList, comparatorT);
分享到:
相关推荐
public List<Map<String, Object>> search(String sql, Map<String, Object> params) throws DaoAccessException { try { logger.debug(sql); return namedParameterJdbcTemplate.queryForList(sql, params...
protected List<Content> getList(Map<String, TemplateModel> params, Environment env) throws TemplateException { Integer[] ids = DirectiveUtils.getIntArray(PARAM_IDS, params); if (ids != null) { //...
public List<User> getUserLists(Map<String, Object> map) { return null; } @Override public Integer getUserCount(Map<String, Object> map) { String sql = "select count(1) from User where id=? ...
public String invokeServiceMethod(String url,Map<String,String> params,Map<String, String> header) throws Exception{ HttpClient httpclient=new DefaultHttpClient(); HttpResponse response = null; ...
List<Pois> list=new ArrayList<Pois>(); SAXReader saxReader = new SAXReader(); org.dom4j.Document document=null; //从api上面解析 if(flg.equals("URL")){ String url = UrlUtils.getBaiduMapUrl...
• Single Table per Class Hierarchy Strategy: the <subclass> element in Hibernate 每个类层次结构一张表 • Joined Subclass Strategy: the <joined-subclass> element in Hibernate 连接的子类策略 @...
* @MapKey(name="“多端”做为Key的属性") * public Map<“多端”做为Key的属性的类,主表类> get“多端”列表(){return “多端”列表} * “多端”配置参考@ManyToOne. * 方法三 使用这种配置,在为“一端”添加...
javax.persistence.MapKey.class javax.persistence.MapKeyClass.class javax.persistence.MapKeyColumn.class javax.persistence.MapKeyEnumerated.class javax.persistence.MapKeyJoinColumn.class javax....
在Web开发中需要处理HTML标记时,应做什么样的处理,要筛选那些字符(< > & “”) 3.在JSP中如何读取客户端的请求,如何访问CGI变量,如何确定某个Jsp文件的真实路径。 4.描述Cookie和Session的作用,区别和各自...
<>boolean Boolean char Character byte Byte short Short int Integer long Long float Float double Double 引用类型和原始类型的行为完全不同,并且它们具有不同的语义。引用类型和原始类型具有...
6.3.5. 使用<idbag> 6.4. 集合例子(Collection example) 7. 关联关系映射 7.1. 介绍 7.2. 单向关联(Unidirectional associations) 7.2.1. 多对一(many to one) 7.2.2. 一对一(one to one) 7.2.3. 一对...
6.3.5. 使用<idbag> 6.4. 集合例子(Collection example) 7. 关联关系映射 7.1. 介绍 7.2. 单向关联(Unidirectional associations) 7.2.1. 多对一(many to one) 7.2.2. 一对一(one to one) 7.2.3. 一对...
6.3.5. 使用<idbag> 6.4. 集合例子(Collection example) 7. 关联关系映射 7.1. 介绍 7.2. 单向关联(Unidirectional associations) 7.2.1. 多对一(many to one) 7.2.2. 一对一(one to one) 7.2.3. 一对...
Collections是针对集合类的一个帮助类,他提供一系列静态方法实现对各种集合的搜索、排序、线程安全化等操作。 13、&和&&的区别。 &是位运算符,表示按位与运算,&&是逻辑运算符,表示逻辑与(and)。 14、...
6.3.5. 使用<idbag> 6.4. 集合例子(Collection example) 7. 关联关系映射 7.1. 介绍 7.2. 单向关联(Unidirectional associations) 7.2.1. 多对一(many to one) 7.2.2. 一对一(one to one) 7.2.3. 一对...
6.3.5. 使用<idbag> 6.4. 集合例子(Collection example) 7. 关联关系映射 7.1. 介绍 7.2. 单向关联(Unidirectional associations) 7.2.1. 多对一(many to one) 7.2.2. 一对一(one to one) 7.2.3. 一对多(one ...
6.3.5. 使用<idbag> 6.4. 集合例子(Collection example) 7. 关联关系映射 7.1. 介绍 7.2. 单向关联(Unidirectional associations) 7.2.1. 多对一(many to one) 7.2.2. 一对一(one to one) 7.2.3. 一对...
Collections是针对集合类的一个帮助类,他提供一系列静态方法实现对各种集合的搜索、排序、线程安全化等操作。 10、&和&&的区别。 &是位运算符,表示按位与运算,&&是逻辑运算符,表示逻辑与(and)。 11、HashMap...
Collections是针对集合类的一个帮助类,他提供一系列静态方法实现对各种集合的搜索、排序、线程安全化等操作。 10、&和&&的区别。 &是位运算符,表示按位与运算,&&是逻辑运算符,表示逻辑与(and)。 11、HashMap...
6.3.5. 使用<idbag> 6.4. 集合例子(Collection example) 7. 关联关系映射 7.1. 介绍 7.2. 单向关联(Unidirectional associations) 7.2.1. 多对一(many to one) 7.2.2. 一对一(one to one) 7.2.3. 一对多(one ...