// 
// Decompiled by Procyon v0.6.0
// 

package org.bson.codecs.pojo;

import org.bson.BsonType;
import org.bson.codecs.Codec;

public final class PropertyModel<T>
{
    private final String name;
    private final String readName;
    private final String writeName;
    private final TypeData<T> typeData;
    private final Codec<T> codec;
    private final PropertySerialization<T> propertySerialization;
    private final Boolean useDiscriminator;
    private final PropertyAccessor<T> propertyAccessor;
    private final String error;
    private volatile Codec<T> cachedCodec;
    private final BsonType bsonRepresentation;
    
    PropertyModel(final String name, final String readName, final String writeName, final TypeData<T> typeData, final Codec<T> codec, final PropertySerialization<T> propertySerialization, final Boolean useDiscriminator, final PropertyAccessor<T> propertyAccessor, final String error, final BsonType bsonRepresentation) {
        this.name = name;
        this.readName = readName;
        this.writeName = writeName;
        this.typeData = typeData;
        this.codec = codec;
        this.cachedCodec = codec;
        this.propertySerialization = propertySerialization;
        this.useDiscriminator = useDiscriminator;
        this.propertyAccessor = propertyAccessor;
        this.error = error;
        this.bsonRepresentation = bsonRepresentation;
    }
    
    public static <T> PropertyModelBuilder<T> builder() {
        return new PropertyModelBuilder<T>();
    }
    
    public String getName() {
        return this.name;
    }
    
    public String getWriteName() {
        return this.writeName;
    }
    
    public String getReadName() {
        return this.readName;
    }
    
    public boolean isWritable() {
        return this.writeName != null;
    }
    
    public boolean isReadable() {
        return this.readName != null;
    }
    
    public TypeData<T> getTypeData() {
        return this.typeData;
    }
    
    public Codec<T> getCodec() {
        return this.codec;
    }
    
    public BsonType getBsonRepresentation() {
        return this.bsonRepresentation;
    }
    
    public boolean shouldSerialize(final T value) {
        return this.propertySerialization.shouldSerialize(value);
    }
    
    public PropertyAccessor<T> getPropertyAccessor() {
        return this.propertyAccessor;
    }
    
    public Boolean useDiscriminator() {
        return this.useDiscriminator;
    }
    
    @Override
    public String toString() {
        return "PropertyModel{propertyName='" + this.name + "', readName='" + this.readName + "', writeName='" + this.writeName + "', typeData=" + this.typeData + "}";
    }
    
    @Override
    public boolean equals(final Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || this.getClass() != o.getClass()) {
            return false;
        }
        final PropertyModel<?> that = (PropertyModel<?>)o;
        Label_0062: {
            if (this.getName() != null) {
                if (this.getName().equals(that.getName())) {
                    break Label_0062;
                }
            }
            else if (that.getName() == null) {
                break Label_0062;
            }
            return false;
        }
        Label_0095: {
            if (this.getReadName() != null) {
                if (this.getReadName().equals(that.getReadName())) {
                    break Label_0095;
                }
            }
            else if (that.getReadName() == null) {
                break Label_0095;
            }
            return false;
        }
        Label_0128: {
            if (this.getWriteName() != null) {
                if (this.getWriteName().equals(that.getWriteName())) {
                    break Label_0128;
                }
            }
            else if (that.getWriteName() == null) {
                break Label_0128;
            }
            return false;
        }
        Label_0161: {
            if (this.getTypeData() != null) {
                if (this.getTypeData().equals(that.getTypeData())) {
                    break Label_0161;
                }
            }
            else if (that.getTypeData() == null) {
                break Label_0161;
            }
            return false;
        }
        Label_0194: {
            if (this.getCodec() != null) {
                if (this.getCodec().equals(that.getCodec())) {
                    break Label_0194;
                }
            }
            else if (that.getCodec() == null) {
                break Label_0194;
            }
            return false;
        }
        Label_0227: {
            if (this.getPropertySerialization() != null) {
                if (this.getPropertySerialization().equals(that.getPropertySerialization())) {
                    break Label_0227;
                }
            }
            else if (that.getPropertySerialization() == null) {
                break Label_0227;
            }
            return false;
        }
        Label_0260: {
            if (this.useDiscriminator != null) {
                if (this.useDiscriminator.equals(that.useDiscriminator)) {
                    break Label_0260;
                }
            }
            else if (that.useDiscriminator == null) {
                break Label_0260;
            }
            return false;
        }
        Label_0293: {
            if (this.getPropertyAccessor() != null) {
                if (this.getPropertyAccessor().equals(that.getPropertyAccessor())) {
                    break Label_0293;
                }
            }
            else if (that.getPropertyAccessor() == null) {
                break Label_0293;
            }
            return false;
        }
        Label_0326: {
            if (this.getError() != null) {
                if (this.getError().equals(that.getError())) {
                    break Label_0326;
                }
            }
            else if (that.getError() == null) {
                break Label_0326;
            }
            return false;
        }
        if (this.getCachedCodec() != null) {
            if (this.getCachedCodec().equals(that.getCachedCodec())) {
                return true;
            }
        }
        else if (that.getCachedCodec() == null) {
            return true;
        }
        return false;
    }
    
    @Override
    public int hashCode() {
        int result = (this.getName() != null) ? this.getName().hashCode() : 0;
        result = 31 * result + ((this.getReadName() != null) ? this.getReadName().hashCode() : 0);
        result = 31 * result + ((this.getWriteName() != null) ? this.getWriteName().hashCode() : 0);
        result = 31 * result + ((this.getTypeData() != null) ? this.getTypeData().hashCode() : 0);
        result = 31 * result + ((this.getCodec() != null) ? this.getCodec().hashCode() : 0);
        result = 31 * result + ((this.getPropertySerialization() != null) ? this.getPropertySerialization().hashCode() : 0);
        result = 31 * result + ((this.useDiscriminator != null) ? this.useDiscriminator.hashCode() : 0);
        result = 31 * result + ((this.getPropertyAccessor() != null) ? this.getPropertyAccessor().hashCode() : 0);
        result = 31 * result + ((this.getError() != null) ? this.getError().hashCode() : 0);
        result = 31 * result + ((this.getCachedCodec() != null) ? this.getCachedCodec().hashCode() : 0);
        return result;
    }
    
    boolean hasError() {
        return this.error != null;
    }
    
    String getError() {
        return this.error;
    }
    
    PropertySerialization<T> getPropertySerialization() {
        return this.propertySerialization;
    }
    
    void cachedCodec(final Codec<T> codec) {
        this.cachedCodec = codec;
    }
    
    Codec<T> getCachedCodec() {
        return this.cachedCodec;
    }
}
