Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend @Table with attributes to enable automatic numbering of rows and columns #116

Closed
janschaefer opened this issue Sep 10, 2015 · 9 comments
Assignees
Milestone

Comments

@janschaefer
Copy link
Contributor

Suggestion:

@Table( rowIndex = true, colIndex = true )
@janschaefer
Copy link
Contributor Author

What about the title for these index columns/rows, should that be configurable or would be the default # enough?

@nikowitt
Copy link
Contributor

I think it makes sense to be able to configure the title in these cases while using "#" as default.

@janschaefer
Copy link
Contributor Author

What do you think about the following:

@Table( rowIndex = true )

Add an index to each row with header #.

@Table( rowIndexCol = "Counter" )

Adds an index to each row with header Counter.

@nikowitt
Copy link
Contributor

That'll be great!

@janschaefer janschaefer self-assigned this Sep 11, 2015
@nikowitt
Copy link
Contributor

Hi,
I'm just curious regarding your implementation:

Is there any specific reason you decided to implement the default header with a blank value and then to e.g. implement

if( dataTable.hasVerticalHeader() ) {
                String header = "#";
                if( !tableAnnotation.numberedColumnsHeader().equals( "" ) ) {
                    header = tableAnnotation.numberedColumnsHeader();
                }
                row.add( header );
            }

instead of just providing the default value "#" in the annotation itself and then just to use

if( dataTable.hasVerticalHeader() ) {
                    header = tableAnnotation.numberedColumnsHeader();
row.add( header );
}

It's less verbose and you could directly see in the annotation what default value is used?

Regards Niko

@janschaefer
Copy link
Contributor Author

Cool that you review my code! :-)

But there actually is a reason, but a subtle one. The problem is that I have to distinguish whether a user has explicitly set a column header or not. In Java, I cannot set the default value to null which would be the obvious value for absent. So while your above code would work with your suggestion, the code that decides whether or not to add numbered columns would not work. The problem is when a user actually uses the default like this:

@Table( numberedColumnsHeader = "#" )

Then I do not know any more whether the user explictly wanted the default, or whether the value was the default. The same happens with my solution when a user writes

@Table( numberedColumnsHeader = "" )

Which I assume is unlikely.

@janschaefer
Copy link
Contributor Author

Thinking a bit more about this, it might not be that unlikely that a user explicitly wants an empty header. So maybe I should change the default to something like "__NOT_SET"

@nikowitt
Copy link
Contributor

Well, I'm a curious guy ;)

Ah, OK, i didn't see that there is the requirement to be able to distinguish between set or not that (I was just aware of the code change and then concluded that e.g. hasVerticalHeader() property was enough to determine whether something is set or not without knowing how it is actually calculated.

The reason I'm pointing that out is that I've actually expected the "#" to also be included in the @table JavaDoc somewhere to know that this is used as a default value even though the annotation property default value is something different.

@janschaefer
Copy link
Contributor Author

Yes, you are right. I improved the JavaDoc and also changed the default so that you can now even specify @Table( numberedRowsHeader = "").

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants