com.moviejukebox.model.Comparator.CertificationComparator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of yamj Show documentation
Show all versions of yamj Show documentation
Static analysis of MovieJukebox project
/*
* Copyright (c) 2004-2012 YAMJ Members
* http://code.google.com/p/moviejukebox/people/list
*
* Web: http://code.google.com/p/moviejukebox/
*
* This software is licensed under a Creative Commons License
* See this page: http://code.google.com/p/moviejukebox/wiki/License
*
* For any reuse or distribution, you must make clear to others the
* license terms of this work.
*/
package com.moviejukebox.model.Comparator;
import java.io.Serializable;
import java.util.Comparator;
import java.util.List;
/**
* @author altman.matthew
*/
public class CertificationComparator implements Comparator, Serializable {
private static final long serialVersionUID = 1L;
private transient List ordering = null;
public CertificationComparator(List ordering) {
this.ordering = ordering;
}
@Override
public int compare(String obj1, String obj2) {
int obj1Pos = ordering.indexOf(obj1);
int obj2Pos = ordering.indexOf(obj2);
if (obj1Pos < 0) {
ordering.add(obj1);
obj1Pos = ordering.indexOf(obj1);
}
if (obj2Pos < 0) {
ordering.add(obj2);
obj2Pos = ordering.indexOf(obj2);
}
return obj1Pos - obj2Pos;
}
}