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

org.jline.style.NopStyleSource Maven / Gradle / Ivy

There is a newer version: 3.26.3
Show newest version
/*
 * Copyright (c) 2002-2017, the original author or authors.
 *
 * This software is distributable under the BSD license. See the terms of the
 * BSD license in the documentation provided with this software.
 *
 * http://www.opensource.org/licenses/bsd-license.php
 */
package org.jline.style;

import javax.annotation.Nullable;
import java.util.Collections;
import java.util.Map;

import static java.util.Objects.requireNonNull;

/**
 * {@link StyleSource} which always returns {@code null}.
 *
 * @since 3.4
 */
public class NopStyleSource
        implements StyleSource {
    // NOTE: preconditions here to help validate usage when this impl is used

    /**
     * Always returns {@code null}.
     */
    @Nullable
    @Override
    public String get(final String group, final String name) {
        requireNonNull(group);
        requireNonNull(name);
        return null;
    }

    /**
     * Non-operation.
     */
    @Override
    public void set(final String group, final String name, final String style) {
        requireNonNull(group);
        requireNonNull(name);
        requireNonNull(style);
    }

    /**
     * Non-operation.
     */
    @Override
    public void remove(final String group) {
        requireNonNull(group);
    }

    /**
     * Non-operation.
     */
    @Override
    public void remove(final String group, final String name) {
        requireNonNull(group);
        requireNonNull(name);
    }

    /**
     * Non-operation.
     */
    @Override
    public void clear() {
        // empty
    }

    /**
     * Always returns empty list.
     */
    @Override
    public Iterable groups() {
        return Collections.unmodifiableList(Collections.emptyList());
    }

    /**
     * Always returns empty map.
     */
    @Override
    public Map styles(final String group) {
        return Collections.unmodifiableMap(Collections.emptyMap());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy