Commit 758f5298 by s_guodong

增加ModuleList中缺少的方法

parent 1cc8da9d
package com.brilliance.mda.runtime.mda;
import com.brilliance.mda.runtime.annotation.Module;
import java.util.Collection;
import java.util.List;
import java.util.Map;
......@@ -50,4 +48,16 @@ public interface IModule extends IBaseObject {
Map<String, Object> getAttrMaps();
void setPageSize(int paramInt);
void setPaging(boolean paramBoolean);
void setPage(int paramInt);
int getPageSize();
int getPage();
int getRealIndex(int paramInt);
}
......@@ -33,6 +33,8 @@ public abstract class AbstractModule implements IModule, IModuleRoot {
private String serialNum;
protected transient boolean paging = false;
private Map<String, Object> attrMaps = new HashMap<>();
public AbstractModule() {
......@@ -212,13 +214,45 @@ public abstract class AbstractModule implements IModule, IModuleRoot {
}
}
public void setAttrMaps(Map<String, Object> attrMaps) {
this.attrMaps = attrMaps;
}
@Override
public Map<String, Object> getAttrMaps() {
return attrMaps;
}
public void setAttrMaps(Map<String, Object> attrMaps) {
this.attrMaps = attrMaps;
@Override
public void setPaging(boolean paging) {
this.paging = paging;
}
@Override
public void setPageSize(int paramInt) {
}
@Override
public void setPage(int paramInt) {
}
@Override
public int getPageSize() {
return 0;
}
@Override
public int getPage() {
return 0;
}
@Override
public int getRealIndex(int paramInt) {
return 0;
}
......
......@@ -29,6 +29,10 @@ public class ModuleList<T extends IModule> extends ArrayList<T> implements IModu
private Class<T> dataClass;
private static Field parentField;
private String moduleType;
protected transient boolean paging = false;
protected transient int pageSize = 0;
protected transient int page = 1;
protected transient int fullSize = -1;
static {
try {
......@@ -294,7 +298,52 @@ public class ModuleList<T extends IModule> extends ArrayList<T> implements IModu
return attrMaps;
}
public void setAttrMaps(Map<String, Object> attrMaps) {
this.attrMaps = attrMaps;
}
@Override
public void setPageSize(int paramInt) {
this.pageSize = paramInt;
}
@Override
public void setPaging(boolean paging) {
this.paging = paging;
}
@Override
public void setPage(int paramInt) {
if (!this.paging) {
this.page = (page >= 1) ? ((page <= getPages()) ? page : getPages()) : 1;
} else {
this.page = (page >= 1) ? page : 1;
}
}
@Override
public int getPageSize() {
return this.pageSize;
}
@Override
public int getPage() {
return this.page;
}
@Override
public int getRealIndex(int index) {
if (this.pageSize == 0 || !this.paging)
return index;
return (this.page - 1) * this.pageSize + index;
}
public int getPages() {
if (this.pageSize <= 0)
return 0;
int size = (this.fullSize > 0) ? this.fullSize : size();
return (size % this.pageSize == 0) ? (size / this.pageSize) : (size / this.pageSize + 1);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment