/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.objectmodel.Entity
 *  com.l7tech.objectmodel.EntityType
 *  com.l7tech.objectmodel.EntityTypeRegistry
 *  com.l7tech.objectmodel.ExternalEntityHeader
 *  com.l7tech.objectmodel.ExternalEntityHeader$ValueType
 *  com.l7tech.objectmodel.FindException
 *  com.l7tech.objectmodel.Goid
 *  com.l7tech.objectmodel.PersistentEntity
 *  com.l7tech.objectmodel.migration.MigrationDependency
 *  com.l7tech.objectmodel.migration.MigrationMappingSelection
 *  com.l7tech.objectmodel.migration.MigrationUtils
 *  com.l7tech.objectmodel.migration.PropertyResolver$Type
 *  com.l7tech.objectmodel.migration.PropertyResolverException
 */
package com.l7tech.server.migration;

import com.l7tech.objectmodel.Entity;
import com.l7tech.objectmodel.EntityType;
import com.l7tech.objectmodel.EntityTypeRegistry;
import com.l7tech.objectmodel.ExternalEntityHeader;
import com.l7tech.objectmodel.FindException;
import com.l7tech.objectmodel.Goid;
import com.l7tech.objectmodel.PersistentEntity;
import com.l7tech.objectmodel.migration.MigrationDependency;
import com.l7tech.objectmodel.migration.MigrationMappingSelection;
import com.l7tech.objectmodel.migration.MigrationUtils;
import com.l7tech.objectmodel.migration.PropertyResolver;
import com.l7tech.objectmodel.migration.PropertyResolverException;
import com.l7tech.server.EntityFinder;
import com.l7tech.server.EntityHeaderUtils;
import com.l7tech.server.migration.AbstractPropertyResolver;
import com.l7tech.server.migration.PropertyResolverFactory;
import java.io.Serializable;
import java.lang.reflect.Method;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;

public abstract class AbstractGoidPropertyResolver
extends AbstractPropertyResolver {
    private static final Logger c;
    private EntityFinder d;
    private static final String[] e;

    protected AbstractGoidPropertyResolver(PropertyResolverFactory propertyResolverFactory, PropertyResolver.Type type, EntityFinder entityFinder) {
        super(propertyResolverFactory, type);
        this.d = entityFinder;
    }

    public abstract EntityType getTargetType();

    public Map<ExternalEntityHeader, Set<MigrationDependency>> getDependencies(ExternalEntityHeader externalEntityHeader, Object object, Method method, String string) throws PropertyResolverException {
        Goid goid;
        String[] stringArray = e;
        c.log(Level.FINEST, stringArray[6], new Object[]{method.getName(), externalEntityHeader});
        MigrationMappingSelection migrationMappingSelection = MigrationUtils.getMappingType((Method)method);
        MigrationMappingSelection migrationMappingSelection2 = MigrationUtils.getValueMappingType((Method)method);
        ExternalEntityHeader.ValueType valueType = MigrationUtils.getValueType((Method)method);
        boolean bl2 = MigrationUtils.isExported((Method)method);
        EntityType entityType = this.getTargetType();
        try {
            goid = (Goid)AbstractGoidPropertyResolver.getPropertyValue(object, method);
        }
        catch (RuntimeException runtimeException) {
            stringArray = e;
            throw new PropertyResolverException(stringArray[3] + String.valueOf(object), (Throwable)runtimeException);
        }
        HashMap<ExternalEntityHeader, Set<MigrationDependency>> hashMap = new HashMap<ExternalEntityHeader, Set<MigrationDependency>>();
        try {
            ExternalEntityHeader externalEntityHeader2 = EntityHeaderUtils.toExternal(EntityHeaderUtils.fromEntity(this.d.find(EntityTypeRegistry.getEntityClass((EntityType)entityType), (Serializable)goid)));
            externalEntityHeader2.setValueMapping(migrationMappingSelection2, valueType, (Object)goid);
            hashMap.put(externalEntityHeader2, Collections.singleton(new MigrationDependency(externalEntityHeader, externalEntityHeader2, string, this.getType(), migrationMappingSelection, bl2)));
        }
        catch (FindException findException) {
            c.log(Level.FINE, e[8], new Object[]{entityType, goid});
        }
        return hashMap;
    }

    /*
     * Loose catch block
     */
    public void applyMapping(Object object, String string, ExternalEntityHeader externalEntityHeader, Object object2, ExternalEntityHeader externalEntityHeader2) throws PropertyResolverException {
        block11: {
            Class<?> clazz;
            PropertyResolverException propertyResolverException;
            PropertyResolverException propertyResolverException2;
            block13: {
                block12: {
                    if (object instanceof Entity) break block11;
                    try {
                        block14: {
                            PropertyResolverException propertyResolverException3;
                            propertyResolverException2 = propertyResolverException3;
                            propertyResolverException = propertyResolverException3;
                            if (object != null) break block12;
                            break block14;
                            catch (Exception exception) {
                                throw AbstractGoidPropertyResolver.a(exception);
                            }
                        }
                        clazz = null;
                        break block13;
                    }
                    catch (Exception exception) {
                        throw AbstractGoidPropertyResolver.a(exception);
                    }
                }
                clazz = object.getClass();
            }
            String[] stringArray = e;
            propertyResolverException2(stringArray[2] + String.valueOf(clazz));
            throw propertyResolverException;
        }
        try {
            c.log(Level.FINEST, e[1], new Object[]{EntityHeaderUtils.fromEntity((Entity)object), string});
            if (!(object2 instanceof PersistentEntity)) {
                throw new PropertyResolverException(e[4] + String.valueOf(object2));
            }
        }
        catch (Exception exception) {
            throw AbstractGoidPropertyResolver.a(exception);
        }
        Method method = MigrationUtils.setterForPropertyName((Object)object, (String)string, (Class[])new Class[]{Goid.class});
        if (method != null) {
            try {
                method.invoke(object, ((PersistentEntity)object2).getGoid());
            }
            catch (Exception exception) {
                String[] stringArray = e;
                throw new PropertyResolverException(stringArray[5] + string, (Throwable)exception);
            }
        } else {
            String[] stringArray = e;
            throw new PropertyResolverException(stringArray[7] + String.valueOf(object.getClass()) + stringArray[0] + string);
        }
    }

    /*
     * Unable to fully structure code
     */
    static {
        block10: {
            block9: {
                var5 = new String[9];
                var3_1 = 0;
                var2_2 = "\"<X\u001fCv\b\bx,5e&\u0015\u0005q52laX\u0002n7{y6\u0005D;e 3{V&Ag\u0016\nn1{jg\u0016\u0000m {li\u0016Id+/kr\u0011\u0001r~{pc\u001b\u0001h3>f<X)Gt\n\u000bse<gr\f\ro\"{rt\u0017\u0014d7/{&\u000e\u0005m0>\"`\u0017\u0016! 5vo\f\u001d;e?Gt\n\u000bse:rv\u0014\u001dh+<\"k\u0019\u0014q,5e&\u001e\u000bse+pi\b\u0001s1\"\"h\u0019\td~{kh\u000e\u0005m,?\"r\u0019\u0016f /\"p\u0019\bt a*Gt\n\u000bse:rv\u0014\u001dh+<\"k\u0019\u0014q,5e&\u001e\u000bse+pi\b\u0001s1\"\"h\u0019\td\u007f{@Ec\f\u0010h+<\"b\u001d\u0014d+?gh\u001b\rd6{di\nDq74rc\n\u0010xe 2{X\u000bge>lr\u0011\u0010xe,kr\u0010Di :fc\nDzt&,";
                var4_3 = "\"<X\u001fCv\b\bx,5e&\u0015\u0005q52laX\u0002n7{y6\u0005D;e 3{V&Ag\u0016\nn1{jg\u0016\u0000m {li\u0016Id+/kr\u0011\u0001r~{pc\u001b\u0001h3>f<X)Gt\n\u000bse<gr\f\ro\"{rt\u0017\u0014d7/{&\u000e\u0005m0>\"`\u0017\u0016! 5vo\f\u001d;e?Gt\n\u000bse:rv\u0014\u001dh+<\"k\u0019\u0014q,5e&\u001e\u000bse+pi\b\u0001s1\"\"h\u0019\td~{kh\u000e\u0005m,?\"r\u0019\u0016f /\"p\u0019\bt a*Gt\n\u000bse:rv\u0014\u001dh+<\"k\u0019\u0014q,5e&\u001e\u000bse+pi\b\u0001s1\"\"h\u0019\td\u007f{@Ec\f\u0010h+<\"b\u001d\u0014d+?gh\u001b\rd6{di\nDq74rc\n\u0010xe 2{X\u000bge>lr\u0011\u0010xe,kr\u0010Di :fc\nDzt&,".length();
                var1_4 = 3;
                var0_5 = -1;
lbl7:
                // 2 sources

                while (true) {
                    v0 = 74;
                    v1 = ++var0_5;
                    v2 = var2_2.substring(v1, v1 + var1_4);
                    v3 = -1;
                    break block9;
                    break;
                }
lbl13:
                // 1 sources

                while (true) {
                    var5[var3_1++] = AbstractGoidPropertyResolver.b(v0, AbstractGoidPropertyResolver.a(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    var2_2 = "9\ntu\r\u001bD\f\bjc\u0016UB\\\u0015gj\u000fRK\u001bB&t\u0010\u001bV\u0019\fr\u007f\r\u001bC\u0013\rh~_]J\u000eXrr\u001a\u001b@\u0012\fon\u0006\u0001U\u000e\u0017v\u007f\rO\\\\\u001biw\u001dRK\u001d\fou\u0011\u001b(2\u0017&\u007f\u0011OL\b\u0001&|\u0010NK\u0018X`u\r\u001bQ\u0005\bc _@\u0015\u0001Xau\u0016_\u001f\\\u00037gQ";
                    var4_3 = "9\ntu\r\u001bD\f\bjc\u0016UB\\\u0015gj\u000fRK\u001bB&t\u0010\u001bV\u0019\fr\u007f\r\u001bC\u0013\rh~_]J\u000eXrr\u001a\u001b@\u0012\fon\u0006\u0001U\u000e\u0017v\u007f\rO\\\\\u001biw\u001dRK\u001d\fou\u0011\u001b(2\u0017&\u007f\u0011OL\b\u0001&|\u0010NK\u0018X`u\r\u001bQ\u0005\bc _@\u0015\u0001Xau\u0016_\u001f\\\u00037gQ".length();
                    var1_4 = 76;
                    var0_5 = -1;
lbl22:
                    // 2 sources

                    while (true) {
                        v0 = 52;
                        v4 = ++var0_5;
                        v2 = var2_2.substring(v4, v4 + var1_4);
                        v3 = 0;
                        break block9;
                        break;
                    }
                    break;
                }
lbl28:
                // 1 sources

                while (true) {
                    var5[var3_1++] = AbstractGoidPropertyResolver.b(v0, AbstractGoidPropertyResolver.a(v2));
                    if ((var0_5 += var1_4) < var4_3) {
                        var1_4 = var2_2.charAt(var0_5);
                        ** continue;
                    }
                    break block10;
                    break;
                }
            }
            switch (v3) {
                default: {
                    ** continue;
                }
                ** case 0:
lbl39:
                // 1 sources

                ** continue;
            }
        }
        AbstractGoidPropertyResolver.e = var5;
        AbstractGoidPropertyResolver.c = Logger.getLogger(AbstractGoidPropertyResolver.class.getName());
    }

    private static Exception a(Exception exception) {
        return exception;
    }

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

    /*
     * Handled impossible loop by duplicating code
     * Enabled aggressive block sorting
     */
    private static String b(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 -> 72;
                    case 1 -> 76;
                    case 2 -> 50;
                    case 3 -> 46;
                    case 4 -> 75;
                    case 5 -> 15;
                    default -> 17;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }
}

