| |
---|
| | type.addField(new FieldDeclaration(new Type(rename, rename), |
---|
| | ((ResourceNode) re.getSource()).getIdentifierTemplate().getResourceName())); |
---|
| | type.addConstructors(new VariableDeclaration(new Type(rename, rename), |
---|
| | ((ResourceNode) re.getSource()).getIdentifierTemplate().getResourceName())); |
---|
| | }else { |
---|
| | vars.add(new VariableDeclaration(DataConstraintModel.typeInt, |
---|
| | } else { |
---|
| | vars.add(new VariableDeclaration( |
---|
| | ((ResourceNode) re.getSource()).getIdentifierTemplate().getResourceStateType(), |
---|
| | ((ResourceNode) re.getSource()).getIdentifierTemplate().getResourceName())); |
---|
| | flag = true; |
---|
| | } |
---|
| | } |
---|
| | if(flag) type.addMethod(new MethodDeclaration("update", false, new Type("Void", "void"), vars)); |
---|
| | if (flag) |
---|
| | type.addMethod(new MethodDeclaration("update", false, new Type("Void", "void"), vars)); |
---|
| | if (((StoreAttribute) rn.getAttribute()).isStored()) { |
---|
| | type.addField(new FieldDeclaration(DataConstraintModel.typeInt, |
---|
| | type.addField(new FieldDeclaration(rn.getIdentifierTemplate().getResourceStateType(), |
---|
| | rn.getIdentifierTemplate().getResourceName())); |
---|
| | } |
---|
| | type.addMethod(new MethodDeclaration("get" + type.getTypeName(),DataConstraintModel.typeInt)); |
---|
| | type.addMethod(new MethodDeclaration("get" + type.getTypeName(), |
---|
| | rn.getIdentifierTemplate().getResourceStateType())); |
---|
| | codes.add(type); |
---|
| | } |
---|
| | return codes; |
---|
| | } |
---|
| |
---|
| | } |
---|
| | } |
---|
| | codes.add(""); |
---|
| | if (type.getTypeName() != "Main") { |
---|
| | String cons = "\t" + "public " + type.getTypeName() + "("; |
---|
| | for (VariableDeclaration constructor : type.getConstructors()) { |
---|
| | cons += constructor.getType().getTypeName() + " " + constructor.getName() + ","; |
---|
| | } |
---|
| | if (!type.getConstructors().isEmpty()) |
---|
| | cons = cons.substring(0, cons.length() - 1); |
---|
| | cons += ");"; |
---|
| | codes.add(cons); |
---|
| | for (FieldDeclaration field : type.getFields()) { |
---|
| | for (VariableDeclaration vari : type.getConstructors()) { |
---|
| | if (field.getType().getTypeName().equals(vari.getType().getTypeName())) { |
---|
| | codes.add("\t\t" + "this." + field.getName() + " = " + field.getName() + ";"); |
---|
| | if (!type.getConstructors().isEmpty()) { |
---|
| | String cons = "\t" + "public " + type.getTypeName() + "("; |
---|
| | for (VariableDeclaration constructor : type.getConstructors()) { |
---|
| | cons += constructor.getType().getTypeName() + " " + constructor.getName() + ","; |
---|
| | } |
---|
| | if (!type.getConstructors().isEmpty()) |
---|
| | cons = cons.substring(0, cons.length() - 1); |
---|
| | cons += "){"; |
---|
| | codes.add(cons); |
---|
| | for (FieldDeclaration field : type.getFields()) { |
---|
| | for (VariableDeclaration vari : type.getConstructors()) { |
---|
| | if (field.getType().getTypeName().equals(vari.getType().getTypeName())) { |
---|
| | codes.add("\t\t" + "this." + field.getName() + " = " + field.getName() + ";"); |
---|
| | } |
---|
| | } |
---|
| | } |
---|
| | } |
---|
| | codes.add("\t" + "}"); |
---|
| | codes.add("\t" + "}"); |
---|
| | } |
---|
| | } |
---|
| | codes.add(""); |
---|
| | for (MethodDeclaration method : type.getMethods()) { |
---|
| | String varstr = "\t" + "public " + method.getReturnType().getImplementationTypeName() + " " |
---|
| |
---|
| | if (method.getParameters() != null) { |
---|
| | for (VariableDeclaration var : method.getParameters()) { |
---|
| | varstr += var.getType().getImplementationTypeName() + " " + var.getName() + ","; |
---|
| | } |
---|
| | if (!method.getParameters().isEmpty()) varstr = varstr.substring(0, varstr.length() - 1); |
---|
| | if (!method.getParameters().isEmpty()) |
---|
| | varstr = varstr.substring(0, varstr.length() - 1); |
---|
| | } |
---|
| | codes.add(varstr + ")" + "{"); |
---|
| | codes.add("\t" + "}"); |
---|
| | codes.add(""); |
---|
| |
---|
| | |