Enum RestLinkType

    • Enum Constant Detail

      • TYPE

        public static final RestLinkType TYPE
        It will inject the links that return the link type RestLink.entityType() without filtering or searching. For example:
             @GET
             @Path("/records")
             @RestLink(rel = "list")
             @InjectRestLinks(RestLinkType.TYPE)
             public List getAll() { // ... }
        
             @GET
             @Path("/records/valid")
             @RestLink
             public List getValidRecords() { // ... }
        
             @GET
             @Path("/records/{id}")
             @RestLink(rel = "self")
             public TestRecord getById(@PathParam("id") int id) { // ... }
         

        Note that the method `getAll` is annotated with `@InjectRestLinks(RestLinkType.TYPE)`, so when calling to the endpoint `/records`, it will inject the following links:

         Link: ; rel="list"
         Link: ; rel="getValidRecords"
         

        The method `getById` is not injected because it's instance based (it depends on the field `id`).

      • INSTANCE

        public static final RestLinkType INSTANCE
        It will inject all the links that return the link type RestLink.entityType(). For example:
        
             @GET
             @RestLink(rel = "list")
             public List getAll() { // ... }
        
             @GET
             @Path("/records/{id}")
             @RestLink(rel = "self")
             @InjectRestLinks(RestLinkType.INSTANCE)
             public TestRecord getById(@PathParam("id") int id) { // ... }
        
             @GET
             @Path("/records/{slug}")
             @RestLink
             public TestRecord getBySlug(@PathParam("slug") String slug) { // ... }
        
             @DELETE
             @Path("/records/{id}")
             @RestLink
             public TestRecord delete(@PathParam("slug") String slug) { // ... }
         

        Note that the method `getById` is annotated with `@InjectRestLinks(RestLinkType.INSTANCE)`, so when calling to the endpoint `/records/1`, it will inject the following links:

         Link: ; rel="list"
         Link: ; rel="self"
         Link: ; rel="getBySlug"
         Link: ; rel="delete"
         

        Now, all the links have been injected.

    • Method Detail

      • values

        public static RestLinkType[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (RestLinkType c : RestLinkType.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static RestLinkType valueOf​(String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null