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 numerator; 28 private final long denominator; 29 30 /** Create a Rational with a given numerator and denominator. */ Rational(long nominator, long denominator)31 Rational(long nominator, long denominator) { 32 numerator = nominator; 33 this.denominator = denominator; 34 } 35 36 /** Gets the numerator of the rational. */ getNumerator()37 long getNumerator() { 38 return numerator; 39 } 40 41 /** Gets the denominator of the rational */ getDenominator()42 long getDenominator() { 43 return denominator; 44 } 45 46 @Override equals(Object obj)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 numerator == data.numerator && denominator == data.denominator; 57 } 58 return false; 59 } 60 61 @Override hashCode()62 public int hashCode() { 63 return Objects.hash(numerator, denominator); 64 } 65 66 @Override toString()67 public String toString() { 68 return numerator + "/" + denominator; 69 } 70 } 71