MATSIM
households
HouseholdIncomeComparator.java
Go to the documentation of this file.
1
/* *********************************************************************** *
2
* project: org.matsim.*
3
* HouseholdIncomeComparator
4
* *
5
* *********************************************************************** *
6
* *
7
* copyright : (C) 2009 by the members listed in the COPYING, *
8
* LICENSE and WARRANTY file. *
9
* email : info at matsim dot org *
10
* *
11
* *********************************************************************** *
12
* *
13
* This program is free software; you can redistribute it and/or modify *
14
* it under the terms of the GNU General Public License as published by *
15
* the Free Software Foundation; either version 2 of the License, or *
16
* (at your option) any later version. *
17
* See also COPYING, LICENSE and WARRANTY file *
18
* *
19
* *********************************************************************** */
20
package
org.matsim.households;
21
22
import
java.io.Serializable;
23
import
java.util.Comparator;
24
25
31
public
class
HouseholdIncomeComparator
implements
Comparator<Household>, Serializable {
32
33
private
static
final
long
serialVersionUID
= 1L;
34
35
@Override
36
public
int
compare
(
Household
o1,
Household
o2) {
37
if
(o1.
getIncome
().
getIncomePeriod
() != o2.
getIncome
().
getIncomePeriod
()){
38
throw
new
IllegalArgumentException(
"Can only compare Households with incomes in "
39
+
" same income period"
);
40
}
41
if
(o1.
getIncome
().
getIncome
() < o2.
getIncome
().
getIncome
()){
42
return
-1;
43
}
44
else
if
(o1.
getIncome
().
getIncome
() > o2.
getIncome
().
getIncome
()){
45
return
1;
46
}
47
return
0;
48
}
49
50
}
org.matsim.households.Household
Definition:
Household.java:33
org.matsim.households.HouseholdIncomeComparator.compare
int compare(Household o1, Household o2)
Definition:
HouseholdIncomeComparator.java:36
org.matsim.households.HouseholdIncomeComparator
Definition:
HouseholdIncomeComparator.java:31
org.matsim.households.Household.getIncome
Income getIncome()
org.matsim.households.HouseholdIncomeComparator.serialVersionUID
static final long serialVersionUID
Definition:
HouseholdIncomeComparator.java:33
org.matsim.households.Income.getIncome
double getIncome()
org.matsim.households.Income.getIncomePeriod
IncomePeriod getIncomePeriod()
Generated by
1.8.13