@Controller @RequestMapping("/test") public class TestController { @RequestMapping(method = RequestMethod.POST, value = "math") @ResponseBody public Result math(@RequestBody final Request request) { final Result result = new Result(); result.setAddition(request.getLeft() + request.getRight()); result.setSubtraction(request.getLeft() - request.getRight()); result.setMultiplication(request.getLeft() * request.getRight()); return result; } }
public interface Worker() { public Result work(); } public class Secretary() implements Worker { public Result work() { Result myResult = new Result(); return myResult; } } public class Boss() implements Worker { private Secretary secretary; public Result work() { return secretary.work(); } }
public Result retriveData(Long id) { Result myResult = new Result(); //... //do some stuff myResult.setSomeData(slowWebService1.retriveSomeData(id)); myResult.setSomeOtherData(slowWebService2.retriveSomeOtherData(id)); myResult.setData(slowWebService3.retriveData(id)); return myResult; }
MethodDelegation.to(Holder.class); class Holder { static Result result = new Result("intercepted"); static Result intercept() { return result; } }
public static Result getInfo(){ Result result=new Result(); result.setName("name"); result.setAge(10); return result;//now you can have String and int values return from the method }
@Override @javax.jws.WebResult(name = "result") public Result foo(final String child) { Result res = new Result(); res.status = "ok"; res.data = "bar"; return res; }
public Result postYourService(YourData data){ Result r = new Result(); r.setResult("result"); return r; }
import java.util.concurrent.Future; import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.AsyncResult; import org.springframework.stereotype.Service; @Service public class AsyncTask { @Async public Future<Result> performTask(String someArgument) { // put the business logic here and collect the result below Result result = new Result(); // this is some custom bean holding your result return new AsyncResult<Result>(result); } }
Result result = new Result(); result.setResult("success"); result.setValue("my value");
Result result = new Result(); Results.getResultsHashMap().put(Result.getUniqueIdResult(), result);
@Path("calculator") public class Calculator { @GET @Path("squareRoot") @Produces(MediaType.APPLICATION_JSON) public Response squareRoot(@QueryParam("input") double input){ Result result = new Result("Square Root"); result.setInput(input); result.setOutput(Math.sqrt(result.getInput())); return Response.ok( new GenericEntity<Result >(result) ) }
String data = "40 1655.28 ------- 212.61 2.01 ( 40.31%) ( 9)STRE C=C (aminoA - part A) -> 1"; Result result = new Result(data); System.out.println(result);
public Result countCaseWithCharAtAndArray(String sentence) { char[] characters = sentence.toCharArray(); Result result = new Result(); for(char current : characters) { if(Character.isLowerCase(current)) { result.lowerCaseCount++; } else if(Character.isUpperCase(current)){ result.upperCaseCount++; } } return result; }
public class ResultDeserializer implements JsonDeserializer<Result> { @Override public Result deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { JsonArray array = json.getAsJsonArray(); Result result = new Result(); result.title = array.get(0).getAsString(); result.results = new LinkedHashMap<String, Integer>(); for(Entry<String, JsonElement> entry : array.get(1).getAsJsonObject().entrySet()) { result.results.put(entry.getKey(), entry.getValue().getAsInt()); } return result; } }
File f = ... Serializer ser = new Persister(); Result r = new Result(); ser.write(r, f);
protected Result request(String urlStr, String postData) { ProgressDialog dialog = ProgressDialog.show(activity, "", "Loading...",true); Result result = new Result(); String message = ""; try { message = HttpRequest.postURL(urlStr, postData); result = new Result(message); } catch (Exception e) { Log.e(TAG,"Failed to request data from " + urlStr + "\n" + e.getMessage()); } dialog.show(); return result; }
public void start(){ Supplier<Result> numberSupplier = new Supplier<Result>() { @Override public Result get() { Result r = new Result(); try { r.setInteger(SupplyNumbers.sendNumbers()); } catch (Exception e){ r.setException(e); } return r; } }; CompletableFuture<Result> testFuture = CompletableFuture.supplyAsync(numberSupplier).whenComplete(biConsumer); }
List<Result> result= new ArrayList<Result>(); for(ValueList data1: valueListA) { Result inter= new Result(); if (valueListB.contains(data1)) { inter.setKey(data1.getKey()); } else { inter.setKey("-1" /* or -1 */); } inter.setValue(data1.getValue()); result.add(inter); }
List<Result> result= new ArrayList<Result>(); for (ValueList data1: valueListA){ Result inter = new Result(); inter.setKey(data1.getKey()); if (valueListB.contains(data1)) { inter.setValue(data1.getValue()); } else { inter.setValue(-1); } result.add(inter); }
Result process(Parent parent) { Result result = new Result(); for (Child child : parent.getChildren()) { result.update(process(child)); } return result; }