0

I have got an annotation with about 10 parameters, all optional. But in case you use them, it may look like this:

@myAnnotation(oneFlag anotherFlag parameter="value").

Splitting the one annotation into several, the example would look like this:

@oneFlag @anotherFlag @parameter("value");

Which "good java style" criterial exist for this?

1 Answer 1

2

I suspect it depends how cohesive the annotations are. For example:

Bad (difficult to tell which annotations relate to each other):

@Transaction(Isolation.DEFAULT)
@TransactionRollbackFor(Bar.class)
@ReadOnly // Not actually related to transactions
public class Foo { }

Good:

@Transactional(isolation=Isolation.DEFAULT,rollbackFor=Bar.class)
@ReadOnly
public class Foo { }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.