/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  com.l7tech.objectmodel.EntityType
 *  com.l7tech.policy.assertion.UsesEntities
 *  com.l7tech.util.Functions$Unary
 *  com.l7tech.util.Option
 */
package com.l7tech.server.util;

import com.l7tech.objectmodel.EntityType;
import com.l7tech.policy.assertion.UsesEntities;
import com.l7tech.server.util.i;
import com.l7tech.server.util.j;
import com.l7tech.server.util.k;
import com.l7tech.util.Functions;
import com.l7tech.util.Option;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

public class EntityUseUtils {
    private static final String a = EntityUseUtils.a(40, EntityUseUtils.a("%U\u0017R\u0012\u0019\u001c6Y\u0006d)\u001e\u0010&"));

    public static String getTypeName(UsesEntities usesEntities, EntityType entityType) {
        try {
            Option option = Option.optional((Object)usesEntities.getClass().getMethod(a, new Class[0]).getAnnotation(EntityUse.class));
            return (String)option.map(EntityUseUtils.a(entityType)).orSome((Object)entityType.getName());
        }
        catch (NoSuchMethodException noSuchMethodException) {
        }
        catch (SecurityException securityException) {
            // empty catch block
        }
        return entityType.getName();
    }

    private static Functions.Unary<String, EntityUse> a(EntityType entityType) {
        return new i(entityType);
    }

    private static Functions.Unary<EntityType, EntityTypeOverride> a() {
        return new j();
    }

    private static Functions.Unary<String, EntityTypeOverride> b() {
        return new k();
    }

    private static char[] a(String string) {
        char[] cArray = string.toCharArray();
        if (cArray.length < 2) {
            cArray = cArray;
            cArray[0] = (char)(cArray[0] ^ 0x5D);
        }
        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 -> 106;
                    case 1 -> 24;
                    case 2 -> 75;
                    case 3 -> 63;
                    case 4 -> 84;
                    case 5 -> 69;
                    default -> 93;
                })));
                ++n3;
                n4 = n4;
            } while (n4 > n3);
        }
        return new String(cArray2).intern();
    }

    @Documented
    @Retention(value=RetentionPolicy.RUNTIME)
    @Target(value={ElementType.METHOD})
    public static @interface EntityUse {
        public EntityTypeOverride[] value();
    }

    @Documented
    @Retention(value=RetentionPolicy.RUNTIME)
    @Target(value={})
    public static @interface EntityTypeOverride {
        public EntityType type();

        public String description();
    }
}

