EmbeddedLayerSource.java 3.89 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  com.scene7.is.provider.LayerSourceEnum
 *  com.scene7.is.util.serializers.EnumSerializer
 *  com.scene7.is.util.serializers.Serializer
 *  org.jetbrains.annotations.NotNull
 */
package com.scene7.is.ps.provider;

import com.scene7.is.provider.LayerSourceEnum;
import com.scene7.is.ps.provider.LayerSource;
import com.scene7.is.util.serializers.EnumSerializer;
import com.scene7.is.util.serializers.Serializer;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import org.jetbrains.annotations.NotNull;

public class EmbeddedLayerSource
implements LayerSource {
    private static final Serializer<LayerSourceEnum> LAYER_SOURCE_SERIALIZER = EnumSerializer.enumSerializer(LayerSourceEnum.class);
    private static final Serializer<EmbeddedLayerSource> SERIALIZER = new Serializer<EmbeddedLayerSource>(){

        public EmbeddedLayerSource load(@NotNull DataInput in) throws IOException {
            LayerSourceEnum type = (LayerSourceEnum)LAYER_SOURCE_SERIALIZER.load(in);
            String request = in.readUTF();
            return EmbeddedLayerSource.embeddedLayerSource(type, request);
        }

        public void store(EmbeddedLayerSource value, @NotNull DataOutput out) throws IOException {
            LAYER_SOURCE_SERIALIZER.store((Object)value.type, out);
            out.writeUTF(value.request);
        }

        public int dataLength() throws UnsupportedOperationException {
            throw new UnsupportedOperationException("dataLength");
        }
    };
    @NotNull
    private final String request;
    @NotNull
    private final LayerSourceEnum type;

    @NotNull
    public static Serializer<EmbeddedLayerSource> embeddedLayerSourceSerializer() {
        return SERIALIZER;
    }

    public static EmbeddedLayerSource embeddedLayerSource(@NotNull LayerSourceEnum type, @NotNull String request) {
        return new EmbeddedLayerSource(type, request);
    }

    @NotNull
    @Override
    public LayerSourceEnum getType() {
        return this.type;
    }

    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || this.getClass() != obj.getClass()) {
            return false;
        }
        EmbeddedLayerSource that = (EmbeddedLayerSource)obj;
        if (!this.request.equals(that.request)) {
            return false;
        }
        return this.type == that.type;
    }

    public int hashCode() {
        int result = this.type.hashCode();
        result = 31 * result + this.request.hashCode();
        return result;
    }

    public String toString() {
        return "embed[" + this.type.toString() + ",'" + this.request + "']";
    }

    @NotNull
    @Override
    public String getValue() {
        return this.request;
    }

    private void readObject(ObjectInputStream in) throws IOException {
        throw new AssertionError();
    }

    private void writeObject(ObjectOutputStream out) throws IOException {
        throw new AssertionError();
    }

    protected Object writeReplace() {
        return new Serializable(){
            private EmbeddedLayerSource value;

            private Object readResolve() {
                assert (this.value != null);
                return this.value;
            }

            private void readObject(ObjectInputStream in) throws IOException {
                this.value = (EmbeddedLayerSource)SERIALIZER.load((DataInput)in);
            }

            private void writeObject(ObjectOutputStream out) throws IOException {
                SERIALIZER.store((Object)EmbeddedLayerSource.this, (DataOutput)out);
            }
        };
    }

    private EmbeddedLayerSource(@NotNull LayerSourceEnum type, @NotNull String request) {
        this.type = type;
        this.request = request;
    }

}