com.terapico.caf.wxappviewcomponent.BaseWxappViewComponent Maven / Gradle / Ivy
package com.terapico.caf.wxappviewcomponent;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.terapico.caf.viewcomponent.BaseViewComponent;
public abstract class BaseWxappViewComponent extends BaseViewComponent{
protected String id;
protected Map className;
protected List kids;
protected Map customStyle;
protected Object flex;
protected String linkToUrl;
public Map getCustomStyle() {
return customStyle;
}
public Object getFlex() {
return flex;
}
public void setFlex(Object flex) {
this.flex = flex;
}
public String getLinkToUrl() {
return linkToUrl;
}
public void setLinkToUrl(String linkToUrl) {
this.linkToUrl = linkToUrl;
}
public void setCustomStyle(Map customStyle) {
this.customStyle = customStyle;
}
public List getKids() {
return kids;
}
public void setKids(List kids) {
this.kids = kids;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public Map getClassName() {
return className;
}
public void setClassName(Map className) {
this.className = className;
}
public T withId(String id) {
this.setId(id);
return (T) this;
}
public T withClassName(String clazzName) {
ensureClassName();
this.className.put(clazzName, true);
return (T) this;
}
public T withCustomStyle(String name, Object value) {
ensuerCustomStyle();
customStyle.put(name, value);
return (T) this;
}
public T withFlex(Object value) {
this.setFlex(value);
return (T) this;
}
protected void ensuerCustomStyle() {
if (customStyle == null) {
customStyle = new HashMap<>();
}
}
public T kid(BaseWxappViewComponent kid) {
ensureKids();
kids.add(kid);
if (kid.getId() == null) {
kid.setId(String.format("%s-%04d", kid.getType(), kids.size()));
}
return (T) this;
}
protected void ensureKids() {
if (kids == null) {
kids = new ArrayList<>();
}
}
protected void ensureClassName() {
if (className == null) {
className = new HashMap<>();
}
}
@Override
public Map toMap(){
Map resultMap = new HashMap<>();
putInMap(resultMap, "id", getId());
putInMap(resultMap, "className", getClassName());
putInMap(resultMap, "linkToUrl", getLinkToUrl());
putInMap(resultMap, "type", getType());
putInMap(resultMap, "flex", getFlex());
putInMap(resultMap, "customStyle", getCustomStyle());
mapFieldsToMap(resultMap);
if (kids != null) {
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy