0N/A/*
553N/A * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
553N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
553N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
553N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
553N/A * or visit www.oracle.com if you need additional information or have any
553N/A * questions.
0N/A */
0N/A
0N/Apackage javax.annotation.processing;
0N/A
0N/Aimport java.util.Arrays;
0N/A
0N/A/**
0N/A * Utility class for assembling {@link Completion} objects.
0N/A *
0N/A * @author Joseph D. Darcy
0N/A * @author Scott Seligman
0N/A * @author Peter von der Ahé
0N/A * @since 1.6
0N/A */
0N/Apublic class Completions {
0N/A // No instances for you.
0N/A private Completions() {}
0N/A
0N/A private static class SimpleCompletion implements Completion {
0N/A private String value;
0N/A private String message;
0N/A
0N/A SimpleCompletion(String value, String message) {
0N/A if (value == null || message == null)
0N/A throw new NullPointerException("Null completion strings not accepted.");
0N/A this.value = value;
0N/A this.message = message;
0N/A }
0N/A
0N/A public String getValue() {
0N/A return value;
0N/A }
0N/A
0N/A
0N/A public String getMessage() {
0N/A return message;
0N/A }
0N/A
0N/A @Override
0N/A public String toString() {
0N/A return "[\"" + value + "\", \"" + message + "\"]";
0N/A }
0N/A // Default equals and hashCode are fine.
0N/A }
0N/A
0N/A /**
0N/A * Returns a completion of the value and message.
0N/A *
0N/A * @param value the text of the completion
0N/A * @param message a message about the completion
0N/A * @return a completion of the provided value and message
0N/A */
0N/A public static Completion of(String value, String message) {
0N/A return new SimpleCompletion(value, message);
0N/A }
0N/A
0N/A /**
0N/A * Returns a completion of the value and an empty message
0N/A *
0N/A * @param value the text of the completion
0N/A * @return a completion of the value and an empty message
0N/A */
0N/A public static Completion of(String value) {
0N/A return new SimpleCompletion(value, "");
0N/A }
0N/A}