Code Duplication    Length = 25-26 lines in 2 locations

src/main/java/it/cnr/istc/pst/platinum/ai/framework/domain/component/DomainComponent.java 2 locations

@@ 413-438 (lines=26) @@
410
	 * 
411
	 * @param dec
412
	 */
413
	public synchronized void restore(Decision dec) 
414
	{
415
		// check decision component
416
		if (!dec.getComponent().equals(this)) {
417
			throw new RuntimeException("Trying to restore a not local decision on component:\n- component: " + this.name + "\n- decision: " + dec + "\n");
418
		}
419
		
420
		// if active something goes wrong
421
		if (this.isActive(dec)) {
422
			// unexpected behavior
423
			throw new RuntimeException("Trying to restore an active decision:\n- decision: " + dec + "\n");
424
		}
425
		
426
		// check if pending
427
		if (this.isPending(dec)) {
428
			// warning information
429
			warning("Trying to restore an already pending decision:\n- decision: " + dec + "\n");
430
//			throw new RuntimeException("Trying to restore an already pending decision:\n- decision: " + dec + "\n");
431
		}
432
		
433
		// check if silent decision
434
		if (this.isSilent(dec)) {
435
			// remove from silent set
436
			this.decisions.get(PlanElementStatus.SILENT).remove(dec);
437
			// add to pending set
438
			this.decisions.get(PlanElementStatus.PENDING).add(dec);
439
		}
440
	}
441
	
@@ 783-807 (lines=25) @@
780
	 * 
781
	 * @param dec
782
	 */
783
	public synchronized void free(Decision dec) 
784
	{
785
		// check decision component
786
		if (!dec.getComponent().equals(this)) {
787
			throw new RuntimeException("Trying to free a not local decision from a component:\n- component: " + this.name + "\n- decision: " + dec + "\n");
788
		}
789
		
790
		// check if already SILENT
791
		if (this.isSilent(dec)) {
792
			// warning information
793
			warning("Trying to free an already SILENT decision:\n- decision: " + dec + "\n");
794
		}
795
		
796
		// check if ACTIVE
797
		if (this.isActive(dec)) {
798
			// check as this could be a potential bug in the backtracking procedure when "restoring" plan states 
799
			throw new RuntimeException("Trying to free an ACTIVE decision:\n- decision: " + dec + "\n");
800
		}
801
		
802
		// complete transition PENDING -> SILENT
803
		if (this.isPending(dec)) {
804
			// delete pending decision
805
			this.decisions.get(PlanElementStatus.PENDING).remove(dec);
806
			// add to silent decisions
807
			this.decisions.get(PlanElementStatus.SILENT).add(dec);
808
		}
809
	}
810