1 /* 2 * Copyright (C) 2012 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.dialer.callcomposer.camera.exif; 18 19 import java.util.Objects; 20 21 /** 22 * The rational data type of EXIF tag. Contains a pair of longs representing the numerator and 23 * denominator of a Rational number. 24 */ 25 public class Rational { 26 27 private final long mNumerator; 28 private final long mDenominator; 29 30 /** Create a Rational with a given numerator and denominator. */ 31 Rational(long nominator, long denominator) { 32 mNumerator = nominator; 33 mDenominator = denominator; 34 } 35 36 /** Gets the numerator of the rational. */ 37 long getNumerator() { 38 return mNumerator; 39 } 40 41 /** Gets the denominator of the rational */ 42 long getDenominator() { 43 return mDenominator; 44 } 45 46 @Override 47 public boolean equals(Object obj) { 48 if (obj == null) { 49 return false; 50 } 51 if (this == obj) { 52 return true; 53 } 54 if (obj instanceof Rational) { 55 Rational data = (Rational) obj; 56 return mNumerator == data.mNumerator && mDenominator == data.mDenominator; 57 } 58 return false; 59 } 60 61 @Override 62 public int hashCode() { 63 return Objects.hash(mNumerator, mDenominator); 64 } 65 66 @Override 67 public String toString() { 68 return mNumerator + "/" + mDenominator; 69 } 70 } 71