public String generateSource_AddElements(ModelField modelField) { String fieldNameCapped = NameUtil.capName(modelField.getName()); String fieldNameUncapped = NameUtil.uncapName(modelField.getName()); String fieldClassName = TypeUtil.getClassName(modelField.getType()); String fieldTypeLocalPart = TypeUtil.getLocalPart(modelField.getType()); Buf buf = new Buf(); buf.putLine2("putElements(" + fieldTypeLocalPart + "Map);"); return buf.get(); }
public String generateSource_SetElement(ModelField modelField) { String fieldNameCapped = NameUtil.capName(modelField.getName()); String fieldNameUncapped = NameUtil.uncapName(modelField.getName()); String fieldClassName = TypeUtil.getClassName(modelField.getType()); String fieldTypeLocalPart = TypeUtil.getLocalPart(modelField.getType()); Buf buf = new Buf(); // buf.putLine2("synchronized (this."+fieldNameUncapped+") {"); buf.putLine2("this." + fieldNameUncapped + " = " + fieldTypeLocalPart + ";"); // buf.putLine2("}"); return buf.get(); }
public String generateSource_PutElement(ModelField modelField) { String fieldType = modelField.getType(); String fieldTypeLocalPart = TypeUtil.getLocalPart(fieldType); Buf buf = new Buf(); buf.putLine2("putElement(" + fieldTypeLocalPart + "Key, " + fieldTypeLocalPart + ");"); return buf.get(); }
public String generateSource_GetElements(ModelField modelField) { Buf buf = new Buf(); String structure = modelField.getStructure(); if (structure.equals("map")) { String fieldType = modelField.getType(); String fieldTypeLocalPart = TypeUtil.getLocalPart(fieldType); buf.putLine2("return getElements(" + fieldTypeLocalPart + "Keys);"); } return buf.get(); }
public String generateSource_Constructor(Cache cache) { Buf buf = new Buf(); List<Field> fields = ElementUtil.getFields(cache); Iterator<Field> iterator = fields.iterator(); while (iterator.hasNext()) { Field field = iterator.next(); String className = TypeUtil.getClassName(field.getType()); String structure = field.getStructure(); if (structure.equals("item")) { // buf.putLine2(field.getName()+" = new "+className+"();"); } else if (structure.equals("list")) { buf.putLine2(field.getName() + " = new ArrayList<" + className + ">();"); } else if (structure.equals("set")) { buf.putLine2(field.getName() + " = new HashSet<" + className + ">();"); } else if (structure.equals("map")) { String keyClassName = TypeUtil.getClassName(field.getKey()); buf.putLine2( field.getName() + " = new HashMap<" + keyClassName + ", " + className + ">();"); } } return buf.get(); }
public String generateSource_RemoveElements(ModelField modelField) { String fieldNameCapped = NameUtil.capName(modelField.getName()); String fieldNameUncapped = NameUtil.uncapName(modelField.getName()); String fieldClassName = TypeUtil.getClassName(modelField.getType()); String fieldTypeLocalPart = TypeUtil.getLocalPart(modelField.getType()); String parameterName = fieldTypeLocalPart; String structure = modelField.getStructure(); if (structure.equals("list")) { parameterName = fieldTypeLocalPart + "List"; } else if (structure.equals("set")) { parameterName = fieldTypeLocalPart + "Set"; } else if (structure.equals("map")) { parameterName = fieldTypeLocalPart + "Map"; } Buf buf = new Buf(); buf.putLine2("synchronized (" + fieldNameUncapped + ") {"); buf.putLine2(" " + fieldNameUncapped + ".removeAll(" + parameterName + ");"); buf.putLine2("}"); return buf.get(); }