// Path: src/main/java/org/tyrannyofheaven/bukkit/util/ToHStringUtils.java
// public static boolean hasText(String text) {
//     return text != null && text.trim().length() > 0;
// }


import static org.tyrannyofheaven.bukkit.util.ToHStringUtils.hasText;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/*
 * Copyright 2011 ZerothAngel <zerothangel@tyrannyofheaven.org>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.tyrannyofheaven.bukkit.util.command;



/**
 * Metadata for a command.
 * 
 * @author zerothangel
 */
final class CommandMetaData {

    private final Object handler;

    private final Method method;

    private final List<MethodParameter> parameters;

    private final String[] permissions;

    private final boolean requireAll;

    private final boolean checkNegations;

    private final String description;

    private final boolean hasRest;

    private final String rest;

    private final String completer;

    private final List<OptionMetaData> flagOptions;
    
    private final List<OptionMetaData> positionalArguments;

    /**
     * Create a CommandMetaData with the given arguments.
     * 
     * @param handler the handler object
     * @param method the associated method in the handler object
     * @param options method parameters
     * @param permissions required permissions, if any
     * @param requireAll true if all permissions are required
     */
    public CommandMetaData(Object handler, Method method, List<MethodParameter> options, String[] permissions, boolean requireAll, boolean checkNegations, String description, boolean hasRest, String rest, String completer) {
        if (handler == null)
            throw new IllegalArgumentException("handler cannot be null");
        if (method == null)
            throw new IllegalArgumentException("method cannot be null");
        
        if (options == null)
            options = Collections.emptyList();
        if (permissions == null)
            permissions = new String[0];
// Path: src/main/java/org/tyrannyofheaven/bukkit/util/ToHStringUtils.java
// public static boolean hasText(String text) {
//     return text != null && text.trim().length() > 0;
// }


// Path: src/main/java/org/tyrannyofheaven/bukkit/util/command/CommandMetaData.java
import static org.tyrannyofheaven.bukkit.util.ToHStringUtils.hasText;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/*
 * Copyright 2011 ZerothAngel <zerothangel@tyrannyofheaven.org>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.tyrannyofheaven.bukkit.util.command;



/**
 * Metadata for a command.
 * 
 * @author zerothangel
 */
final class CommandMetaData {

    private final Object handler;

    private final Method method;

    private final List<MethodParameter> parameters;

    private final String[] permissions;

    private final boolean requireAll;

    private final boolean checkNegations;

    private final String description;

    private final boolean hasRest;

    private final String rest;

    private final String completer;

    private final List<OptionMetaData> flagOptions;
    
    private final List<OptionMetaData> positionalArguments;

    /**
     * Create a CommandMetaData with the given arguments.
     * 
     * @param handler the handler object
     * @param method the associated method in the handler object
     * @param options method parameters
     * @param permissions required permissions, if any
     * @param requireAll true if all permissions are required
     */
    public CommandMetaData(Object handler, Method method, List<MethodParameter> options, String[] permissions, boolean requireAll, boolean checkNegations, String description, boolean hasRest, String rest, String completer) {
        if (handler == null)
            throw new IllegalArgumentException("handler cannot be null");
        if (method == null)
            throw new IllegalArgumentException("method cannot be null");
        
        if (options == null)
            options = Collections.emptyList();
        if (permissions == null)
            permissions = new String[0];
        if (!hasText(description))