ResourceCache$class.java 9.74 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  com.adobe.forms.cache.ResourceCache$
 *  com.adobe.forms.cache.ResourceCache$$anonfun
 *  com.adobe.forms.cache.ResourceCache$$anonfun$clearAll
 *  com.adobe.forms.cache.ResourceCache$$anonfun$get
 *  com.adobe.forms.cache.ResourceCache$$anonfun$getOrElseUpdate
 *  com.adobe.forms.cache.ResourceCache$$anonfun$put
 *  org.slf4j.Logger
 *  org.slf4j.LoggerFactory
 *  scala.Function0
 *  scala.Function1
 *  scala.None
 *  scala.None$
 *  scala.Option
 *  scala.runtime.AbstractFunction0
 *  scala.runtime.AbstractFunction0$mcV
 *  scala.runtime.AbstractFunction0$mcV$sp
 *  scala.runtime.AbstractFunction0$mcZ
 *  scala.runtime.AbstractFunction0$mcZ$sp
 *  scala.runtime.BoxesRunTime
 */
package com.adobe.forms.cache;

import com.adobe.forms.cache.CacheStore;
import com.adobe.forms.cache.Cacheable;
import com.adobe.forms.cache.LCFormsCacheConfig;
import com.adobe.forms.cache.ResourceCache;
import com.adobe.forms.cache.impl.CacheConfigParam$;
import com.adobe.forms.logging.PerfLogger$;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import scala.Function0;
import scala.Function1;
import scala.None;
import scala.Option;
import scala.runtime.AbstractFunction0;
import scala.runtime.BoxesRunTime;

public abstract class ResourceCache$class {
    public static long cacheSize(ResourceCache $this) {
        return $this.lcFormsCacheConfig().getCacheSize();
    }

    public static double maxObjectSize(ResourceCache $this) {
        return CacheConfigParam$.MODULE$.getSizeMb($this.lcFormsCacheConfig().getMaxObjectSize()) * 1024 * 1024;
    }

    public static boolean put(ResourceCache $this, Cacheable res$1) {
        return BoxesRunTime.unboxToBoolean(PerfLogger$.MODULE$.measure((Function0<Object>)new scala.Serializable($this){
            public static final long serialVersionUID;

            public static {
                long l = ResourceCache..anonfun.put.serialVersionUID = 0;
            }

            public final String apply() {
                return "ResourceCache.put";
            }
        }, new scala.Serializable($this, res$1){
            public static final long serialVersionUID;
            private final ResourceCache $outer;
            private final Cacheable res$1;

            public static {
                long l = ResourceCache..anonfun.put.serialVersionUID = 0;
            }

            public final boolean apply() {
                return this.apply$mcZ$sp();
            }

            public boolean apply$mcZ$sp() {
                boolean bl;
                if (this.$outer.isEnabled()) {
                    if ((double)this.res$1.size() > this.$outer.maxObjectSize()) {
                        this.$outer.logger().warn(new scala.collection.mutable.StringBuilder().append((Object)"Ignoring cache write as Object size is greater than Max Object size in cache setting. Key [").append(this.res$1.key().getOrElse((Function0)new scala.Serializable(this){
                            public static final long serialVersionUID;

                            public static {
                                long l = com.adobe.forms.cache.ResourceCache$$anonfun$put$1$$anonfun$apply$mcZ$sp$1.serialVersionUID = 0;
                            }

                            public final String apply() {
                                return "";
                            }
                        })).append((Object)"] and Size [").append((Object)BoxesRunTime.boxToLong((long)this.res$1.size())).append((Object)"]").toString());
                        bl = false;
                    } else if (this.res$1.isCacheable()) {
                        String string;
                        scala.Some some;
                        String x;
                        Option<String> option = this.res$1.key();
                        if (option instanceof scala.Some && this.gd1$1(x = (string = (String)(some = (scala.Some)option).x()))) {
                            this.$outer._store().put(x, this.res$1);
                            bl = true;
                        } else {
                            this.$outer.logger().debug("Ignoring cache write as Object key is not specified.");
                            bl = false;
                        }
                    } else {
                        this.$outer.logger().warn("Ignoring cache write as Object is not cache-able. Please check previous logs for further information.");
                        bl = false;
                    }
                } else {
                    bl = false;
                }
                return bl;
            }

            private final boolean gd1$1(String string) {
                return !string.isEmpty();
            }
        }));
    }

    public static Option get(ResourceCache $this, Option resKey$1) {
        return (Option)PerfLogger$.MODULE$.measure((Function0<Object>)new scala.Serializable($this){
            public static final long serialVersionUID;

            public static {
                long l = ResourceCache..anonfun.get.serialVersionUID = 0;
            }

            public final String apply() {
                return "ResourceCache.get";
            }
        }, new scala.Serializable($this, resKey$1){
            public static final long serialVersionUID;
            private final ResourceCache $outer;
            private final Option resKey$1;

            public static {
                long l = ResourceCache..anonfun.get.serialVersionUID = 0;
            }

            public final Option<Cacheable> apply() {
                String string;
                scala.Some some;
                Object object;
                String x;
                Option<Object> option;
                Option option2;
                scala.Some some2;
                None. v0 = this.$outer.isEnabled() ? ((option2 = this.resKey$1) instanceof scala.Some && this.gd2$1(x = (string = (String)(some = (scala.Some)option2).x())) ? ((option = this.$outer._store().get(x)) instanceof scala.Some && (object = (some2 = (scala.Some)option).x()) instanceof Cacheable ? new scala.Some((Object)((Cacheable)object)) : None..MODULE$) : None..MODULE$) : None..MODULE$;
                return v0;
            }

            private final boolean gd2$1(String string) {
                return !string.isEmpty();
            }
        });
    }

    public static Option get(ResourceCache $this, Cacheable res) {
        return $this.get(res.key());
    }

    private static Object unity(ResourceCache $this, Object a) {
        return a;
    }

    public static Cacheable getOrElseUpdate(ResourceCache $this, Cacheable res$2, Function1 cacheGenerator$1, Option key$1) {
        return (Cacheable)PerfLogger$.MODULE$.measure((Function0<Object>)new scala.Serializable($this){
            public static final long serialVersionUID;

            public static {
                long l = ResourceCache..anonfun.getOrElseUpdate.serialVersionUID = 0;
            }

            public final String apply() {
                return "ResourceCache.getOrElseUpdate";
            }
        }, new scala.Serializable($this, res$2, cacheGenerator$1, key$1){
            public static final long serialVersionUID;
            private final ResourceCache $outer;
            private final Cacheable res$2;
            private final Function1 cacheGenerator$1;
            private final Option key$1;

            public static {
                long l = ResourceCache..anonfun.getOrElseUpdate.serialVersionUID = 0;
            }

            public final U apply() {
                Cacheable cacheable;
                Cacheable x;
                Cacheable cacheable2;
                Cacheable cacheable3;
                scala.Some some;
                Option option = this.key$1;
                Option<Cacheable> lastCached = option instanceof scala.Some ? this.$outer.get(this.key$1) : this.$outer.get(this.res$2);
                Option<Cacheable> option2 = lastCached;
                if (option2 instanceof scala.Some && (cacheable = (Cacheable)(some = (scala.Some)option2).x()) instanceof Cacheable && this.gd3$1(x = (cacheable2 = cacheable))) {
                    cacheable3 = x;
                } else {
                    Cacheable it = (Cacheable)this.cacheGenerator$1.apply((Object)this.res$2);
                    this.$outer.put(it);
                    cacheable3 = it;
                }
                return (U)cacheable3;
            }

            private final boolean gd3$1(Cacheable cacheable) {
                return !cacheable.isExpired((Option<Cacheable>)new scala.Some((Object)this.res$2));
            }
        });
    }

    public static Option getOrElseUpdate$default$3(ResourceCache $this) {
        return None..MODULE$;
    }

    public static Set keySet(ResourceCache $this) {
        return $this._store().keySet();
    }

    public static void clearAll(ResourceCache $this) {
        PerfLogger$.MODULE$.measure((Function0<Object>)new scala.Serializable($this){
            public static final long serialVersionUID;

            public static {
                long l = ResourceCache..anonfun.clearAll.serialVersionUID = 0;
            }

            public final String apply() {
                return "ResourceCache.clearAll";
            }
        }, new scala.Serializable($this){
            public static final long serialVersionUID;
            private final ResourceCache $outer;

            public static {
                long l = ResourceCache..anonfun.clearAll.serialVersionUID = 0;
            }

            public final void apply() {
                this.apply$mcV$sp();
            }

            public void apply$mcV$sp() {
                this.$outer._store().clearAll();
            }
        });
    }

    public static void $init$(ResourceCache $this) {
        $this.logger_$eq(LoggerFactory.getLogger($this.getClass()));
    }
}