- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
public final class Equality {
/**
* @param o an object
* @param a an object to be compared with {@code o} for equality
* @return true if the arguments are equal to each other and false otherwise
*/
public static <O> boolean eq(@Nullable O o, @Nullable O a) {
return Objects.equals(o, a);
}
/**
* @param o an object
* @param a an object to be compared with {@code o} for equality
* @return true if the any arguments are equal to each other and false otherwise
*/
public static <O> boolean eqAny(@Nullable O o, @Nullable O a) {
return eq(o, a);
}
/**
* @param o an object
* @param a an object to be compared with {@code o} for equality
* @param b an object to be compared with {@code o} for equality
* @return true if the any arguments are equal to each other and false otherwise
*/
public static <O> boolean eqAny(@Nullable O o, @Nullable O a, @Nullable O b) {
return eq(o, a) || eq(o, b);
}
/**
* @param o an object
* @param a an object to be compared with {@code o} for equality
* @param b an object to be compared with {@code o} for equality
* @param c an object to be compared with {@code o} for equality
* @return true if the any arguments are equal to each other and false otherwise
*/
public static <O> boolean eqAny(@Nullable O o, @Nullable O a, @Nullable O b, @Nullable O c) {
return eqAny(o, a, b) || eq(o, c);
}
/**
* @param o an object
* @param a an object to be compared with {@code o} for equality
* @param b an object to be compared with {@code o} for equality
* @param c an object to be compared with {@code o} for equality
* @param d an object to be compared with {@code o} for equality
* @return true if the any arguments are equal to each other and false otherwise
*/
public static <O> boolean eqAny(@Nullable O o, @Nullable O a, @Nullable O b, @Nullable O c, @Nullable O d) {
return eqAny(o, a, b, c) || eq(o, d);
}
/**
* @param o an object
* @param a an object to be compared with {@code o} for equality
* @param b an object to be compared with {@code o} for equality
* @param c an object to be compared with {@code o} for equality
* @param d an object to be compared with {@code o} for equality
* @param e an object to be compared with {@code o} for equality
* @return true if the any arguments are equal to each other and false otherwise
*/
public static <O> boolean eqAny(@Nullable O o, @Nullable O a, @Nullable O b, @Nullable O c, @Nullable O d, @Nullable O e) {
return eqAny(o, a, b, c, d) || eq(o, e);
}
/**
* @param o an object
* @param a an array of objects to be compared
* @return true if any the arguments are equal to each other and false otherwise
*/
public static <O> boolean eqAny(@Nullable O o, O... a) {
for(O e: a)
if(eq(o, e))
return true;
return false;
}
}
Мой любимый класс.
Когда на душе становится тяжело, я всегда открываю этот класс, и признаки депрессии улетучиваются.
И да, комментарии врут, и да, там еще столько же методов eqAll(...)