summaryrefslogtreecommitdiffstats
path: root/third_party/libwebrtc/rtc_base/java/src/org/webrtc/Size.java
blob: a711b5d2cadd3a8d7ce33ce813103d14ff160873 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
 *  Copyright 2016 The WebRTC project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree. An additional intellectual property rights grant can be found
 *  in the file PATENTS.  All contributing project authors may
 *  be found in the AUTHORS file in the root of the source tree.
 */

package org.webrtc;

/**
 * Class for representing size of an object. Very similar to android.util.Size but available on all
 * devices.
 */
public class Size {
  public int width;
  public int height;

  public Size(int width, int height) {
    this.width = width;
    this.height = height;
  }

  @Override
  public String toString() {
    return width + "x" + height;
  }

  @Override
  public boolean equals(Object other) {
    if (!(other instanceof Size)) {
      return false;
    }
    final Size otherSize = (Size) other;
    return width == otherSize.width && height == otherSize.height;
  }

  @Override
  public int hashCode() {
    // Use prime close to 2^16 to avoid collisions for normal values less than 2^16.
    return 1 + 65537 * width + height;
  }
}