cz.cuni.pogamut.shed.presenter
Class AbstractLapElementListener<PARENT extends PoshElement>

Package class diagram package AbstractLapElementListener
java.lang.Object
  extended by cz.cuni.pogamut.shed.presenter.AbstractLapElementListener<PARENT>
All Implemented Interfaces:
PoshElementListener<PARENT>, PropertyChangeListener, EventListener

public abstract class AbstractLapElementListener<PARENT extends PoshElement>
extends Object
implements PoshElementListener<PARENT>

Base class that provides helper method for manipulation of events I got from lap elements. TODO: Delete all stuff from AbstractPresenter that is duplicated here.

Author:
Honza Havlicek

Constructor Summary
AbstractLapElementListener()
           
 
Method Summary
protected  ActionPattern extractActionPattern(List<ActionPattern> actionPatterns, PoshElement actionPattern)
          Assert that @actionPattern is in the @actionPatterns and return it.
protected  Competence extractCompetence(List<Competence> competences, PoshElement competence)
          Assert that @competence is in the @competences and return it.
protected  DriveElement extractDrive(List<DriveElement> drives, PoshElement drive)
           
protected  CompetenceElement extractChoice(List<CompetenceElement> choices, PoshElement choice)
          Assert that @choice is in the @choices and return it.
protected  Sense extractSense(Trigger<?> trigger, PoshElement sense)
          Assert that sense is a part of the trigger and return it.
protected
<T extends PoshElement>
int
getPosition(List<T> list, T element)
          Get position of the element in the list.
protected  boolean isActionPattern(PoshElement element)
          Is the element ActionPattern?
protected  boolean isCompetence(PoshElement element)
          Is the element Competence?
protected  boolean isDrive(PoshElement element)
           
protected  boolean isChoice(PoshElement element)
          Is the element CompetenceElement?
protected  boolean isSense(PoshElement element)
          Is passed element a Sense?
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface cz.cuni.amis.pogamut.sposh.elements.PoshElementListener
childElementAdded, childElementMoved, childElementRemoved
 
Methods inherited from interface java.beans.PropertyChangeListener
propertyChange
 

Constructor Detail

AbstractLapElementListener

public AbstractLapElementListener()
Method Detail

isSense

protected final boolean isSense(PoshElement element)
Is passed element a Sense?

Parameters:
element - element to check.
Returns:
true if element is sense, false if not.

extractSense

protected final Sense extractSense(Trigger<?> trigger,
                                   PoshElement sense)
Assert that sense is a part of the trigger and return it.

Parameters:
trigger - Trigger against which the method is testing.
sense - tested sense
Returns:
properly typed sense

isDrive

protected final boolean isDrive(PoshElement element)

extractDrive

protected final DriveElement extractDrive(List<DriveElement> drives,
                                          PoshElement drive)

isChoice

protected final boolean isChoice(PoshElement element)
Is the element CompetenceElement?

Parameters:
element - Tested element
Returns:
true if the @element is CompetenceElement or its subclass, false otherwise.

extractChoice

protected final CompetenceElement extractChoice(List<CompetenceElement> choices,
                                                PoshElement choice)
Assert that @choice is in the @choices and return it.

Parameters:
choices - List of choices that must contain the @choice.
choice - Choice must be contained in the @choices
Returns:
Properly casted @choice.

isActionPattern

protected final boolean isActionPattern(PoshElement element)
Is the element ActionPattern?

Parameters:
element - Tested element
Returns:
true if the @element is ActionPattern or its subclass, false otherwise.

extractActionPattern

protected final ActionPattern extractActionPattern(List<ActionPattern> actionPatterns,
                                                   PoshElement actionPattern)
Assert that @actionPattern is in the @actionPatterns and return it. Basically a checked type conversion from PoshElement to ActionPattern.

Parameters:
actionPatterns - List of ActionPatterns that must contain the @actionPattern.
actionPattern - The ActionPattern that must be contained in the @actionPatterns
Returns:
Properly casted @actionPattern.

isCompetence

protected final boolean isCompetence(PoshElement element)
Is the element Competence?

Parameters:
element - Tested element
Returns:
true if the @element is Competence or its subclass, false otherwise.

extractCompetence

protected final Competence extractCompetence(List<Competence> competences,
                                             PoshElement competence)
Assert that @competence is in the @competences and return it. Basically a checked type conversion from PoshElement to Competence.

Parameters:
competences - List of Competences that must contain the
competence - The Competence that must be contained in the
Returns:
Properly casted @competence.

getPosition

protected final <T extends PoshElement> int getPosition(List<T> list,
                                                        T element)
Get position of the element in the list.

Type Parameters:
T - Type of element
Parameters:
list - list in which we determine position of the elemnt.
element - The element for whic we want position in the list. Must be there, otherwise assert error.
Returns:
Found position.


Copyright © 2013 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.