AbstractImportService.java

/*
 * Copyright © 2024-2025 The CTAN Team and individual authors
 *
 * This file is distributed under the 3-clause BSD license.
 * See file LICENSE for details.
 */
package org.ctan.site.services.catalogue;

import java.io.File;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import lombok.NonNull;

/**
 * This abstract base class provides the fundamentals for the catalogue imports
 * from ML files.
 *
 * @param <T> the class of the encapsulated store
 *
 * @author <a href="mailto:gene@ctan.org">Gerd Neugebauer</a>
 */
public abstract class AbstractImportService<T> {

    /**
     * The field <code>store</code> contains the encapsulated store.
     */
    @NonNull
    protected T store;

    /**
     * The field <code>entries</code> contains the base directory.
     */
    @NonNull
    protected File entries;

    /**
     * This is the constructor for <code>AbstractImportService</code>.
     *
     * @param store the topics store
     */
    @SuppressFBWarnings(value = "CT_CONSTRUCTOR_THROW")
    AbstractImportService(@NonNull File entries, @NonNull T store) {

        this.entries = entries;
        this.store = store;
    }

    /**
     * The method <code>neq</code> provides means to compare two strings in a
     * null-safe fashion.
     *
     * @param a the first argument
     * @param b the second argument
     * @return {@code true} iff the arguments are not equal
     */
    protected boolean neq(String a, String b) {

        return a == null ? b != null : !a.equals(b);
    }
}