1 /*
2  *  Copyright 2016 The WebRTC project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 package org.webrtc;
12 
13 /**
14  * Class for representing size of an object. Very similar to android.util.Size but available on all
15  * devices.
16  */
17 public class Size {
18   public int width;
19   public int height;
20 
Size(int width, int height)21   public Size(int width, int height) {
22     this.width = width;
23     this.height = height;
24   }
25 
26   @Override
toString()27   public String toString() {
28     return width + "x" + height;
29   }
30 
31   @Override
equals(Object other)32   public boolean equals(Object other) {
33     if (!(other instanceof Size)) {
34       return false;
35     }
36     final Size otherSize = (Size) other;
37     return width == otherSize.width && height == otherSize.height;
38   }
39 
40   @Override
hashCode()41   public int hashCode() {
42     // Use prime close to 2^16 to avoid collisions for normal values less than 2^16.
43     return 1 + 65537 * width + height;
44   }
45 }
46