Minor code improvements
This commit is contained in:
parent
9e411253c4
commit
0cff29fa2a
34 changed files with 76 additions and 76 deletions
|
@ -182,7 +182,7 @@ public class BaseEditController extends VitroHttpServlet {
|
|||
}
|
||||
|
||||
|
||||
Collections.sort(bodyVal, new ListComparator(vreq.getCollator()));
|
||||
bodyVal.sort(new ListComparator(vreq.getCollator()));
|
||||
for (String aBodyVal : bodyVal) {
|
||||
options.add(hashMap.get(aBodyVal));
|
||||
}
|
||||
|
|
|
@ -267,7 +267,7 @@ public class FormUtils {
|
|||
}
|
||||
}
|
||||
|
||||
Collections.sort(options, (o1, o2) -> o1.getBody().compareTo(o2.getBody()));
|
||||
options.sort((o1, o2) -> o1.getBody().compareTo(o2.getBody()));
|
||||
|
||||
return options;
|
||||
}
|
||||
|
|
|
@ -308,7 +308,7 @@ public class IndividualImpl extends BaseResourceBean implements Individual, Comp
|
|||
|
||||
protected void sortPropertiesForDisplay( ){
|
||||
//here we sort the Property objects
|
||||
Collections.sort(getObjectPropertyList(), new ObjectProperty.DisplayComparator());
|
||||
getObjectPropertyList().sort(new ObjectProperty.DisplayComparator());
|
||||
}
|
||||
|
||||
public JsonNode toJSON() {
|
||||
|
|
|
@ -463,7 +463,7 @@ public class ObjectProperty extends Property implements Comparable<ObjectPropert
|
|||
}
|
||||
};
|
||||
try {
|
||||
Collections.sort(objPropStmtsList, fieldComp);
|
||||
objPropStmtsList.sort(fieldComp);
|
||||
} catch (Exception e) {
|
||||
log.error("Exception sorting object property statements for object property "+prop.getURI());
|
||||
}
|
||||
|
@ -562,7 +562,7 @@ public class ObjectProperty extends Property implements Comparable<ObjectPropert
|
|||
}
|
||||
};
|
||||
try {
|
||||
Collections.sort(objPropStmtsList, dpComp);
|
||||
objPropStmtsList.sort(dpComp);
|
||||
} catch (Exception e) {
|
||||
log.error("Exception sorting object property statements " +
|
||||
"for object property " + prop.getURI(), e);
|
||||
|
|
|
@ -35,7 +35,7 @@ public class VClassList extends VClass {
|
|||
}
|
||||
|
||||
public void sort(){
|
||||
Collections.sort(getEntities(), getCompare() );
|
||||
getEntities().sort(getCompare());
|
||||
}
|
||||
|
||||
public int getSize(){
|
||||
|
|
|
@ -157,7 +157,7 @@ public class DashboardPropertyListController extends VitroHttpServlet {
|
|||
|
||||
if (mergedPropertyList!=null) {
|
||||
try {
|
||||
Collections.sort(mergedPropertyList,new PropertyRanker(vreq));
|
||||
mergedPropertyList.sort(new PropertyRanker(vreq));
|
||||
} catch (Exception ex) {
|
||||
log.error("Exception sorting merged property list: " + ex.getMessage());
|
||||
}
|
||||
|
@ -276,7 +276,7 @@ public class DashboardPropertyListController extends VitroHttpServlet {
|
|||
}
|
||||
if (pg.getPropertyList().size()>1) {
|
||||
try {
|
||||
Collections.sort(pg.getPropertyList(),new Property.DisplayComparatorIgnoringPropertyGroup());
|
||||
pg.getPropertyList().sort(new Property.DisplayComparatorIgnoringPropertyGroup());
|
||||
} catch (Exception ex) {
|
||||
log.error("Exception sorting property group "+pg.getName()+" property list: "+ex.getMessage());
|
||||
}
|
||||
|
|
|
@ -205,7 +205,7 @@ public class VitroHttpServlet extends HttpServlet implements MultipartRequestWra
|
|||
|
||||
protected void sortForPickList(List<? extends ResourceBean> beans,
|
||||
VitroRequest vreq) {
|
||||
Collections.sort(beans, new PickListSorter(vreq));
|
||||
beans.sort(new PickListSorter(vreq));
|
||||
}
|
||||
|
||||
protected class PickListSorter implements Comparator<ResourceBean> {
|
||||
|
|
|
@ -60,12 +60,12 @@ public abstract class UserAccountsPage extends AbstractPageHandler {
|
|||
}
|
||||
}
|
||||
|
||||
Collections.sort(list, new Comparator<PermissionSet>() {
|
||||
@Override
|
||||
public int compare(PermissionSet ps1, PermissionSet ps2) {
|
||||
return ps1.getUri().compareTo(ps2.getUri());
|
||||
}
|
||||
});
|
||||
list.sort(new Comparator<PermissionSet>() {
|
||||
@Override
|
||||
public int compare(PermissionSet ps1, PermissionSet ps2) {
|
||||
return ps1.getUri().compareTo(ps2.getUri());
|
||||
}
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
|
|
|
@ -244,8 +244,7 @@ public class FauxPropertyRetryController extends BaseEditController {
|
|||
private List<Option> createClassGroupOptionList() {
|
||||
List<Option> groupOptList = getGroupOptList(beanForEditing
|
||||
.getGroupURI());
|
||||
Collections.sort(groupOptList,
|
||||
new OptionsBodyComparator(req.getCollator()));
|
||||
groupOptList.sort(new OptionsBodyComparator(req.getCollator()));
|
||||
groupOptList.add(0, new Option("", "none"));
|
||||
return groupOptList;
|
||||
}
|
||||
|
@ -322,12 +321,12 @@ public class FauxPropertyRetryController extends BaseEditController {
|
|||
list.add(option);
|
||||
}
|
||||
}
|
||||
Collections.sort(list, new Comparator<Option>() {
|
||||
@Override
|
||||
public int compare(Option o1, Option o2) {
|
||||
return o1.getBody().compareTo(o2.getBody());
|
||||
}
|
||||
});
|
||||
list.sort(new Comparator<Option>() {
|
||||
@Override
|
||||
public int compare(Option o1, Option o2) {
|
||||
return o1.getBody().compareTo(o2.getBody());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static class OptionsBodyComparator implements
|
||||
|
|
|
@ -74,7 +74,7 @@ public class PropertyGroupsListingController extends BaseEditController {
|
|||
results.add("XX");
|
||||
List<Property> propertyList = pg.getPropertyList();
|
||||
if (propertyList != null && propertyList.size() > 0) {
|
||||
Collections.sort(propertyList, comparator);
|
||||
propertyList.sort(comparator);
|
||||
results.add("+");
|
||||
results.add("XX");
|
||||
results.add("property");
|
||||
|
|
|
@ -102,7 +102,7 @@ public class ShowObjectPropertyHierarchyController extends FreemarkerHttpServlet
|
|||
} else {
|
||||
roots = opDao.getRootObjectProperties();
|
||||
if (roots!=null){
|
||||
Collections.sort(roots, new ObjectPropertyAlphaComparator(vreq)); // sorts by domain public
|
||||
roots.sort(new ObjectPropertyAlphaComparator(vreq)); // sorts by domain public
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ public class ViewLabelsServlet extends FreemarkerHttpServlet{
|
|||
LabelInformationComparator lic = new LabelInformationComparator();
|
||||
for(String languageName: labelsHash.keySet()) {
|
||||
List<LabelInformation> labelInfo = labelsHash.get(languageName);
|
||||
Collections.sort(labelInfo, lic);
|
||||
labelInfo.sort(lic);
|
||||
}
|
||||
return labelsHash;
|
||||
|
||||
|
|
|
@ -202,9 +202,9 @@ public class VClassDaoFiltering extends BaseFiltering implements VClassDao{
|
|||
vcg.setLocalName("0");
|
||||
vcg.setPublicName("Browse Categories");
|
||||
vcg.addAll( this.getAllVclasses() );
|
||||
java.util.Collections.sort(vcg.getVitroClassList(),new Comparator(){
|
||||
public int compare(Object o1, Object o2){
|
||||
return ((VClass)o1).getName().compareTo(((VClass)o2).getName());
|
||||
vcg.getVitroClassList().sort(new Comparator() {
|
||||
public int compare(Object o1, Object o2) {
|
||||
return ((VClass) o1).getName().compareTo(((VClass) o2).getName());
|
||||
}
|
||||
});
|
||||
groups.add(vcg);
|
||||
|
|
|
@ -63,7 +63,7 @@ public class VitroFilterUtils {
|
|||
|
||||
@Override
|
||||
public List<Individual> fn(List<Individual> individuals) {
|
||||
Collections.sort(individuals,comparator);
|
||||
individuals.sort(comparator);
|
||||
return individuals;
|
||||
}
|
||||
|
||||
|
|
|
@ -164,7 +164,7 @@ public class DataPropertyDaoJena extends PropertyDaoJena implements
|
|||
}
|
||||
|
||||
List<DataProperty> dataprops = new ArrayList<DataProperty>(hash.values());
|
||||
Collections.sort(dataprops, new DataPropertyRanker());
|
||||
dataprops.sort(new DataPropertyRanker());
|
||||
return dataprops;
|
||||
}
|
||||
|
||||
|
|
|
@ -602,7 +602,7 @@ public class IndividualJena extends IndividualImpl implements Individual {
|
|||
}
|
||||
};
|
||||
try {
|
||||
Collections.sort(getObjectPropertyStatements(), comp);
|
||||
getObjectPropertyStatements().sort(comp);
|
||||
} catch (Exception e) {
|
||||
log.error("Exception sorting object property statements for object property "+this.getURI());
|
||||
}
|
||||
|
|
|
@ -1038,7 +1038,7 @@ public class IndividualSDB extends IndividualImpl implements Individual {
|
|||
}
|
||||
};
|
||||
try {
|
||||
Collections.sort(getObjectPropertyStatements(), comp);
|
||||
getObjectPropertyStatements().sort(comp);
|
||||
} catch (Exception e) {
|
||||
log.error("Exception sorting object property statements for object property "+this.getURI());
|
||||
}
|
||||
|
|
|
@ -896,18 +896,18 @@ public class JenaBaseDao extends JenaBaseDaoCon {
|
|||
}
|
||||
|
||||
// Sort by lexical value to guarantee consistent results
|
||||
Collections.sort(labels, new Comparator<RDFNode>() {
|
||||
public int compare(RDFNode left, RDFNode right) {
|
||||
if (left == null) {
|
||||
return (right == null) ? 0 : -1;
|
||||
}
|
||||
if ( left.isLiteral() && right.isLiteral()) {
|
||||
return ((Literal) left).getLexicalForm().compareTo(((Literal) right).getLexicalForm());
|
||||
}
|
||||
// Can't sort meaningfully if both are not literals
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
labels.sort(new Comparator<RDFNode>() {
|
||||
public int compare(RDFNode left, RDFNode right) {
|
||||
if (left == null) {
|
||||
return (right == null) ? 0 : -1;
|
||||
}
|
||||
if (left.isLiteral() && right.isLiteral()) {
|
||||
return ((Literal) left).getLexicalForm().compareTo(((Literal) right).getLexicalForm());
|
||||
}
|
||||
// Can't sort meaningfully if both are not literals
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
|
||||
for (String lang : PREFERRED_LANGUAGES) {
|
||||
label = getLabel(lang,labels);
|
||||
|
|
|
@ -121,7 +121,7 @@ public class PropertyInstanceDaoJena extends PropertyDaoJena implements
|
|||
propInsts.add(propInst);
|
||||
}
|
||||
}
|
||||
Collections.sort(propInsts, new PropInstSorter());
|
||||
propInsts.sort(new PropInstSorter());
|
||||
return propInsts;
|
||||
}
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ public class SparqlGraphMultilingual extends SparqlGraph implements GraphWithPer
|
|||
return WrappedIterator.create(tripList.iterator());
|
||||
}
|
||||
if (subject.isConcrete() && predicate.isConcrete() && !object.isConcrete()) {
|
||||
Collections.sort(tripList, new TripleSortByLang());
|
||||
tripList.sort(new TripleSortByLang());
|
||||
LinkedList<Triple> tripl = new LinkedList<Triple>();
|
||||
if (!tripList.get(0).getObject().isLiteral()) {
|
||||
tripl.addAll(tripList);
|
||||
|
|
|
@ -450,7 +450,7 @@ public class UserAccountsDaoJena extends JenaBaseDao implements UserAccountsDao
|
|||
getOntModel().leaveCriticalSection();
|
||||
}
|
||||
|
||||
Collections.sort(list, new PermissionSetsByUri());
|
||||
list.sort(new PermissionSetsByUri());
|
||||
|
||||
return list;
|
||||
}
|
||||
|
|
|
@ -251,11 +251,11 @@ public class VClassGroupDaoJena extends JenaBaseDao implements VClassGroupDao {
|
|||
}
|
||||
|
||||
public void sortGroupList(List<VClassGroup> groupList) {
|
||||
Collections.sort(groupList, new Comparator<VClassGroup>() {
|
||||
groupList.sort(new Comparator<VClassGroup>() {
|
||||
public int compare(VClassGroup first, VClassGroup second) {
|
||||
if (first!=null) {
|
||||
if (second!=null) {
|
||||
return (first.getDisplayRank()-second.getDisplayRank());
|
||||
if (first != null) {
|
||||
if (second != null) {
|
||||
return (first.getDisplayRank() - second.getDisplayRank());
|
||||
} else {
|
||||
log.error("error--2nd VClassGroup is null in VClassGroupDao.getGroupList().compare()");
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ public class SelectListGeneratorVTwo {
|
|||
comparator = new MapPairsComparator(vreq);
|
||||
}
|
||||
|
||||
Collections.sort(objectsToSort, comparator);
|
||||
objectsToSort.sort(comparator);
|
||||
|
||||
HashMap<String,String> map = new LinkedHashMap<String,String>(objectsToSort.size());
|
||||
for (String[] pair:objectsToSort) {
|
||||
|
|
|
@ -256,13 +256,13 @@ public class ManageLabelsForIndividualGenerator extends BaseEditConfigurationGen
|
|||
}
|
||||
}
|
||||
//Sort list by language label and return
|
||||
Collections.sort(availableLocales, new Comparator<HashMap<String, String>>() {
|
||||
public int compare(HashMap<String, String> h1, HashMap<String, String> h2) {
|
||||
String languageName1 = (String) h1.get("label");
|
||||
String languageName2 = (String) h2.get("label");
|
||||
return languageName1.compareTo(languageName2);
|
||||
}
|
||||
});
|
||||
availableLocales.sort(new Comparator<HashMap<String, String>>() {
|
||||
public int compare(HashMap<String, String> h1, HashMap<String, String> h2) {
|
||||
String languageName1 = (String) h1.get("label");
|
||||
String languageName2 = (String) h2.get("label");
|
||||
return languageName1.compareTo(languageName2);
|
||||
}
|
||||
});
|
||||
|
||||
return availableLocales;
|
||||
}
|
||||
|
@ -330,7 +330,7 @@ public class ManageLabelsForIndividualGenerator extends BaseEditConfigurationGen
|
|||
LabelInformationComparator lic = new LabelInformationComparator();
|
||||
for(String languageName: labelsHash.keySet()) {
|
||||
List<LabelInformation> labelInfo = labelsHash.get(languageName);
|
||||
Collections.sort(labelInfo, lic);
|
||||
labelInfo.sort(lic);
|
||||
}
|
||||
return labelsHash;
|
||||
|
||||
|
|
|
@ -119,7 +119,7 @@ public class LanguageFilteringRDFService implements RDFService {
|
|||
if (candidatesForRemoval.size() == 1) {
|
||||
continue;
|
||||
}
|
||||
Collections.sort(candidatesForRemoval, new StatementSortByLang());
|
||||
candidatesForRemoval.sort(new StatementSortByLang());
|
||||
log.debug("sorted statements: " + showSortedStatements(candidatesForRemoval));
|
||||
Iterator<Statement> candIt = candidatesForRemoval.iterator();
|
||||
String langRegister = null;
|
||||
|
@ -197,7 +197,7 @@ public class LanguageFilteringRDFService implements RDFService {
|
|||
if (candidatesForRemoval.size() == 1) {
|
||||
continue;
|
||||
}
|
||||
Collections.sort(candidatesForRemoval, new RowIndexedLiteralSortByLang());
|
||||
candidatesForRemoval.sort(new RowIndexedLiteralSortByLang());
|
||||
log.debug("sorted RowIndexedLiterals: " + showSortedRILs(candidatesForRemoval));
|
||||
Iterator<RowIndexedLiteral> candIt = candidatesForRemoval.iterator();
|
||||
String langRegister = null;
|
||||
|
@ -290,7 +290,7 @@ public class LanguageFilteringRDFService implements RDFService {
|
|||
if (candidatesForRemoval.size() == 1) {
|
||||
continue;
|
||||
}
|
||||
Collections.sort(candidatesForRemoval, new RowIndexedLiteralSortByLang());
|
||||
candidatesForRemoval.sort(new RowIndexedLiteralSortByLang());
|
||||
log.debug("sorted RowIndexedLiterals: " + showSortedRILs(candidatesForRemoval));
|
||||
Iterator<RowIndexedLiteral> candIt = candidatesForRemoval.iterator();
|
||||
String langRegister = null;
|
||||
|
|
|
@ -416,10 +416,11 @@ public class PagedSearchController extends FreemarkerHttpServlet {
|
|||
}
|
||||
|
||||
|
||||
Collections.sort(classes, new Comparator<VClass>(){
|
||||
public int compare(VClass o1, VClass o2) {
|
||||
classes.sort(new Comparator<VClass>() {
|
||||
public int compare(VClass o1, VClass o2) {
|
||||
return o1.compareTo(o2);
|
||||
}});
|
||||
}
|
||||
});
|
||||
|
||||
List<VClassSearchLink> vClassLinks = new ArrayList<VClassSearchLink>(classes.size());
|
||||
for (VClass vc : classes) {
|
||||
|
|
|
@ -88,7 +88,7 @@ public class ThemeInfoSetup implements ServletContextListener {
|
|||
}
|
||||
}
|
||||
|
||||
Collections.sort(themeNames, String.CASE_INSENSITIVE_ORDER);
|
||||
themeNames.sort(String.CASE_INSENSITIVE_ORDER);
|
||||
return themeNames;
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ public class GetAllPrefix extends BaseEditController {
|
|||
respo.append("<options>");
|
||||
List<String> prefixList = new ArrayList<String>();
|
||||
prefixList.addAll(prefixMap.keySet());
|
||||
Collections.sort(prefixList, vreq.getCollator());
|
||||
prefixList.sort(vreq.getCollator());
|
||||
for (String prefix : prefixList) {
|
||||
respo.append(makeOption(prefix, prefixMap.get(prefix)));
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ public class OptionsForPropertyTag extends TagSupport {
|
|||
if( stmts == null ) throw new Exception("object properties for subject were null");
|
||||
|
||||
individuals = removeIndividualsAlreadyInRange(individuals,stmts);
|
||||
Collections.sort(individuals,new compareEnts());
|
||||
individuals.sort(new compareEnts());
|
||||
|
||||
JspWriter out = pageContext.getOut();
|
||||
|
||||
|
|
|
@ -622,7 +622,7 @@ public class EditConfigurationTemplateModel extends BaseTemplateModel {
|
|||
x[1] = hmap.get(key);
|
||||
objectsToSort.add(x);
|
||||
}
|
||||
Collections.sort(objectsToSort, new MapComparator());
|
||||
objectsToSort.sort(new MapComparator());
|
||||
|
||||
HashMap<String,String> map = new LinkedHashMap<String,String>(objectsToSort.size());
|
||||
for (String[] pair:objectsToSort) {
|
||||
|
|
|
@ -167,7 +167,7 @@ public class CollatedObjectPropertyTemplateModel extends
|
|||
filteredList.add(outerMap);
|
||||
} else {
|
||||
//Subclass variable should already reflect most specifick types but there may be more than one most specific type
|
||||
Collections.sort(dataForThisObject, new DataComparatorBySubclass());
|
||||
dataForThisObject.sort(new DataComparatorBySubclass());
|
||||
filteredList.add(dataForThisObject.get(0));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -219,7 +219,7 @@ public class GroupedPropertyList extends BaseTemplateModel {
|
|||
|
||||
protected void sort(List<Property> propertyList) {
|
||||
try {
|
||||
Collections.sort(propertyList, new PropertyRanker(vreq));
|
||||
propertyList.sort(new PropertyRanker(vreq));
|
||||
} catch (Exception ex) {
|
||||
log.error("Exception sorting merged property list: "
|
||||
+ ex.getMessage());
|
||||
|
|
|
@ -225,7 +225,7 @@ public class LanguageFilteringRDFServiceTest extends AbstractTestClass {
|
|||
log.debug("before sorting: "
|
||||
+ languagesFromLiterals(listOfRowIndexedLiterals));
|
||||
Comparator<Object> comparator = buildRowIndexedLiteralSortByLang();
|
||||
Collections.sort(listOfRowIndexedLiterals, comparator);
|
||||
listOfRowIndexedLiterals.sort(comparator);
|
||||
}
|
||||
|
||||
private void assertLanguageOrder(String message) {
|
||||
|
|
|
@ -94,8 +94,8 @@ public class StringResultsMappingTest extends AbstractTestClass {
|
|||
// ----------------------------------------------------------------------
|
||||
|
||||
private <T> void assertEquivalentUnorderedLists(List<T> list1, List<T> list2) {
|
||||
Collections.sort(list1, new ArbitraryOrder<>());
|
||||
Collections.sort(list2, new ArbitraryOrder<>());
|
||||
list1.sort(new ArbitraryOrder<>());
|
||||
list2.sort(new ArbitraryOrder<>());
|
||||
assertEquals(list1, list2);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue