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

org.jsimpledb.vaadin.Util Maven / Gradle / Ivy

The newest version!

/*
 * Copyright (C) 2015 Archie L. Cobbs. All rights reserved.
 */

package org.jsimpledb.vaadin;

import com.google.common.base.Preconditions;

import java.util.SortedMap;
import java.util.TreeMap;

import org.jsimpledb.JClass;
import org.jsimpledb.JField;

/**
 * Utility routines.
 */
final class Util {

    private Util() {
    }

    /**
     * Get the {@link JField}s that are common to all of the given types.
     *
     * @param jclasses types to inspect
     * @return map containing common {@link JField}s, or null if {@code jclasses} is empty
     */
    static SortedMap getCommonJFields(Iterable> jclasses) {
        Preconditions.checkArgument(jclasses != null, "null jclasses");
        TreeMap jfields = null;
        for (JClass jclass : jclasses) {     // TODO: keep only fields with the same name; prefer indexed (sub-)fields
            if (jfields == null)
                jfields = new TreeMap<>(jclass.getJFieldsByStorageId());
            else
                jfields.keySet().retainAll(jclass.getJFieldsByStorageId().keySet());
        }
        return jfields;
    }
}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy