com.hfg.util.collection.DirtyList Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of com_hfg Show documentation
Show all versions of com_hfg Show documentation
com.hfg xml, html, svg, and bioinformatics utility library
package com.hfg.util.collection;
import java.util.ArrayList;
import java.util.Collection;
import java.util.function.Predicate;
import java.util.function.UnaryOperator;
//------------------------------------------------------------------------------
/**
List with dirty flag support.
@author J. Alex Taylor, hairyfatguy.com
*/
//------------------------------------------------------------------------------
// com.hfg XML/HTML Coding Library
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com
// [email protected]
//------------------------------------------------------------------------------
public class DirtyList extends ArrayList
{
private boolean mIsDirty;
//###########################################################################
// CONSTRUCTORS
//###########################################################################
//---------------------------------------------------------------------------
public DirtyList()
{
super();
}
//---------------------------------------------------------------------------
public DirtyList(int inInitialCapacity)
{
super(inInitialCapacity);
}
//---------------------------------------------------------------------------
public DirtyList(Collection inCollection)
{
super();
addAll(inCollection);
}
//###########################################################################
// PUBLIC METHODS
//###########################################################################
//--------------------------------------------------------------------------
public void bless()
{
mIsDirty = false;
}
//--------------------------------------------------------------------------
public boolean isDirty()
{
return mIsDirty;
}
//---------------------------------------------------------------------------
@Override
public void clear()
{
if (size() > 0)
{
mIsDirty = true;
}
super.clear();
}
//---------------------------------------------------------------------------
@Override
public boolean remove(Object inObj)
{
mIsDirty = true;
return super.remove(inObj);
}
//---------------------------------------------------------------------------
@Override
public T remove(int inPosition)
{
mIsDirty = true;
return super.remove(inPosition);
}
//---------------------------------------------------------------------------
@Override
public boolean removeAll(Collection > inObjs)
{
mIsDirty = true;
return super.removeAll(inObjs);
}
//---------------------------------------------------------------------------
@Override
public boolean add(T inObj)
{
mIsDirty = true;
return super.add(inObj);
}
//---------------------------------------------------------------------------
@Override
public void add(int inIndex, T inObj)
{
mIsDirty = true;
super.add(inIndex, inObj);
}
//---------------------------------------------------------------------------
@Override
public boolean addAll(Collection extends T> inObjs)
{
mIsDirty = true;
return super.addAll(inObjs);
}
//---------------------------------------------------------------------------
@Override
public boolean addAll(int inIndex, Collection extends T> inObjs)
{
mIsDirty = true;
return super.addAll(inIndex, inObjs);
}
//---------------------------------------------------------------------------
@Override
public boolean retainAll(Collection> inObjs)
{
mIsDirty = true;
return super.retainAll(inObjs);
}
//---------------------------------------------------------------------------
@Override
public boolean removeIf(Predicate super T> inFilter)
{
mIsDirty = true;
return super.removeIf(inFilter);
}
//---------------------------------------------------------------------------
@Override
public void removeRange(int inFrom, int inTo)
{
mIsDirty = true;
super.removeRange(inFrom, inTo);
}
//---------------------------------------------------------------------------
@Override
public void replaceAll(UnaryOperator inOperator)
{
mIsDirty = true;
super.replaceAll(inOperator);
}
}