This repository has been archived by the owner on Oct 14, 2023. It is now read-only.
forked from hedzr/android-file-chooser
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
79 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
library/src/main/java/com/obsez/android/lib/smbfilechooser/internals/Triple.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package com.obsez.android.lib.smbfilechooser.internals; | ||
|
||
import android.util.Pair; | ||
|
||
public class Triple<F, S, T> extends Pair<F, S> { | ||
public final T third; | ||
|
||
/** | ||
* Constructor for a Pair. | ||
* | ||
* @param first the first object in the Pair | ||
* @param second the second object in the pair | ||
*/ | ||
public Triple(F first, S second) { | ||
this(first, second, null); | ||
} | ||
|
||
/** | ||
* Constructor for a Triple. | ||
* | ||
* @param first the first object in the Triple | ||
* @param second the second object in the Triple | ||
* @param third the third object in the Triple | ||
*/ | ||
public Triple(F first, S second, T third) { | ||
super(first, second); | ||
this.third = third; | ||
} | ||
|
||
protected static boolean nullSafeEquals(Object a, Object b) { | ||
//noinspection EqualsReplaceableByObjectsCall | ||
return (a == b) || (a != null && a.equals(b)); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
return (o instanceof Triple && nullSafeEquals(((Triple) o).first, first) && nullSafeEquals(((Triple) o).second, second) && nullSafeEquals(((Triple) o).third, third)); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return super.hashCode() ^ (third == null ? 0 : third.hashCode()); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Triple{" + first + ", " + second + ", " + third + "}"; | ||
} | ||
|
||
/** | ||
* @deprecated use {@link #create(Object, Object, Object)} instead | ||
*/ | ||
@Deprecated | ||
public static <A, B> Pair <A, B> create(A a, B b) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
/** | ||
* Convenience method for creating an appropriately typed Triple. | ||
* @param a the first object in the Triple | ||
* @param b the second object in the Triple | ||
* @param c the third object in the Triple | ||
* @return a Triple that is templatized with the types of a, b and c | ||
*/ | ||
public static <A, B, C> Triple <A, B, C> create(A a, B b, C c) { | ||
return new Triple<>(a, b, c); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters