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

javarepl.completion.CompletionCandidate Maven / Gradle / Ivy

There is a newer version: 431
Show newest version
package javarepl.completion;

import com.googlecode.totallylazy.Sequence;
import com.googlecode.totallylazy.functions.Function1;

import static com.googlecode.totallylazy.Sequences.sequence;

public class CompletionCandidate {
    private final String value;
    private final Sequence forms;

    public CompletionCandidate(String value, Sequence forms) {
        this.value = value;
        this.forms = forms;
    }

    public String value() {
        return value;
    }

    public Sequence forms() {
        return forms;
    }

    @Override
    public String toString() {
        return value + forms.toString(" (", ", ", ")");
    }


    @Override
    public int hashCode() {
        return (value != null ? value.hashCode() : 0) +
                (forms != null ? forms.hashCode() : 0);
    }


    @Override
    public boolean equals(Object other) {
        return other instanceof CompletionCandidate &&
                other.getClass().equals(getClass()) &&
                (value != null && value.equals(((CompletionCandidate) other).value)) &&
                (forms != null && forms.equals(((CompletionCandidate) other).forms));
    }

    public static Function1 asCompletionCandidate() {
        return candidate -> new CompletionCandidate(candidate, sequence(candidate));
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy