| OLD | NEW |
| (Empty) |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 package org.chromium.mojo.bindings; | |
| 6 | |
| 7 /** | |
| 8 * The header for a mojo complex element. | |
| 9 */ | |
| 10 public final class DataHeader { | |
| 11 /** | |
| 12 * The size of a serialized header, in bytes. | |
| 13 */ | |
| 14 public static final int HEADER_SIZE = 8; | |
| 15 | |
| 16 /** | |
| 17 * The offset of the size field. | |
| 18 */ | |
| 19 public static final int SIZE_OFFSET = 0; | |
| 20 | |
| 21 /** | |
| 22 * The offset of the number of fields field. | |
| 23 */ | |
| 24 public static final int ELEMENTS_OR_VERSION_OFFSET = 4; | |
| 25 | |
| 26 /** | |
| 27 * The size of the object owning this header. | |
| 28 */ | |
| 29 public final int size; | |
| 30 | |
| 31 /** | |
| 32 * Number of element (for an array) or version (for a struct) of the object
owning this | |
| 33 * header. | |
| 34 */ | |
| 35 public final int elementsOrVersion; | |
| 36 | |
| 37 /** | |
| 38 * Constructor. | |
| 39 */ | |
| 40 public DataHeader(int size, int elementsOrVersion) { | |
| 41 super(); | |
| 42 this.size = size; | |
| 43 this.elementsOrVersion = elementsOrVersion; | |
| 44 } | |
| 45 | |
| 46 /** | |
| 47 * @see Object#hashCode() | |
| 48 */ | |
| 49 @Override | |
| 50 public int hashCode() { | |
| 51 final int prime = 31; | |
| 52 int result = 1; | |
| 53 result = prime * result + elementsOrVersion; | |
| 54 result = prime * result + size; | |
| 55 return result; | |
| 56 } | |
| 57 | |
| 58 /** | |
| 59 * @see Object#equals(Object) | |
| 60 */ | |
| 61 @Override | |
| 62 public boolean equals(Object object) { | |
| 63 if (object == this) return true; | |
| 64 if (object == null) return false; | |
| 65 if (getClass() != object.getClass()) return false; | |
| 66 | |
| 67 DataHeader other = (DataHeader) object; | |
| 68 return (elementsOrVersion == other.elementsOrVersion && size == other.si
ze); | |
| 69 } | |
| 70 } | |
| OLD | NEW |