
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// This file is autogenerated by:
//     mojo/public/tools/bindings/mojom_bindings_generator.py
// For:
//     media/mojo/interfaces/media_types.mojom
//

package org.chromium.media.mojom;

import org.chromium.base.annotations.SuppressFBWarnings;
import org.chromium.mojo.bindings.DeserializationException;


public final class MasteringMetadata extends org.chromium.mojo.bindings.Struct {

    private static final int STRUCT_SIZE = 48;
    private static final org.chromium.mojo.bindings.DataHeader[] VERSION_ARRAY = new org.chromium.mojo.bindings.DataHeader[] {new org.chromium.mojo.bindings.DataHeader(48, 0)};
    private static final org.chromium.mojo.bindings.DataHeader DEFAULT_STRUCT_INFO = VERSION_ARRAY[0];
    public org.chromium.gfx.mojom.PointF primaryR;
    public org.chromium.gfx.mojom.PointF primaryG;
    public org.chromium.gfx.mojom.PointF primaryB;
    public org.chromium.gfx.mojom.PointF whitePoint;
    public float luminanceMax;
    public float luminanceMin;

    private MasteringMetadata(int version) {
        super(STRUCT_SIZE, version);
    }

    public MasteringMetadata() {
        this(0);
    }

    public static MasteringMetadata deserialize(org.chromium.mojo.bindings.Message message) {
        return decode(new org.chromium.mojo.bindings.Decoder(message));
    }

    /**
     * Similar to the method above, but deserializes from a |ByteBuffer| instance.
     *
     * @throws org.chromium.mojo.bindings.DeserializationException on deserialization failure.
     */
    public static MasteringMetadata deserialize(java.nio.ByteBuffer data) {
        if (data == null)
            return null;

        return deserialize(new org.chromium.mojo.bindings.Message(
                data, new java.util.ArrayList<org.chromium.mojo.system.Handle>()));
    }

    @SuppressWarnings("unchecked")
    public static MasteringMetadata decode(org.chromium.mojo.bindings.Decoder decoder0) {
        if (decoder0 == null) {
            return null;
        }
        decoder0.increaseStackDepth();
        MasteringMetadata result;
        try {
            org.chromium.mojo.bindings.DataHeader mainDataHeader = decoder0.readAndValidateDataHeader(VERSION_ARRAY);
            result = new MasteringMetadata(mainDataHeader.elementsOrVersion);
            if (mainDataHeader.elementsOrVersion >= 0) {
                
                org.chromium.mojo.bindings.Decoder decoder1 = decoder0.readPointer(8, false);
                result.primaryR = org.chromium.gfx.mojom.PointF.decode(decoder1);
            }
            if (mainDataHeader.elementsOrVersion >= 0) {
                
                org.chromium.mojo.bindings.Decoder decoder1 = decoder0.readPointer(16, false);
                result.primaryG = org.chromium.gfx.mojom.PointF.decode(decoder1);
            }
            if (mainDataHeader.elementsOrVersion >= 0) {
                
                org.chromium.mojo.bindings.Decoder decoder1 = decoder0.readPointer(24, false);
                result.primaryB = org.chromium.gfx.mojom.PointF.decode(decoder1);
            }
            if (mainDataHeader.elementsOrVersion >= 0) {
                
                org.chromium.mojo.bindings.Decoder decoder1 = decoder0.readPointer(32, false);
                result.whitePoint = org.chromium.gfx.mojom.PointF.decode(decoder1);
            }
            if (mainDataHeader.elementsOrVersion >= 0) {
                
                result.luminanceMax = decoder0.readFloat(40);
            }
            if (mainDataHeader.elementsOrVersion >= 0) {
                
                result.luminanceMin = decoder0.readFloat(44);
            }
        } finally {
            decoder0.decreaseStackDepth();
        }
        return result;
    }

    @SuppressWarnings("unchecked")
    @Override
    protected final void encode(org.chromium.mojo.bindings.Encoder encoder) {
        org.chromium.mojo.bindings.Encoder encoder0 = encoder.getEncoderAtDataOffset(DEFAULT_STRUCT_INFO);
        
        encoder0.encode(primaryR, 8, false);
        
        encoder0.encode(primaryG, 16, false);
        
        encoder0.encode(primaryB, 24, false);
        
        encoder0.encode(whitePoint, 32, false);
        
        encoder0.encode(luminanceMax, 40);
        
        encoder0.encode(luminanceMin, 44);
    }

    /**
     * @see Object#equals(Object)
     */
    @Override
    public boolean equals(Object object) {
        if (object == this)
            return true;
        if (object == null)
            return false;
        if (getClass() != object.getClass())
            return false;
        MasteringMetadata other = (MasteringMetadata) object;
        if (!org.chromium.mojo.bindings.BindingsHelper.equals(this.primaryR, other.primaryR))
            return false;
        if (!org.chromium.mojo.bindings.BindingsHelper.equals(this.primaryG, other.primaryG))
            return false;
        if (!org.chromium.mojo.bindings.BindingsHelper.equals(this.primaryB, other.primaryB))
            return false;
        if (!org.chromium.mojo.bindings.BindingsHelper.equals(this.whitePoint, other.whitePoint))
            return false;
        if (this.luminanceMax!= other.luminanceMax)
            return false;
        if (this.luminanceMin!= other.luminanceMin)
            return false;
        return true;
    }

    /**
     * @see Object#hashCode()
     */
    @Override
    public int hashCode() {
        final int prime = 31;
        int result = prime + getClass().hashCode();
        result = prime * result + org.chromium.mojo.bindings.BindingsHelper.hashCode(primaryR);
        result = prime * result + org.chromium.mojo.bindings.BindingsHelper.hashCode(primaryG);
        result = prime * result + org.chromium.mojo.bindings.BindingsHelper.hashCode(primaryB);
        result = prime * result + org.chromium.mojo.bindings.BindingsHelper.hashCode(whitePoint);
        result = prime * result + org.chromium.mojo.bindings.BindingsHelper.hashCode(luminanceMax);
        result = prime * result + org.chromium.mojo.bindings.BindingsHelper.hashCode(luminanceMin);
        return result;
    }
}