Specific Remove Operations For Non Root Datatypes

From AIBenchWiki

Jump to: navigation, search

It is now possible to specify a new modified inside a @Datatype annotation that allows a user to define a remove method for that Datatype.

Until now, only Root Datatypes were removable, now it is possible to:

@Datatype(structure=Structure.COMPLEX,removable=false)
public class Cube{
...
}
  • Define a remove method for any other Datatypes:

To use this, the user must:

  • 1 - Specify a remove method inside the @Datatype annotation and implement that method:
@Datatype(structure=Structure.SIMPLE,removeMethod="remove")
public class CubeProperties{
   
   private Cube owner;
...
...
    public void remove(){
       List<ClipboardItem> items = Core.getInstance().getClipboard().getItemsByClass(CubeProperties.class);
       ClipboardItem torem = null;
       for(ClipboardItem item : items){
          if(item.getUserData().equals(this)){
             torem = item;
             break;
          }
       }
       Core.getInstance().getClipboard().removeClipboardItem(torem);
       this.owner.setCubeProperties(null);
       System.gc();
    }
...
}
  • 2 - The user is responsible to guarantee that the method keeps the data coherent. This modification thus giving more power to user, also introduces a new level of possible incoherence. Only experienced users are recommended to use it.
Personal tools
Documentation