// Path: src/main/java/io/taciturn/Utility.java
// public static <Item> ClassUtility<Item> $(Class<Item> object) {
//     return new ClassUtility<>(object);
// }


import java.util.Objects;
import java.util.Optional;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.Supplier;
import static io.taciturn.Utility.$;
package io.taciturn.utility;



@SuppressWarnings("WeakerAccess")
public abstract class AbstractUtility<Item> {

    @SuppressWarnings("OptionalUsedAsFieldOrParameterType")
    private Optional<Item> object;

    public AbstractUtility(Item object) {
        this.object = Optional.ofNullable(object);
    }
    
    public boolean isPresent() {
        return object.isPresent();
    }
    
    public void ifPresent(Consumer<? super Item> consumer) {
        object.ifPresent(consumer);
    }

    @SuppressWarnings("unchecked")
    public <T extends AbstractUtility<Item>> T filter(Predicate<? super Item> predicate) {
        object = object.filter(predicate);
        return (T) this;
    }
    
    @SuppressWarnings("unchecked")
    public <U> AbstractUtility<U> map(Function<? super Item, ? extends U> mapper) {
// Path: src/main/java/io/taciturn/Utility.java
// public static <Item> ClassUtility<Item> $(Class<Item> object) {
//     return new ClassUtility<>(object);
// }


// Path: src/main/java/io/taciturn/utility/AbstractUtility.java
import java.util.Objects;
import java.util.Optional;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.Supplier;
import static io.taciturn.Utility.$;

package io.taciturn.utility;



@SuppressWarnings("WeakerAccess")
public abstract class AbstractUtility<Item> {

    @SuppressWarnings("OptionalUsedAsFieldOrParameterType")
    private Optional<Item> object;

    public AbstractUtility(Item object) {
        this.object = Optional.ofNullable(object);
    }
    
    public boolean isPresent() {
        return object.isPresent();
    }
    
    public void ifPresent(Consumer<? super Item> consumer) {
        object.ifPresent(consumer);
    }

    @SuppressWarnings("unchecked")
    public <T extends AbstractUtility<Item>> T filter(Predicate<? super Item> predicate) {
        object = object.filter(predicate);
        return (T) this;
    }
    
    @SuppressWarnings("unchecked")
    public <U> AbstractUtility<U> map(Function<? super Item, ? extends U> mapper) {
        return $(this.object.map(mapper).orElse(null));