mirror of
https://codeberg.org/Mercury-IM/Mercury-IM
synced 2024-06-17 09:04:53 +02:00
24 lines
432 B
Java
24 lines
432 B
Java
|
package org.mercury_im.messenger.core.util;
|
||
|
|
||
|
/**
|
||
|
* Since j.u.Optional is only available on Android since API lvl 24, we need this utility class.
|
||
|
*
|
||
|
* @param <T> type of wrapped object.
|
||
|
*/
|
||
|
public class Optional<T> {
|
||
|
|
||
|
private final T item;
|
||
|
|
||
|
public Optional(T item) {
|
||
|
this.item = item;
|
||
|
}
|
||
|
|
||
|
public T getItem() {
|
||
|
return item;
|
||
|
}
|
||
|
|
||
|
public boolean isPresent() {
|
||
|
return item != null;
|
||
|
}
|
||
|
}
|