All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.landawn.abacus.util.PrimitiveTuple Maven / Gradle / Ivy

/*
 * Copyright (C) 2020 HaiYang Li
 *
 * 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.landawn.abacus.util;

import com.landawn.abacus.util.u.Optional;

@com.landawn.abacus.annotation.Immutable
abstract class PrimitiveTuple> implements Immutable {

    /**
     *
     *
     * @return
     */
    public abstract int arity();

    /**
     *
     *
     * @param 
     * @param action
     * @throws E
     */
    public  void accept(final Throwables.Consumer action) throws E {
        action.accept((TP) this);
    }

    /**
     *
     *
     * @param 
     * @param 
     * @param mapper
     * @return
     * @throws E
     */
    public  U map(final Throwables.Function mapper) throws E {
        return mapper.apply((TP) this);
    }

    /**
     *
     *
     * @param 
     * @param predicate
     * @return
     * @throws E
     */
    public  Optional filter(final Throwables.Predicate predicate) throws E {
        return predicate.test((TP) this) ? Optional.of((TP) this) : Optional.empty();
    }

    /**
     *
     *
     * @return
     */
    public Optional toOptional() {
        return Optional.of((TP) this);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy