Added [Feature]: a toString() method for enumerated values in Java#103
Added [Feature]: a toString() method for enumerated values in Java#103subhajit20 wants to merge 4 commits intoaccordproject:mainfrom
Conversation
Signed-off-by: Subhajit Ghosh <subhajitstd07@gmail.com>
Signed-off-by: Subhajit Ghosh <subhajitstd07@gmail.com>
Signed-off-by: Subhajit Ghosh <subhajitstd07@gmail.com>
|
hey @mttrbrts @sanketshevkar can you please review and give some feedback |
Signed-off-by: Subhajit Ghosh <subhajitstd07@gmail.com>
| public enum LaptopMake { | ||
| Apple, | ||
| Microsoft, | ||
| @Override |
There was a problem hiding this comment.
I am not sure if enums in java store functions.
There was a problem hiding this comment.
Yes it does, because I have created one java program where I declared a enum and inside it defined the toString function and it worked totally final without any issue
There was a problem hiding this comment.
Okay, thanks for clarification. I'm not much proficient in Java. @mttrbrts can you please review this?
There was a problem hiding this comment.
Here is a sample code snippet
public class Main{
public enum State {
MA,
NY,
CO,
// Override the toString() method for the entire enum type
@Override
public String toString() {
return name();
}
}
public static void main(String[] args) {
// Using the enum constants
State state1 = State.MA;
State state2 = State.NY;
String ma = state1.toString(); // This will call the overridden toString() method
// Printing the enum constants
System.out.println("State 1: " + ma);
}
}
There was a problem hiding this comment.
Hey @sanketshevkar Have one question, How can I pass extra parameters like parameters.filewriter as show in the code.. I mean to say can we pass other parameter like this parameters.x ?
concerto-codegen/lib/codegen/fromcto/java/javavisitor.js
Lines 142 to 146 in 7c14d70
There was a problem hiding this comment.
yes, you can. it is an options object on the visitor. (answered by @dselman on the Tech WG call)
There was a problem hiding this comment.
yes, you can. it is an options object on the visitor. (answered by @dselman on the Tech WG call)
Okay ... I am assuming is that something like this parameters.options
18522a9 to
7c14d70
Compare
Closes accordproject/concerto#100
Changes
Author Checklist
--signoffoption of git commit.mainfromfork:branchname