private static String getName(Method m, int i) { for (HasQuery h : getAnnotations(HasQuery.class, m, i)) { if (! h.name().isEmpty()) return h.name(); if (! h.value().isEmpty()) return h.value(); } throw new InternalServerError("@HasQuery used without name or value on method ''{0}'' parameter ''{1}''.", m, i); }
private static String getName(Method m, int i) { for (HasQuery h : getAnnotations(HasQuery.class, m, i)) { if (! h.name().isEmpty()) return h.name(); if (! h.value().isEmpty()) return h.value(); } throw new InternalServerError("@HasQuery used without name or value on method ''{0}'' parameter ''{1}''.", m, i); }
@RestMethod(name=POST, path="/*") public Reader formPostAsContent( @Body F01 bean, @HasQuery("p1") boolean hqp1, @HasQuery("p2") boolean hqp2, @Query("p1") String qp1, @Query("p2") int qp2) throws Exception { return new StringReader("bean=["+SimpleJsonSerializer.DEFAULT.toString(bean)+"],qp1=["+qp1+"],qp2=["+qp2+"],hqp1=["+hqp1+"],hqp2=["+hqp2+"]"); } public static class F01 {
private static String getName(Method m, int i) { for (HasQuery h : getAnnotations(HasQuery.class, m, i)) { if (! h.name().isEmpty()) return h.name(); if (! h.value().isEmpty()) return h.value(); } throw new InternalServerError("@HasQuery used without name or value on method ''{0}'' parameter ''{1}''.", m, i); }
@RestMethod(properties={@Property(name="p4",value="v4a"), @Property(name="p5", value="v5")}) public ObjectMap e02(RequestProperties properties, @HasQuery("override") boolean override) { // Should show {p1:'v1',p2:'v2a',p3:'v3',p4:'v4a',p5:'v5'} when override is false. // Should show {p1:'x',p2:'x',p3:'x',p4:'x',p5:'x'} when override is true. if (override) { properties.put("p1", "x"); properties.put("p2", "x"); properties.put("p3", "x"); properties.put("p4", "x"); properties.put("p5", "x"); } return transform(properties); }