Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package jpaoletti.jpm.core;
 
This class is used to sort fields within the order attribute of Entity

Author(s):
yero
See also:
Entity.order
 
public class FieldComparator implements Comparator<Field> {
    
A space separated string with the fields id
    private String order;
    
    
Constructor with the specified order

Parameters:
order The order
    public FieldComparator(String order){
        this. = order;
    }

    
Compare method.

Parameters:
o1 First field to compare
o2 Second field to compare
Returns:
The lesser looking at order property
    @Override
    public int compare(Field o1Field o2) {
        int i = .indexOf(o1.getId());
        int j = .indexOf(o2.getId());
        if(i==jreturn 0;
        if(i==-1 && j >= 0) return 1;
        if(j==-1 && i >= 0) return -1;
        return i - j;
    }

    
Setter for order

Parameters:
order the order to set
    public void setOrder(String order) {
        this. = order;
    }

    
Getter for order

Returns:
the order
    public String getOrder() {
        return ;
    }
New to GrepCode? Check out our FAQ X