/** * Define a relationship for the give rel name to a LinkBuilder. If supported, * the output rendering (serialization) will be an array (or list) instead * of a single object for this rel name. * * @param name the relationship name (rel name). * @param builder an OptionalLinkBuilder instance. * @return this relationship definition instance to facilitate method chaining. */ public RelationshipDefinition rels(String name, ConditionalLinkBuilder builder) { arrayRels.add(name); return rel(name, builder); }
/** * Define a relationship for the given rel name to a URL. * * @param rel the relationship name (rel name). * @param href the URL, possibly templated. * @return this relationship definition instance to facilitate method chaining. */ public RelationshipDefinition rel(String rel, String href) { return rel(rel, factory.newLinkBuilder(href)); }
public static void define(RestExpress server) { Map<String, String> routes = server.getRouteUrlsByName(); HyperExpress.relationships() .forCollectionOf(Record.class) .rel(RelTypes.SELF, routes.get(Constants.Routes.RECORD_COLLECTION)) .withQuery("limit={limit}") .withQuery("offset={offset}") .rel(RelTypes.NEXT, routes.get(Constants.Routes.RECORD_COLLECTION) + "?offset={nextOffset}") .withQuery("limit={limit}") .optional() .rel(RelTypes.PREV, routes.get(Constants.Routes.RECORD_COLLECTION) + "?offset={prevOffset}") .withQuery("limit={limit}") .optional() .forClass(Record.class) .rel(RelTypes.SELF, routes.get(Constants.Routes.SINGLE_RECORD)) .rel(RelTypes.UP, routes.get(Constants.Routes.RECORD_COLLECTION)); } }
/** * * @param server */ public static void define(RestExpress server) { Map<String, String> routes = server.getRouteUrlsByName(); HyperExpress.relationships() .forCollectionOf(Transaction.class) .rel(RelTypes.SELF, routes.get(Constants.Routes.TRANSACTION_COLLECTION)) .withQuery("limit={limit}") .withQuery("offset={offset}") .rel(RelTypes.NEXT, routes.get(Constants.Routes.TRANSACTION_COLLECTION) + "?offset={nextOffset}") .withQuery("limit={limit}") .optional() .rel(RelTypes.PREV, routes.get(Constants.Routes.TRANSACTION_COLLECTION) + "?offset={prevOffset}") .withQuery("limit={limit}") .optional() .forClass(Transaction.class) .rel(RelTypes.SELF, routes.get(Constants.Routes.SINGLE_TRANSACTION)) .rel(RelTypes.UP, routes.get(Constants.Routes.TRANSACTION_COLLECTION)); } }
/** * * @param server */ public static void define(RestExpress server) { Map<String, String> routes = server.getRouteUrlsByName(); HyperExpress.relationships() .forCollectionOf(Vehicle.class) .rel(RelTypes.SELF, routes.get(Constants.Routes.VEHICLE_COLLECTION)) .withQuery("limit={limit}") .withQuery("offset={offset}") .rel(RelTypes.NEXT, routes.get(Constants.Routes.VEHICLE_COLLECTION) + "?offset={nextOffset}") .withQuery("limit={limit}") .optional() .rel(RelTypes.PREV, routes.get(Constants.Routes.VEHICLE_COLLECTION) + "?offset={prevOffset}") .withQuery("limit={limit}") .optional() .forClass(Vehicle.class) .rel(RelTypes.SELF, routes.get(Constants.Routes.SINGLE_VEHICLE)) .rel(RelTypes.UP, routes.get(Constants.Routes.VEHICLE_COLLECTION)); } }
/** * * @param server */ public static void define(RestExpress server) { Map<String, String> routes = server.getRouteUrlsByName(); HyperExpress.relationships() .forClass(Client.class) .forCollectionOf(Client.class) .rel(RelTypes.SELF, routes.get(Constants.Routes.CLIENT_COLLECTION)) .withQuery("limit={limit}") .withQuery("offset={offset}") .rel(RelTypes.NEXT, routes.get(Constants.Routes.CLIENT_COLLECTION) + "?offset={nextOffset}") .withQuery("limit={limit}") .optional() .rel(RelTypes.PREV, routes.get(Constants.Routes.CLIENT_COLLECTION) + "?offset={prevOffset}") .withQuery("limit={limit}") .optional() .forClass(Client.class) .rel(RelTypes.SELF, routes.get(Constants.Routes.SINGLE_CLIENT)) .rel(RelTypes.UP, routes.get(Constants.Routes.CLIENT_COLLECTION)); } }
.rel(RelTypes.SELF, routes.get(Constants.Routes.BLOGS_READ_ROUTE)) .rel(RelTypes.SELF, routes.get(Constants.Routes.BLOG_READ_ROUTE)) .rel("entries", routes.get(Constants.Routes.BLOG_ENTRIES_READ_ROUTE)) .rel(RelTypes.SELF, routes.get(Constants.Routes.BLOG_ENTRIES_READ_ROUTE)) .withQuery("filter={filter}") .withQuery("limit={limit}") .withQuery("offset={offset}") .rel(RelTypes.NEXT, routes.get(Constants.Routes.BLOG_ENTRIES_READ_ROUTE) + "?offset={nextOffset}") .withQuery("filter={filter}") .withQuery("limit={limit}") .optional() .rel(RelTypes.PREV, routes.get(Constants.Routes.BLOG_ENTRIES_READ_ROUTE) + "?offset={prevOffset}") .withQuery("filter={filter}") .withQuery("limit={limit}") .optional() .rel(RelTypes.UP, routes.get(Constants.Routes.BLOG_READ_ROUTE)) .rel(RelTypes.SELF, routes.get(Constants.Routes.BLOG_ENTRY_READ_ROUTE)) .rel(RelTypes.UP, routes.get(Constants.Routes.BLOG_ENTRIES_READ_ROUTE)) .rel("comments", routes.get(Constants.Routes.COMMENTS_READ_ROUTE)) .rel(RelTypes.SELF, routes.get(Constants.Routes.COMMENTS_READ_ROUTE)) .withQuery("filter={filter}") .withQuery("limit={limit}") .withQuery("offset={offset}") .rel(RelTypes.NEXT, routes.get(Constants.Routes.COMMENTS_READ_ROUTE) + "?offset={nextOffset}") .withQuery("filter={filter}")