Package com.mysema.query.sql.codegen

Source Code of com.mysema.query.sql.codegen.OrdinalPositionComparator

package com.mysema.query.sql.codegen;

import java.util.Arrays;
import java.util.Comparator;
import java.util.Map;

import com.mysema.query.codegen.Property;
import com.mysema.query.sql.ColumnMetadata;

public class OrdinalPositionComparator implements Comparator<Property> {

    public OrdinalPositionComparator() {
        super();
    }

    @Override
    public int compare(Property property1, Property property2) {
        Integer comparison = null;
        for (Property property : Arrays.asList(property1, property2)) {
            Map<Object, Object> data = property.getData();
            ColumnMetadata columnMetadata = (ColumnMetadata) data.get("COLUMN");
            int index = columnMetadata.getIndex();
            comparison = comparison == null ? index : comparison - index;
        }
        return comparison;
    }

}
TOP

Related Classes of com.mysema.query.sql.codegen.OrdinalPositionComparator

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.