Solventada
Gracias a la solución de @Jordi_Castilla he usado el método LimitedLIFOList
siguiendo las indicaciones suyas he realizado lo siguiente:
public class LimitedLIFOList<E> extends Stack<E> {
private int limite;
public LimitedLIFOList(int limite) {
this.limite = limite;
}
@Override
public E push(E o) {
super.push(o);
if (size() > limite) { super.remove(0); }
return o;
}
}
Test:
LimitedLIFOList<TextDataStatus> fifo2 = new LimitedLIFOList<>(3);
fifo2.push(new TextDataStatus(1,"A",0,0));
fifo2.push(new TextDataStatus(1,"B",0,0));
fifo2.push(new TextDataStatus(2,"C",0,0));
fifo2.push(new TextDataStatus(1,"D",0,0));
fifo2.push(new TextDataStatus(1,"E",0,0));
fifo2.push(new TextDataStatus(3,"F",3,1));
Resultado:
I/System.out: TextDataStatus{action=1, content='D', start=0, end=0}
I/System.out: TextDataStatus{action=1, content='E', start=0, end=0}
I/System.out: TextDataStatus{action=3, content='F', start=3, end=1}