Search in sources :

Example 16 with Person

use of org.eclipse.collections.impl.test.domain.Person in project eclipse-collections by eclipse.

the class ComparatorsTest method fromFunctions.

@Test
public void fromFunctions() {
    Person raab = new Person(null, "Raab", 0);
    Person white = new Person(null, "White", 0);
    Comparator<Person> personComparator = Comparators.fromFunctions(Person.TO_LAST);
    Verify.assertNegative(personComparator.compare(raab, white));
    Verify.assertPositive(personComparator.compare(white, raab));
    Verify.assertZero(personComparator.compare(raab, raab));
}
Also used : Person(org.eclipse.collections.impl.test.domain.Person) Test(org.junit.Test)

Example 17 with Person

use of org.eclipse.collections.impl.test.domain.Person in project eclipse-collections by eclipse.

the class HashingStrategiesTest method fromFunctionsThreeArgs.

@Test
public void fromFunctionsThreeArgs() {
    Person john1 = new Person("John", "Smith");
    Person john2 = new Person("John", "Smith");
    Person john3 = new Person("John", "Doe");
    Person john4 = new Person("John", "Smith", 10);
    HashingStrategy<Person> chainedHashingStrategy = HashingStrategies.fromFunctions(Person.TO_FIRST, Person.TO_LAST, Person.TO_AGE);
    Assert.assertEquals(john1.hashCode(), chainedHashingStrategy.computeHashCode(john1));
    Assert.assertTrue(chainedHashingStrategy.equals(john1, john2));
    Assert.assertFalse(chainedHashingStrategy.equals(john1, john3));
    Assert.assertFalse(chainedHashingStrategy.equals(john1, john4));
}
Also used : Person(org.eclipse.collections.impl.test.domain.Person) Test(org.junit.Test)

Aggregations

Person (org.eclipse.collections.impl.test.domain.Person)17 Test (org.junit.Test)17 Pair (org.eclipse.collections.api.tuple.Pair)3 ObjectIntPair (org.eclipse.collections.api.tuple.primitive.ObjectIntPair)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1