public static <S extends Setting<V>, V extends Setting.State> SettingMapFactory<S, V> create(S[] settings, V[] states) {
        Objects.requireNonNull(settings, "settings");
        Objects.requireNonNull(states, "states");

        // ensure the number of settings can fit into a byte
        // we encode the number of "changes" from default as a byte.
        if (settings.length > 255) {
            throw new IllegalArgumentException("number of settings cannot be greater than 255");
        }

        // ensure the ordinal of any of the states can fit into a byte
        // means indexes run from 0-255
        if (states.length > 256) {
            throw new IllegalArgumentException("number of states cannot be greater than 256");
        }

        // ensure ordinal has been correctly implemented for the states
        for (int i = 0; i < states.length; i++) {
            V state = states[i];
            if (state.ordinal() != i) {
                throw new IllegalArgumentException("The ordinal of state " + state + " does not equal its array index. ordinal=" + state.ordinal() + ", index=" + i);
            }
        }

        byte[] defaultStates = new byte[settings.length];
        for (int i = 0; i < settings.length; i++) {
            S setting = settings[i];

            // ensure ordinal has been correctly implemented for the settings
            if (setting.ordinal() != i) {
                throw new IllegalArgumentException("The ordinal of setting " + setting + " does not equal its array index. ordinal=" + setting.ordinal() + ", index=" + i);
            }

            defaultStates[i] = (byte) setting.defaultState().ordinal();
        }

        return new SettingMapFactory<>(settings, states, defaultStates);
    }
Creates a new {@link SettingMapFactory} for the given {@link Setting}s and {@link Setting.State}s.

<p>Factories should ideally be cached (stored in a static field) in the
setting class.</p>

@param settings the settings
@param <S> the class type
@return a new factory
helper/src/main/java/me/lucko/helper/setting/SettingMapFactory.java