Open giflw opened 7 years ago
Hi there, It probably wouldn't be that hard to add. Do you imagine using the || to get nicer formatting in your tables?
Regarding your point about parsing 2 or more types, what exactly do you mean? Could you maybe give an example?
Cheers, Ben
Hi, sorry for the delay. Regarding to "||", would be nice to have something like this:
a | b | c || max
1 | 2 | 3 || 3
5 | 6 | 7 || 7
9 | 8 | 7 || 9
Regarding two 2 or more type, i problably was thinking in something like:
List<List<Book>, List<Price>> booksAnPrices = GroovyTables.createListOf(Book.class, Price.class).fromTable {
author | title || cost | symbol
"Jane Austen" | "Pride and Prejudice" || 12.95 | "USD"
"Harper Lee" | "To Kill a Mockingbird" || 14.95 | "USD"
"F. Scott Fitzgerald" | "The Great Gatsby" || 12.95 | "REA"
"Charlotte Brontë" | "Jane Eyre" || 6.95 | "REA"
"George Orwell" | "1984" || 8.95 | "USD"
"J.D. Salinger" | "The Catcher in the Rye" || 6.95 | "REA"
"William Shakespeare" | "Romeo and Juliet" || 5.95 | "USD"
}
Hi there, Not sure about two separate lists.... Do you think that could be of much use?
I could imagine this type of thing:
List<Book> booksAnPrices = GroovyTables.createListOf(Book.class, Price.class).fromTable {
author | title || cost | symbol
"Jane Austen" | "Pride and Prejudice" || 12.95 | "USD"
"Harper Lee" | "To Kill a Mockingbird" || 14.95 | "USD"
"F. Scott Fitzgerald" | "The Great Gatsby" || 12.95 | "REA"
"Charlotte Brontë" | "Jane Eyre" || 6.95 | "REA"
"George Orwell" | "1984" || 8.95 | "USD"
"J.D. Salinger" | "The Catcher in the Rye" || 6.95 | "REA"
"William Shakespeare" | "Romeo and Juliet" || 5.95 | "USD"
}
Where the constructor for book is:
public Book(String author, String title, Price price)
So that the Price would be injected into the constructor of the Book.
Would that be useful to you?
Cheers, Ben
Actually, I think that might prove too complex. (My idea not yours). I'll have a think on it.
Hi! Your idea is really interesting! If you build the objects from tail to head on the given list, maybe be easy to create the object from the table. With this approach, we avoid an extra for
each time to do the composition (outside the library). In fact, this was the use I was thinking.
Hey @giflw, I think the enhancement does have some merit. Might have to think a bit more on implementation details. I probably haven't got the bandwidth to implement such a feature at the moment. Will leave the issue open for possible future development.
Hi
I use the Spock Framework, and they have support for both "|" and "||" operators. I really don't know how it works. I tried to use "||" and I notice that those values where ignored (I got coersion error).
Would be nice to have support for "||", if its easy to add. Could even be added a way to parse 2 or more types (varargs) of object at once using "||" separator?
Thanks