Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Java Annotations Writing Your Own Annotation Using a Custom Annotation

zlatkap
zlatkap
21,494 Points

@Secure(Role.ADMIN)?

How can I tell if it is required based on the information?

1 Answer

Ah, i made this mistake too at my first try. The assertion is: "The element name below is required"

@Secure(role = Role.ADMIN)

To answer this question it is "key" (sorry for the bad joke) to understand, that an element consists of a pair of key and value. Now, the name of this element (key&value) is just, what ever you named the key.

for example: favouriteFood = "Pizza" --> elements name is "favouriteFood"

bestBandEver = "The Dandy Warhols" --> elements name is "bestBandEver"

And by some madness convention some dudes decided that if you key is called "value", you can leave the assignment part and just write down the value of the key named "value".

I hope this helps someone =)