/** * Put complex types that are polymorphic and have recursive references. * * @param complexBody Please put a salmon that looks like this: { "fishtype": "salmon", "species": * "king", "length": 1, "age": 1, "location": "alaska", "iswild": true, "siblings": [ { * "fishtype": "shark", "species": "predator", "length": 20, "age": 6, "siblings": [ { * "fishtype": "salmon", "species": "coho", "length": 2, "age": 2, "location": "atlantic", * "iswild": true, "siblings": [ { "fishtype": "shark", "species": "predator", "length": 20, * "age": 6 }, { "fishtype": "sawshark", "species": "dangerous", "length": 10, "age": 105 } ] * }, { "fishtype": "sawshark", "species": "dangerous", "length": 10, "age": 105 } ] }, { * "fishtype": "sawshark", "species": "dangerous", "length": 10, "age": 105 } ] } * @throws ErrorException exception thrown from REST call * @throws IOException exception thrown from serialization/deserialization * @throws IllegalArgumentException exception thrown from invalid parameters * @return the {@link ServiceResponse} object if successful. */ public ServiceResponse<Void> putValid(Fish complexBody) throws ErrorException, IOException, IllegalArgumentException { if (complexBody == null) { throw new IllegalArgumentException("Parameter complexBody is required and cannot be null."); } Validator.validate(complexBody); Call<ResponseBody> call = service.putValid(complexBody); return putValidDelegate(call.execute(), null); }
/** * Put complex types that are polymorphic and have recursive references. * * @param complexBody Please put a salmon that looks like this: { "fishtype": "salmon", "species": * "king", "length": 1, "age": 1, "location": "alaska", "iswild": true, "siblings": [ { * "fishtype": "shark", "species": "predator", "length": 20, "age": 6, "siblings": [ { * "fishtype": "salmon", "species": "coho", "length": 2, "age": 2, "location": "atlantic", * "iswild": true, "siblings": [ { "fishtype": "shark", "species": "predator", "length": 20, * "age": 6 }, { "fishtype": "sawshark", "species": "dangerous", "length": 10, "age": 105 } ] * }, { "fishtype": "sawshark", "species": "dangerous", "length": 10, "age": 105 } ] }, { * "fishtype": "sawshark", "species": "dangerous", "length": 10, "age": 105 } ] } * @param serviceCallback the async ServiceCallback to handle successful and failed responses. * @return the {@link Call} object */ public Call<ResponseBody> putValidAsync( Fish complexBody, final ServiceCallback<Void> serviceCallback) { if (complexBody == null) { serviceCallback.failure( new IllegalArgumentException("Parameter complexBody is required and cannot be null.")); return null; } Validator.validate(complexBody, serviceCallback); Call<ResponseBody> call = service.putValid(complexBody); call.enqueue( new ServiceResponseCallback<Void>(serviceCallback) { @Override public void onResponse(Response<ResponseBody> response, Retrofit retrofit) { try { serviceCallback.success(putValidDelegate(response, retrofit)); } catch (ErrorException | IOException exception) { serviceCallback.failure(exception); } } }); return call; }