package com.changhong.epc.count.service.count.model;
|
|
import java.util.ArrayList;
|
import java.util.Collection;
|
import java.util.Iterator;
|
import java.util.List;
|
import java.util.ListIterator;
|
|
import com.changhong.epc.bean.tenant.norm.AppStanderDef;
|
|
|
/**
|
* 该类只为
|
* [补助标准-维度]
|
* 定制数据接口,仅实现了 java.util.List.add(T) 方法
|
* 其数据格式封装为二维数组
|
* 慎用!
|
* @ClassName: MatrixList
|
|
* @author [九鼎联合科技]
|
* @date 2017年3月18日 下午9:24:20
|
*/
|
public class MatrixList implements List<AppStanderDef>{
|
|
private List<AppStanderDef[]> data = new ArrayList<>();
|
|
private List<AppStanderDef> row;
|
|
private AppStanderDef lastApp;
|
|
@Override
|
public boolean add(AppStanderDef e) {
|
if(lastApp == null){
|
return addRow(e);
|
}else{
|
if(compareRow(lastApp,e)){
|
return addRow(e);
|
}else{
|
return addCol(e);
|
}
|
}
|
}
|
public MatrixList() {
|
}
|
/*
|
* 添加行
|
*/
|
protected boolean addRow(AppStanderDef e) {
|
if(row == null) row = new ArrayList<>();
|
row.add(e);
|
lastApp = e;
|
return true;
|
}
|
|
protected boolean addCol(AppStanderDef e) {
|
/* 向矩阵中添加一行 */
|
AppStanderDef[] appRow = new AppStanderDef[row.size()];
|
row.toArray(appRow);
|
data.add(appRow);
|
row = null;
|
return addRow(e);
|
}
|
|
public AppStanderDef[][] toMatrix(){
|
|
if(row == null)
|
return new AppStanderDef[0][0];
|
AppStanderDef[] appRow = new AppStanderDef[row.size()];
|
row.toArray(appRow);
|
data.add(appRow);
|
if(data.isEmpty())
|
return new AppStanderDef[0][0];
|
AppStanderDef[][] apCounts = new AppStanderDef[data.size()][data.get(0).length];
|
data.toArray(apCounts);
|
return apCounts;
|
}
|
|
/**
|
* 比较行号
|
* @param lastApp
|
* @param app
|
* @return
|
*/
|
public boolean compareRow(AppStanderDef lastApp ,AppStanderDef app){
|
return (lastApp.getRowNo() - app.getRowNo()) == 0;
|
}
|
@Override
|
public void add(int index, AppStanderDef element) {
|
// 暂不实现
|
}
|
|
@Override
|
public boolean addAll(Collection<? extends AppStanderDef> c) {
|
return false;
|
}
|
|
@Override
|
public boolean addAll(int index, Collection<? extends AppStanderDef> c) {
|
return false;
|
}
|
|
@Override
|
public void clear() {
|
// 暂不实现
|
}
|
|
@Override
|
public boolean contains(Object o) {
|
return false;
|
}
|
|
@Override
|
public boolean containsAll(Collection<?> c) {
|
return false;
|
}
|
|
@Override
|
public AppStanderDef get(int index) {
|
return null;
|
}
|
|
@Override
|
public int indexOf(Object o) {
|
return 0;
|
}
|
|
@Override
|
public boolean isEmpty() {
|
return false;
|
}
|
|
@Override
|
public Iterator<AppStanderDef> iterator() {
|
return null;
|
}
|
|
@Override
|
public int lastIndexOf(Object o) {
|
return 0;
|
}
|
|
@Override
|
public ListIterator<AppStanderDef> listIterator() {
|
return new ArrayList().listIterator();
|
}
|
|
@Override
|
public ListIterator<AppStanderDef> listIterator(int index) {
|
return new ArrayList().listIterator();
|
}
|
|
@Override
|
public boolean remove(Object o) {
|
return false;
|
}
|
|
// @Override
|
// public AppStanderDef remove1(int index) {
|
// return new AppStanderDef();
|
// }
|
|
@Override
|
public boolean removeAll(Collection<?> c) {
|
return false;
|
}
|
|
@Override
|
public boolean retainAll(Collection<?> c) {
|
return false;
|
}
|
|
@Override
|
public AppStanderDef set(int index, AppStanderDef element) {
|
return new AppStanderDef();
|
}
|
|
@Override
|
public int size() {
|
return 0;
|
}
|
|
@Override
|
public List<AppStanderDef> subList(int fromIndex, int toIndex) {
|
return new ArrayList<>();
|
}
|
|
@Override
|
public Object[] toArray() {
|
return new Object[0];
|
}
|
|
@Override
|
public <T> T[] toArray(T[] a) {
|
return (T[]) new Object[0];
|
}
|
|
@Override
|
public AppStanderDef remove(int index) {
|
// TODO Auto-generated method stub
|
return null;
|
}
|
}
|