/*
 * Copyright 2017, Flávio Keglevich
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.fkeglevich.rawdumper.camera.data;

/**
 * TODO: Add class header
 * <p>
 * Created by Flávio Keglevich on 26/10/17.
 */

public class ManualFocus
{
    private static final int INVALID_NUMERIC_VALUE = 0;

    public static final ManualFocus DISABLED = new ManualFocus(INVALID_NUMERIC_VALUE);

    public static ManualFocus create(int numericValue)
    {
        if (numericValue <= INVALID_NUMERIC_VALUE)
            throw new IllegalArgumentException();

        return new ManualFocus(numericValue);
    }

    private final int numericValue;

    private ManualFocus(int numericValue)
    {
        this.numericValue = numericValue;
    }

    public int getNumericValue()
    {
        if (this == DISABLED)
            throw new RuntimeException("Disabled manual focus doesn't have a numeric value!");

        return numericValue;
    }
}

@@ -642,16 +642,60 @@
 .data;%0A%0A
+import android.support.annotation.NonNull;%0A%0A
 /**%0A * T
@@ -796,16 +796,51 @@
 ualFocus
+ implements Comparable%3CManualFocus%3E
 %0A%7B%0A    p
@@ -1384,16 +1384,15 @@
 if (
-this == 
+equals(
 DISA
@@ -1396,16 +1396,17 @@
 ISABLED)
+)
 %0A       
@@ -1490,24 +1490,24 @@
  value!%22);%0A%0A
-
         retu
@@ -1528,11 +1528,1232 @@
 e;%0A    %7D
+%0A%0A    @Override%0A    public boolean equals(Object o)%0A    %7B%0A        if (this == o) return true;%0A        if (o == null %7C%7C getClass() != o.getClass()) return false;%0A%0A        ManualFocus that = (ManualFocus) o;%0A%0A        return numericValue == that.numericValue;%0A    %7D%0A%0A    @Override%0A    public int hashCode()%0A    %7B%0A        return numericValue;%0A    %7D%0A%0A    /**%0A     * Compares this object to the specified object to determine their relative%0A     * order.%0A     *%0A     * @param another the object to compare to this instance.%0A     * @return a negative integer if this instance is less than %7B@code another%7D;%0A     * a positive integer if this instance is greater than%0A     * %7B@code another%7D; 0 if this instance has the same order as%0A     * %7B@code another%7D.%0A     * @throws ClassCastException if %7B@code another%7D cannot be converted into something%0A     *                            comparable to %7B@code this%7D instance.%0A     */%0A    @Override%0A    public int compareTo(@NonNull ManualFocus another)%0A    %7B%0A        int myNumeric = equals(DISABLED) ? Integer.MIN_VALUE : getNumericValue();%0A        int anotherNumeric = another.equals(DISABLED) ? Integer.MIN_VALUE : another.getNumericValue();%0A        return myNumeric - anotherNumeric;%0A    %7D
 %0A%7D%0A

Make ManualFocus comparable