-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
525 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.speedment.codegen; | ||
|
||
import com.speedment.codegen.model.Class_; | ||
import com.speedment.codegen.model.Field_; | ||
import static com.speedment.codegen.model.Type_.STRING; | ||
|
||
/** | ||
* | ||
* @author pemi | ||
*/ | ||
public class Test { | ||
|
||
/** | ||
* @param args the command line arguments | ||
*/ | ||
public static void main(String[] args) { | ||
|
||
final Field_ field = new Field_(STRING, "foo").private_(); | ||
|
||
final Class_ class_ = new Class_(); | ||
class_.add(field); | ||
class_.add(new Field_(STRING, "bar")); | ||
|
||
} | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/com/speedment/codegen/control/AccessorImplementer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.speedment.codegen.control; | ||
|
||
/** | ||
* | ||
* @author pemi | ||
*/ | ||
public class AccessorImplementer { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.speedment.codegen.model; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* | ||
* @author pemi | ||
*/ | ||
public class Block_ { | ||
|
||
private final List<Statement_> statements; | ||
|
||
public Block_() { | ||
this.statements = new ArrayList<>(); | ||
} | ||
|
||
Block_ add(Statement_ statement_) { | ||
getStatements().add(statement_); | ||
return this; | ||
} | ||
|
||
public List<Statement_> getStatements() { | ||
return statements; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.speedment.codegen.model; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* | ||
* @author pemi | ||
*/ | ||
public class Class_ { | ||
|
||
private final List<Field_> fields; | ||
private final List<Constructor_> constructors; | ||
private final List<Method_> methods; | ||
|
||
public Class_() { | ||
this.fields = new ArrayList<>(); | ||
constructors = new ArrayList<>(); | ||
methods = new ArrayList<>(); | ||
} | ||
|
||
public Class_ add(Field_ field) { | ||
getFields().add(field); | ||
return this; | ||
} | ||
|
||
public Class_ add(Constructor_ constructor) { | ||
getConstructors().add(constructor); | ||
return this; | ||
} | ||
|
||
public Class_ add(Method_ method_) { | ||
getMethods().add(method_); | ||
return this; | ||
} | ||
|
||
public List<Field_> getFields() { | ||
return fields; | ||
} | ||
|
||
public List<Constructor_> getConstructors() { | ||
return constructors; | ||
} | ||
|
||
public List<Method_> getMethods() { | ||
return methods; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.speedment.codegen.model; | ||
|
||
/** | ||
* | ||
* @author pemi | ||
*/ | ||
public class Constructor_ { | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/com/speedment/codegen/model/Expression_.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.speedment.codegen.model; | ||
|
||
/** | ||
* | ||
* @author pemi | ||
*/ | ||
public class Expression_ { | ||
|
||
private String stringExpression; | ||
|
||
public Expression_(String stringExpression) { | ||
this.stringExpression = stringExpression; | ||
} | ||
|
||
public String getStringExpression() { | ||
return stringExpression; | ||
} | ||
|
||
public Expression_ setStringExpression(String stringExpression) { | ||
this.stringExpression = stringExpression; | ||
return this; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
package com.speedment.codegen.model; | ||
|
||
/** | ||
* | ||
* @author pemi | ||
*/ | ||
public class Field_ { | ||
|
||
protected boolean private_; | ||
protected boolean static_; | ||
protected boolean final_; | ||
protected Type_ type_; | ||
private CharSequence name_; | ||
private Expression_ expression_; | ||
|
||
public Field_(Type_ type_, CharSequence name_) { | ||
this.type_ = type_; | ||
this.name_ = name_; | ||
} | ||
|
||
public Field_ private_() { | ||
return private_(true); | ||
} | ||
|
||
public Field_ private_(boolean private_) { | ||
this.private_ = private_; | ||
return this; | ||
} | ||
|
||
public Field_ static_() { | ||
return static_(true); | ||
} | ||
|
||
public Field_ static_(boolean static_) { | ||
this.final_ = static_; | ||
return this; | ||
} | ||
|
||
public Field_ final_(boolean final_) { | ||
this.final_ = final_; | ||
return this; | ||
} | ||
|
||
public Field_ final_() { | ||
return final_(true); | ||
} | ||
|
||
// public static class Builder extends Field_ { | ||
// | ||
// public Builder(Type_ type_, CharSequence name_) { | ||
// super(type_, name_); | ||
// } | ||
// | ||
// public Builder private_() { | ||
// return private_(true); | ||
// } | ||
// | ||
// public Builder private_(boolean private_) { | ||
// this.private_ = private_; | ||
// return this; | ||
// } | ||
// | ||
// public Builder static_(boolean static_) { | ||
// this.final_ = static_; | ||
// return this; | ||
// } | ||
// | ||
// public Builder final_(boolean final_) { | ||
// this.final_ = final_; | ||
// return this; | ||
// } | ||
// | ||
// public Field_ build() { | ||
// return new Field_(private_, static_, final_, type_, name_); | ||
// } | ||
// | ||
// } | ||
// | ||
// public static Builder builder(Type_ type_, CharSequence name_) { | ||
// return new Builder(type_, name_); | ||
// } | ||
|
||
public CharSequence getName_() { | ||
return name_; | ||
} | ||
|
||
public void setName_(CharSequence name_) { | ||
this.name_ = name_; | ||
} | ||
|
||
public Expression_ getExpression_() { | ||
return expression_; | ||
} | ||
|
||
public void setExpression_(Expression_ expression_) { | ||
this.expression_ = expression_; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
package com.speedment.codegen.model; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* | ||
* @author pemi | ||
*/ | ||
public class Method_ { | ||
|
||
private boolean private_; | ||
private boolean static_; | ||
private boolean final_; | ||
private Type_ type_; | ||
private CharSequence name_; | ||
private Expression_ expression_; | ||
private Block_ block; | ||
private List<Field_> parameters; // Todo: Introduce parameter | ||
|
||
public Method_(Type_ type_, CharSequence name_) { | ||
this.parameters = new ArrayList<>(); | ||
this.type_ = type_; | ||
this.name_ = name_; | ||
} | ||
|
||
public Method_ private_() { | ||
return private_(true); | ||
} | ||
|
||
public Method_ private_(boolean private_) { | ||
this.setPrivate_(private_); | ||
return this; | ||
} | ||
|
||
public Method_ static_() { | ||
return static_(true); | ||
} | ||
|
||
public Method_ static_(boolean static_) { | ||
this.setFinal_(static_); | ||
return this; | ||
} | ||
|
||
public Method_ final_(boolean final_) { | ||
this.setFinal_(final_); | ||
return this; | ||
} | ||
|
||
public Method_ final_() { | ||
return final_(true); | ||
} | ||
|
||
Method_ add(Field_ field_) { | ||
getParameters().add(field_); | ||
return this; | ||
} | ||
|
||
public boolean isPrivate_() { | ||
return private_; | ||
} | ||
|
||
public void setPrivate_(boolean private_) { | ||
this.private_ = private_; | ||
} | ||
|
||
public boolean isStatic_() { | ||
return static_; | ||
} | ||
|
||
public void setStatic_(boolean static_) { | ||
this.static_ = static_; | ||
} | ||
|
||
public boolean isFinal_() { | ||
return final_; | ||
} | ||
|
||
public void setFinal_(boolean final_) { | ||
this.final_ = final_; | ||
} | ||
|
||
public Type_ getType_() { | ||
return type_; | ||
} | ||
|
||
public void setType_(Type_ type_) { | ||
this.type_ = type_; | ||
} | ||
|
||
public CharSequence getName_() { | ||
return name_; | ||
} | ||
|
||
public void setName_(CharSequence name_) { | ||
this.name_ = name_; | ||
} | ||
|
||
public Expression_ getExpression_() { | ||
return expression_; | ||
} | ||
|
||
public void setExpression_(Expression_ expression_) { | ||
this.expression_ = expression_; | ||
} | ||
|
||
public Block_ getBlock() { | ||
return block; | ||
} | ||
|
||
public void setBlock(Block_ block) { | ||
this.block = block; | ||
} | ||
|
||
public List<Field_> getParameters() { | ||
return parameters; | ||
} | ||
|
||
public void setParameters(List<Field_> parameters) { | ||
this.parameters = parameters; | ||
} | ||
|
||
} |
Oops, something went wrong.