CPD Results

The following document contains the results of PMD's CPD 4.2.5.

Duplications

FileLine
org/apache/myfaces/examples/listexample/PagedSortableCarList.java63
org/apache/myfaces/examples/listexample/SimpleSortableCarList.java51
    }

    protected boolean isDefaultAscending(String sortColumn)
    {
        return true;
    }

    protected void sort(final String column, final boolean ascending)
    {
        Comparator comparator = new Comparator()
        {
            public int compare(Object o1, Object o2)
            {
                SimpleCar c1 = (SimpleCar)o1;
                SimpleCar c2 = (SimpleCar)o2;
                if (column == null)
                {
                    return 0;
                }
                if (column.equals("type"))
                {
                    return ascending ? c1.getType().compareTo(c2.getType()) : c2.getType().compareTo(c1.getType());
                }
                else if (column.equals("color"))
                {
                    return ascending ? c1.getColor().compareTo(c2.getColor()) : c2.getColor().compareTo(c1.getColor());
                }
                else return 0;
            }
        };
        Collections.sort(_cars, comparator);
FileLine
org/apache/myfaces/examples/listexample/SimpleCar.java28
org/apache/myfaces/examples/selectOneRow/SimpleCar.java28
public class SimpleCar
        implements Serializable
{
    /**
     * serial id for serialisation versioning
     */
    private static final long serialVersionUID = 1L;
    private int _id;
    private String _type;
    private String _color;

    public SimpleCar(int id, String type, String color)
    {
        _id = id;
        _type = type;
        _color = color;
    }

    public int getId()
    {
        return _id;
    }

    public void setId(int id)
    {
        _id = id;
    }

    public String getType()
    {
        return _type;
    }

    public void setType(String type)
    {
        _type = type;
    }

    public String getColor()
    {
        return _color;
    }

    public void setColor(String color)
    {
        _color = color;
    }
}