package family; import datastructures.BinTree; /* Hogy ne kelljen a BinTree forráskódjához hozzányúlni a Serializable miatt. */ aspect MakeBinTreeSerializable { declare parents: BinTree implements java.io.Serializable; } public class FamilyTree extends BinTree { public FamilyTree( Person person ){ super(person); } public @Override FamilyTree getLeft(){ return (FamilyTree) super.getLeft(); } public @Override FamilyTree getRight(){ return (FamilyTree) super.getRight(); } public @Override void setLeft( BinTree left ){ if( left != null ){ if(!(left instanceof FamilyTree) ){ throw new IllegalArgumentException("Father is of wrong type: " + left.getClass()); } else if( !left.getData().isMale ){ throw new IllegalArgumentException("Father must be male"); } } super.setLeft(left); } public @Override void setRight( BinTree right ){ if( right != null ){ if( !(right instanceof FamilyTree) ){ throw new IllegalArgumentException("Mother is of wrong type: " + right.getClass()); } else if( right.getData().isMale ){ throw new IllegalArgumentException("Mother must be female"); } } super.setRight(right); } }