Generic Remove From LIST

From AIBenchWiki

Jump to: navigation, search

Until now it was only possible to remove items from the Clipboard if these were Root Items, meaning that any ClipboardItem located inside other Datatype (ex:a COMPLEX Datatype) wasn't removable.

Some changes were now introduced allowing any item located inside a LIST structured Datatype to be removed.

To do it a user must:

  • 1 - Change the annotation inside it's LIST Datatype in the following way:
@Datatype(structure=Structure.LIST)
public class CubesList{


private ArrayList<Cube> cubes;
public CubesList(){ this.cubes = new ArrayList<Cube>(); }
@ListElements(modifiable=true) public ArrayList<Cube> getCubes(){ return this.cubes; } ... }

  • 2 - When a user sets modifiable to true he must guarantee that the data structure returned by the method is an instance of List and that it is the original data structure that holds the data. This means that, for instance:
@Datatype(structure=Structure.LIST)
public class CubesList{


private Cube[] cubes; //the original data is being held in an Array
public CubesList(){ this.cubes = new Cube[10]; }
@ListElements(modifiable=true) public ArrayList<Cube> getCubes(){ ArrayList<Cube> toret = new ArrayList<Cube>(); for(Cube cube:this.cubes) //generation of a dynamic list toret.add(cube);
return toret; //returning the newly generated list will not allow modifications in the real data structure that holds the data } ... }
  • 2.1 - The above example shows what can go wrong using this alternative. That is why, the modifiable modifier is originally set to false.



To see how to remove other Datatypes that aren't Root Datatypes, please refer to this link.

Personal tools
Documentation