/** * Let the plan fail. */ public void fail() { throw new PlanFailureException(); }
/** * Let a plan fail. * @param cause The cause. */ public void fail(Throwable cause) { throw new PlanFailureException(null, cause); }
/** * Let a plan fail. * @param message The message. * @param cause The cause. */ public void fail(String message, Throwable cause) { throw new PlanFailureException(message, cause); }
@PlanBody protected IFuture<Void> body() { System.out.println("Plan A"); res += "A"; return new Future<Void>(new PlanFailureException()); // return IFuture.DONE; } }
@PlanBody public void body() { if(slogans.size()==0) throw new PlanFailureException(); int idx = r.nextInt(slogans.size()); String slogan = slogans.remove(idx); gui.setSlogan(slogan); // blocks until user feedback is received System.out.println("plan end: "+this); }
@Plan(trigger=@Trigger(goals=SomeGoal.class)) protected IFuture<Void> planB() { System.out.println("Plan B"); res += "B"; return new Future<Void>(new PlanFailureException()); // return IFuture.DONE; }
@Plan(trigger=@Trigger(goals=SomeGoal.class)) protected void planA(SomeGoal goal) { System.out.println("Plan A"); goal.plans.add("A"); throw new PlanFailureException(); }
@Plan(trigger=@Trigger(goals=SomeGoal.class)) protected void planB(SomeGoal goal) { System.out.println("Plan B"); goal.plans.add("B"); throw new PlanFailureException(); }
/** * Testcase 0. */ protected void test0() { tr = new TestReport("#1", "Test throwing PlanFailureException."); getLogger().info("Plan should fail due to PlanFailureException, failed method should be called."); throw new PlanFailureException(); }
/** * Translate a word. Plan that fails. */ @Plan(trigger=@Trigger(goals=Translate.class)) protected String translateA(String eword) { System.out.println("Plan A"); throw new PlanFailureException(); }
/** * Translate a word. */ @Plan(trigger=@Trigger(goals=Translate.class)) protected String translate(String eword) { String ret = wordtable.get(eword); if(ret==null) throw new PlanFailureException(); return ret; } }
/** * First plan. Fails with exception. */ @Plan(trigger=@Trigger(goals=HelloGoal.class)) protected IFuture<Void> printHello1(HelloGoal goal) { System.out.println("1: "+goal.getText()); return new Future<Void>(new PlanFailureException()); }
/** * Second plan. Fails 'asynchronously' (i.e. exception in future). */ @Plan(trigger=@Trigger(goals=HelloGoal.class)) protected IFuture<Void> printHello2(HelloGoal goal) { System.out.println("2: "+goal.getText()); return new Future<Void>(new PlanFailureException()); }
/** * Take X plan for the take X goal. */ @Plan(trigger=@Trigger(goals=TakeXGoal.class)) protected void takeX(TakeXGoal goal) { System.out.println("Walking to station."); System.out.println("Checking time table."); if(Math.random()>0.5) { System.out.println("Wait time is too long, failed."); throw new PlanFailureException(); } else { System.out.println("Taking "+goal.getType()); } } }
/** * First plan. Fails with exception. */ @Plan(trigger=@Trigger(goals=HelloGoal.class)) protected IFuture<Void> printHello1(HelloGoal goal) { System.out.println("1: "+goal.getText()); throw new PlanFailureException(); }
if(t instanceof NoClassDefFoundError) throw new PlanFailureException("Could not create plan "+getRPlan(), t);
throw new PlanFailureException(e.getMessage());
/** * The plan body. */ @PlanBody public IFuture<Void> body() { IEnvironment environment = capa.getEnvironment(); Waste waste = goal.getWaste(); boolean success = environment.pickUpWaste(waste); if(!success) return new Future<Void>(new PlanFailureException()); else return IFuture.DONE; }
/** * The plan body. */ @PlanBody public IFuture<Void> body() { IEnvironment environment = capa.getEnvironment(); if(goal.getWaste()==null) System.out.println("waste nulls: "+goal); boolean success = environment.dropWasteInWastebin(goal.getWaste(), goal.getWastebin()); if(!success) return new Future<Void>(new PlanFailureException()); else return IFuture.DONE; } }
@PlanBody public String paint(IPlan plan, GetOneEuro goal) { if(painter!=null) throw new PlanFailureException(); painter = this; System.out.println("painting start: "+agent.getComponentIdentifier()+" "+goal);//this.getRPlan()); plan.waitFor(2000).get(); // if(Math.random()>0.7) // { // getBeliefbase().getBelief("painting").setFact(Boolean.FALSE); // throw new RuntimeException("end painting: painted euro not good enough"); // } // System.out.println("end painting: ok, "+this); System.out.println("painting end: "+agent.getComponentIdentifier()); painter = null; return agent.getComponentIdentifier().getName(); }