public <DatabaseObjectType extends DatabaseObject> DatabaseObjectType get(DatabaseObjectType example, CompareControl.SchemaComparison[] schemaComparisons) {
        Map<String, Set<DatabaseObject>> databaseObjectsByHash = cache.get(example.getClass());

        if (databaseObjectsByHash == null) {
            return null;
        }

        String[] hashes = DatabaseObjectComparatorFactory.getInstance().hash(example, null, database);

        SortedSet<Set<DatabaseObject>> objectSets = new TreeSet<>(new Comparator<Set<DatabaseObject>>() {
            @Override
            public int compare(Set<DatabaseObject> o1, Set<DatabaseObject> o2) {
                int sizeComparison = Integer.valueOf(o1.size()).compareTo(o2.size());
                if (sizeComparison == 0) {
                    return o1.toString().compareTo(o2.toString());
                }
                return sizeComparison;
            }
        });

        for (String hash : hashes) {
            Set<DatabaseObject> databaseObjects = databaseObjectsByHash.get(hash);
            if (databaseObjects != null) {
                objectSets.add(databaseObjects);
            }
        }

        for (Set<DatabaseObject> databaseObjects : objectSets) {
            for (DatabaseObject obj : databaseObjects) {
                if (DatabaseObjectComparatorFactory.getInstance().isSameObject(obj, example, schemaComparisons, database)) {
                    //noinspection unchecked
                    return (DatabaseObjectType) obj;
                }
            }
        }

        return null;
    }
public <DatabaseObjectType extends DatabaseObject> DatabaseObjectType get(DatabaseObjectType example, CompareControl.SchemaComparison[] schemaComparisons) {
        Map<String, Set<DatabaseObject>> databaseObjectsByHash = cache.get(example.getClass());

        if (databaseObjectsByHash == null) {
            return null;
        }

        String[] hashes = DatabaseObjectComparatorFactory.getInstance().hash(example, null, database);

        SortedSet<Set<DatabaseObject>> objectSets = new TreeSet<>(new Comparator<Set<DatabaseObject>>() {
            @Override
            public int compare(Set<DatabaseObject> o1, Set<DatabaseObject> o2) {
                int sizeComparison = Integer.valueOf(o1.size()).compareTo(o2.size());
                if (sizeComparison == 0) {
                    return o1.toString().compareTo(o2.toString());
                }
                return sizeComparison;
            }
        });

        for (String hash : hashes) {
            Set<DatabaseObject> databaseObjects = databaseObjectsByHash.get(hash);
            if (databaseObjects != null) {
                objectSets.add(databaseObjects);
            }
        }

        for (Set<DatabaseObject> databaseObjects : objectSets) {
            for (DatabaseObject obj : databaseObjects) {
                if (DatabaseObjectComparatorFactory.getInstance().isSameObject(obj, example, schemaComparisons, database)) {
                    
                    return (DatabaseObjectType) obj;
                }
            }
        }

        return null;
    }
public < DatabaseObjectType extends DatabaseObject > DatabaseObjectType get ( DatabaseObjectType example , CompareControl . SchemaComparison [ ] schemaComparisons ) { Map < String , Set < DatabaseObject > > databaseObjectsByHash = cache . get ( example . getClass ( ) ) ; if ( databaseObjectsByHash == null ) { return null ; } String [ ] hashes = DatabaseObjectComparatorFactory . getInstance ( ) . hash ( example , null , database ) ; SortedSet < Set < DatabaseObject > > objectSets = new TreeSet <> ( new Comparator < Set < DatabaseObject > > ( ) { @ Override public int compare ( Set < DatabaseObject > o1 , Set < DatabaseObject > o2 ) { int sizeComparison = Integer . valueOf ( o1 . size ( ) ) . compareTo ( o2 . size ( ) ) ; if ( sizeComparison == 0 ) { return o1 . toString ( ) . compareTo ( o2 . toString ( ) ) ; } return sizeComparison ; } } ) ; for ( String hash : hashes ) { Set < DatabaseObject > databaseObjects = databaseObjectsByHash . get ( hash ) ; if ( databaseObjects != null ) { objectSets . add ( databaseObjects ) ; } } for ( Set < DatabaseObject > databaseObjects : objectSets ) { for ( DatabaseObject obj : databaseObjects ) { if ( DatabaseObjectComparatorFactory . getInstance ( ) . isSameObject ( obj , example , schemaComparisons , database ) ) { //noinspection unchecked return ( DatabaseObjectType ) obj ; } } } return null ; }
Returns the object described by the passed example if it is already included in this snapshot.
Returns the object described by the passed example if it is already included in this snapshot .