Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.25 KB | None | 0 0
  1. public interface ApiService {
  2.  
  3. @POST("/api/v1/smart/status")
  4. Call<SessionStatusResponse> postWorkChangeStatus(@Body WorkChangeStatusRequestData sessionStatusData);
  5.  
  6. @POST("/api/v1/smart/sensor")
  7. Call<SensorDataResponse> postWorkSensorData(@Body SensorRequestData sensorData);
  8.  
  9. @GET("/api/v1/smart/sensor")
  10. @FormUrlEncoded
  11. Call<AuthConfirmPhoneResponse> getWorkSensorData(@Field("number") String id);
  12. }
  13.  
  14. void parse() {
  15. methods = clazz.getMethods();
  16. for (int i = 0; i < methods.length; i++) {
  17. if (methods[i].isAnnotationPresent(POST.class))
  18. annotationValues.put(methods[i].getAnnotation(POST.class).value(), new ArrayList<String>());
  19. else if (methods[i].isAnnotationPresent(GET.class))
  20. annotationValues.put(methods[i].getAnnotation(GET.class).value(), new ArrayList<String>());
  21. else if (methods[i].isAnnotationPresent(DELETE.class))
  22. annotationValues.put(methods[i].getAnnotation(DELETE.class).value(), new ArrayList<String>());
  23. else if (methods[i].isAnnotationPresent(PUT.class))
  24. annotationValues.put(methods[i].getAnnotation(PUT.class).value(), new ArrayList<String>());
  25. else if (methods[i].isAnnotationPresent(HEAD.class))
  26. annotationValues.put(methods[i].getAnnotation(HEAD.class).value(), new ArrayList<String>());
  27. else if (methods[i].isAnnotationPresent(OPTIONS.class))
  28. annotationValues.put(methods[i].getAnnotation(OPTIONS.class).value(), new ArrayList<String>());
  29. }
  30. for (int i = 0; i < methods.length; i++) {
  31. if (methods[i].isAnnotationPresent(POST.class)) {
  32. // parse(methods[i], POST.class);
  33. String path = methods[i].getAnnotation(POST.class).value();
  34. annotationValues.get(path).add(POST.class.getSimpleName());
  35. } else if (methods[i].isAnnotationPresent(GET.class)) {
  36. String path = methods[i].getAnnotation(GET.class).value();
  37. annotationValues.get(path).add(GET.class.getSimpleName());
  38. } else if (methods[i].isAnnotationPresent(DELETE.class)) {
  39. String path = methods[i].getAnnotation(DELETE.class).value();
  40. annotationValues.get(path).add(DELETE.class.getSimpleName());
  41. } else if (methods[i].isAnnotationPresent(PUT.class)) {
  42. String path = methods[i].getAnnotation(PUT.class).value();
  43. annotationValues.get(path).add(PUT.class.getSimpleName());
  44. } else if (methods[i].isAnnotationPresent(HEAD.class)) {
  45. String path = methods[i].getAnnotation(HEAD.class).value();
  46. annotationValues.get(path).add(HEAD.class.getSimpleName());
  47. } else if (methods[i].isAnnotationPresent(OPTIONS.class)) {
  48. String path = methods[i].getAnnotation(OPTIONS.class).value();
  49. annotationValues.get(path).add(OPTIONS.class.getSimpleName());
  50. }
  51. }
  52. }
  53.  
  54. private <T extends Annotation> void parse(Method method, Class<T> postClass) {
  55. String test = ((T)method.getAnnotation(postClass)).value(); //ошибка!
  56. Log.d(logTag, "========TESTVALUE: " + test);
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement