I am creating a RESTful service to access data.
So, I started writing this service, first created the ReadOnlyResource interface with the following code:
public interface ReadOnlyResource<E, K> { Collection<E> getAll(); E getById(K id); }
Where E is the return type and K is the key element.
So, if I implement using <Integer, Integer> , I will enter the key as t
@GET @Path("/{id}") @Override public Integer getById(@PathParam("id") Integer id) { return null; }
But when my key is more complicated, for example:
public class ComplexKey { private String name; private int value; }
How to do this so that I can use my interface?
Is there a way to enter both parameters and create a key with them?
EDIT: @QueryParam's solution does not help, because I try to get to / some name / some number and get an instance of ComplexKey that contains some name and some number values ββfrom url.
jersey jax-rs dropwizard
TalOhana Apr 3 '17 at 7:21 2017-04-03 07:21
source share