91 lines
1.9 KiB
Java
91 lines
1.9 KiB
Java
package com.dbgen;
|
|
import java.io.PrintStream;
|
|
import java.util.Collection;
|
|
|
|
public class MethodSetMongoKey implements Visitor {
|
|
private final PrintStream ps;
|
|
private final String variable;
|
|
private final String varname;
|
|
private final String prefix;
|
|
|
|
public static void make(Collection<Variable> variables, PrintStream ps, String prefix) {
|
|
ps.println(prefix + "@Override");
|
|
ps.println(prefix + "public void init(int id,String mongoKey){");
|
|
ps.println(prefix +" setRootId(id);");
|
|
ps.println(prefix +" setMongoKey(mongoKey);");
|
|
for (Variable var : variables)
|
|
make(var, ps, prefix + " ");
|
|
ps.println(prefix + "}");
|
|
ps.println();
|
|
|
|
}
|
|
|
|
public static void make(Jbean bean, PrintStream ps, String prefix) {
|
|
make(bean.getVariables(), ps, prefix);
|
|
}
|
|
|
|
public static void make(Variable var, PrintStream ps, String prefix) {
|
|
var.getType().accept(new MethodSetMongoKey(var.getName(), ps, prefix));
|
|
}
|
|
|
|
public MethodSetMongoKey(String varname, PrintStream ps, String prefix) {
|
|
this.variable = varname;
|
|
this.varname = varname;
|
|
this.ps = ps;
|
|
this.prefix = prefix;
|
|
}
|
|
|
|
|
|
@Override
|
|
public void visit(TypeFloat type) {
|
|
}
|
|
@Override
|
|
public void visit(TypeDouble type) {
|
|
}
|
|
|
|
@Override
|
|
public void visit(TypeBoolean type) {
|
|
}
|
|
|
|
@Override
|
|
public void visit(TypeInt type) {
|
|
|
|
}
|
|
|
|
@Override
|
|
public void visit(TypeShort type) {
|
|
|
|
}
|
|
|
|
@Override
|
|
public void visit(TypeLong type){
|
|
}
|
|
|
|
|
|
@Override
|
|
public void visit(TypeString type) {
|
|
|
|
}
|
|
|
|
@Override
|
|
public void visit(TypeList type) {
|
|
//ps.println(prefix + variable + ".setVerify( getMongoKey(),getRootId())");
|
|
}
|
|
|
|
@Override
|
|
public void visit(TypeSet type) {
|
|
// ps.println(prefix + variable + ".setVerify( getMongoKey(),getRootId())");
|
|
}
|
|
|
|
@Override
|
|
public void visit(TypeMap type) {
|
|
//ps.println(prefix + variable + ".setVerify( getMongoKey(),getRootId())");
|
|
}
|
|
|
|
@Override
|
|
public void visit(Jbean type) {
|
|
|
|
}
|
|
|
|
}
|