org.cruxframework.crux.core.client.bean
Interface BeanComparator<A>

Type Parameters:
A - The type of the beans to be compared by the comparator interface.

public interface BeanComparator<A>

An utility interface to allow comparation between two objects.

You can define comparators by extending this interface.

Imagine you have the following java bean class defined as:

 public class Person {
    private String name;
    private int age;
    
    public String getName(){return name;}
    public void setName(String name){this.name = name;}
    public int getAge(){return age;}
    public void setAge(int age){this.age = age;}
 }
 

You can define the following interface to make comparation between two objects of the given class, considering its property values:

 public interface PersonComparator extends BeanComparator {}
 

To use the comparator, just call GWT.create on the given interface, or inject it on your class.

 public class MyController {
    @Inject
    private PersonComparator comparator;
    
    @Expose
    public void myMethod() {
       // read two objects...
       if(comparator.equals(person1, person2)) {
           // ...
       }
    }
 }
 

Author:
Thiago da Rosa de Bustamante

Method Summary
 boolean equals(A a1, A a2)
          Compare two objects, considering the value of each property, that follow the java bean notation.
 

Method Detail

equals

boolean equals(A a1,
               A a2)
Compare two objects, considering the value of each property, that follow the java bean notation.

Parameters:
a1 - object1
a2 - object2
Returns:
true if all properties have the same value on the two objects


Copyright © 2014. All rights reserved.