geary/test/engine/api/geary-email-identifier-mock.vala
Michael Gratton cb16bdc59d Remove default Geary.EmailIdentifier::hash and ::equal_to impls
Make subclasses implement these themselves and remove the unique string
property, to be (hopefully) more efficient and easier for subclasses
to specialise.
2019-12-12 10:47:52 +11:00

46 lines
1.1 KiB
Vala

/*
* Copyright 2017 Michael Gratton <mike@vee.net>
*
* This software is licensed under the GNU Lesser General Public License
* (version 2.1 or later). See the COPYING file in this distribution.
*/
public class Geary.MockEmailIdentifer : EmailIdentifier {
private int id;
public MockEmailIdentifer(int id) {
this.id = id;
}
public override uint hash() {
return GLib.int_hash(this.id);
}
public override bool equal_to(Geary.EmailIdentifier other) {
return (
this.get_type() == other.get_type() &&
this.id == ((MockEmailIdentifer) other).id
);
}
public override string to_string() {
return "%s(%d)".printf(
this.get_type().name(),
this.id
);
}
public override GLib.Variant to_variant() {
return new GLib.Variant.int32(id);
}
public override int natural_sort_comparator(Geary.EmailIdentifier other) {
MockEmailIdentifer? other_mock = other as MockEmailIdentifer;
return (other_mock == null) ? 1 : this.id - other_mock.id;
}
}