{title:'Utility Beans', created:'9.0.0'}

The {@link oajr.beans} package contains a set of reusable utility beans meant to help with putting together explorable REST interfaces.

The {@link oaj.examples.rest.UtilityBeansResource} class shows how these beans are used. The resource class is hosted in the example REST applications rendered below:

##### ResourceDescriptions

The {@link oaj.examples.rest.UtilityBeansResource#getChildDescriptions() getChildDescriptions()} method shows an example of rendering a list of descriptive links for child endpoints.

| @RestGet("/") | public ResourceDescriptions getChildDescriptions() { | return ResourceDescriptions | .create() | .append("BeanDescription", "Example of BeanDescription bean") | .append("Hyperlink", "Example of Hyperlink bean") | .append("SeeOtherRoot", "Example of SeeOtherRoot bean"); | }

##### HTML representation

##### JSON representation

##### BeanDescription

The {@link oaj.examples.rest.UtilityBeansResource#aBeanDescription() aBeanDescription()} method shows an example of rendering simple schema information about an arbitrary bean class.

| @RestGet("/BeanDescription") | @HtmlDocConfig( | aside={ | "<div class='text'>", | " <p>Example of serialized org.apache.juneau.rest.utilitybeans.ResourceDescriptions bean.</p>", | "</div>" | } | ) | public BeanDescription aBeanDescription() { | return BeanDescription. of(Address. class); | }

##### HTML representation

##### JSON representation

##### Hyperlink

The {@link oaj.examples.rest.UtilityBeansResource#aHyperlink() aHyperlink()} method shows an example of rendering a simple hyperlink.

| @RestGet("/Hyperlink") | @HtmlDocConfig( | aside={ | "<div class='text'>", | " <p>Example of serialized org.apache.juneau.rest.utilitybeans.Hyperlink bean.</p>", | "</div>" | } | ) | public Hyperlink aHyperlink() { | return Hyperlink. create("/utilitybeans", "Back to /utilitybeans"); | }

##### HTML representation

##### JSON representation

##### SeeOtherRoot

The {@link oaj.examples.rest.UtilityBeansResource#aSeeOtherRoot() aSeeOtherRoot()} method shows an example of sending a 303 See Other with a Location header pointing to the servlet root.

| @RestGet("/SeeOtherRoot") | @HtmlDocConfig( | aside={ | "<div class='text'>", | " <p>Example of serialized org.apache.juneau.rest.utilitybeans.SeeOtherRoot bean.</p>", | "</div>" | } | ) | public SeeOtherRoot aSeeOtherRoot() { | return SeeOtherRoot. INSTANCE; | }

Clicking on the link will just redirect to this same page.

Typically this is useful for endpoints where you want to redirect back to the servlet root, such as a DELETE.