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

org.jline.style.StyleResolver 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.
 *
 * https://opensource.org/licenses/BSD-3-Clause
 */
package org.jline.style;

import org.jline.utils.AttributedStyle;

import static java.util.Objects.requireNonNull;

// TODO: document style specification

/**
 * Resolves named (or source-referenced) {@link AttributedStyle}.
 *
 * @since 3.4
 */
public class StyleResolver extends org.jline.utils.StyleResolver {

    private final StyleSource source;

    private final String group;

    public StyleResolver(final StyleSource source, final String group) {
        super(s -> source.get(group, s));
        this.source = requireNonNull(source);
        this.group = requireNonNull(group);
    }

    public StyleSource getSource() {
        return source;
    }

    // TODO: could consider a small cache to reduce style calculations?

    public String getGroup() {
        return group;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy