/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.gateway.common.mapping.MessageContextMappingValues
 *  org.hibernate.HibernateException
 *  org.hibernate.Session
 *  org.hibernate.query.Query
 */
package com.l7tech.server.mapping;

import com.l7tech.gateway.common.mapping.MessageContextMappingValues;
import com.l7tech.server.mapping.MessageContextMappingValueManagerImpl;
import com.l7tech.server.util.ReadOnlyHibernateCallback;
import java.sql.SQLException;
import java.util.List;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.query.Query;

class c
extends ReadOnlyHibernateCallback<Object> {
    final String val$digested;
    final MessageContextMappingValues val$lookupValues;
    final MessageContextMappingValueManagerImpl this$0;
    private static final String a = c.a(120, c.a("Ba]\u000b[\u0016\tB"));

    c(MessageContextMappingValueManagerImpl messageContextMappingValueManagerImpl, String string, MessageContextMappingValues messageContextMappingValues) {
        this.this$0 = messageContextMappingValueManagerImpl;
        this.val$digested = string;
        this.val$lookupValues = messageContextMappingValues;
    }

    @Override
    public Object doInHibernateReadOnly(Session session) throws HibernateException, SQLException {
        block10: {
            Query query = session.createQuery(this.this$0.o);
            query.setParameter(a, (Object)this.val$digested);
            List list = query.list();
            try {
                if (list.size() == 0) {
                    return null;
                }
            }
            catch (HibernateException hibernateException) {
                throw c.a(hibernateException);
            }
            if (list.size() == 1) {
                MessageContextMappingValues messageContextMappingValues = (MessageContextMappingValues)list.iterator().next();
                try {
                    if (messageContextMappingValues.matches(this.val$lookupValues)) {
                        return messageContextMappingValues;
                    }
                    break block10;
                }
                catch (HibernateException hibernateException) {
                    throw c.a(hibernateException);
                }
            }
            for (MessageContextMappingValues messageContextMappingValues : list) {
                try {
                    if (!messageContextMappingValues.matches(this.val$lookupValues)) continue;
                    return messageContextMappingValues;
                }
                catch (HibernateException hibernateException) {
                    throw c.a(hibernateException);
                }
            }
        }
        return null;
    }

    private static HibernateException a(HibernateException hibernateException) {
        return hibernateException;
    }

    private static char[] a(String string) {
        char[] cArray = string.toCharArray();
        if (cArray.length < 2) {
            cArray = cArray;
            cArray[0] = (char)(cArray[0] ^ 0x14);
        }
        return cArray;
    }

    /*
     * Handled impossible loop by duplicating code
     * Enabled aggressive block sorting
     */
    private static String a(int n2, char[] cArray) {
        char[] cArray2;
        block11: {
            int n3;
            int n4;
            int n5;
            block10: {
                n5 = n2;
                cArray2 = cArray;
                n4 = cArray.length;
                n3 = 0;
                if (!true) break block10;
                n4 = n4;
                if (n4 <= n3) break block11;
            }
            do {
                n5 = n5;
                cArray2 = cArray2;
                int n6 = n3;
                cArray2[n6] = (char)(cArray2[n6] ^ (n5 ^ (switch (n3 % 7) {
                    case 0 -> 94;
                    case 1 -> 112;
                    case 2 -> 66;
                    case 3 -> 22;
                    case 4 -> 80;
                    case 5 -> 26;
                    default -> 20;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

