// Path: src/main/java/clientapi/command/executor/ExecutionContext.java
// public interface ExecutionContext {
// 
//     /**
//      * @return The {@link CommandSender} responsible for the command execution
//      */
//     CommandSender sender();
// 
//     /**
//      * @return The {@link CommandHandler} that carried out command execution
//      */
//     CommandHandler handler();
// 
//     static ExecutionContext of(CommandSender sender, CommandHandler handler) {
//         return new Impl(sender, handler);
//     }
// 
//     /**
//      * Implementation of {@link ExecutionContext}, used when
//      * creating an instance of {@link ExecutionContext}
//      * from {@link ExecutionContext#of(CommandSender, CommandHandler)}
//      *
//      * @see ExecutionContext#of(CommandSender, CommandHandler)
//      */
//     class Impl implements ExecutionContext {
// 
//         /**
//          * {@link CommandSender} responsible for command execution
//          */
//         private final CommandSender sender;
// 
//         /**
//          * {@link CommandHandler} that carried out command execution
//          */
//         private final CommandHandler handler;
// 
//         private Impl(CommandSender sender, CommandHandler handler) {
//             this.sender = sender;
//             this.handler = handler;
//         }
// 
//         @Override
//         public CommandSender sender() {
//             return this.sender;
//         }
// 
//         @Override
//         public CommandHandler handler() {
//             return this.handler;
//         }
//     }
// }


import clientapi.command.executor.ExecutionContext;
import clientapi.command.executor.parser.ArgumentParser;
import java.lang.reflect.Type;
/*
 * Copyright 2018 ImpactDevelopment
 *
 * 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 clientapi.command.executor.parser.impl;



/**
 * @author Brady
 * @since 10/20/2017
 */
public final class CharParser implements ArgumentParser<Character> {

    @Override
    public final Character parse(ExecutionContext context, Type type, String raw) {
        if (raw.length() == 1) {
            return raw.charAt(0);
        }
        return null;
    }

    @Override
    public final boolean isTarget(Type type) {
// Path: src/main/java/clientapi/command/executor/ExecutionContext.java
// public interface ExecutionContext {
// 
//     /**
//      * @return The {@link CommandSender} responsible for the command execution
//      */
//     CommandSender sender();
// 
//     /**
//      * @return The {@link CommandHandler} that carried out command execution
//      */
//     CommandHandler handler();
// 
//     static ExecutionContext of(CommandSender sender, CommandHandler handler) {
//         return new Impl(sender, handler);
//     }
// 
//     /**
//      * Implementation of {@link ExecutionContext}, used when
//      * creating an instance of {@link ExecutionContext}
//      * from {@link ExecutionContext#of(CommandSender, CommandHandler)}
//      *
//      * @see ExecutionContext#of(CommandSender, CommandHandler)
//      */
//     class Impl implements ExecutionContext {
// 
//         /**
//          * {@link CommandSender} responsible for command execution
//          */
//         private final CommandSender sender;
// 
//         /**
//          * {@link CommandHandler} that carried out command execution
//          */
//         private final CommandHandler handler;
// 
//         private Impl(CommandSender sender, CommandHandler handler) {
//             this.sender = sender;
//             this.handler = handler;
//         }
// 
//         @Override
//         public CommandSender sender() {
//             return this.sender;
//         }
// 
//         @Override
//         public CommandHandler handler() {
//             return this.handler;
//         }
//     }
// }


// Path: src/main/java/clientapi/command/executor/parser/impl/CharParser.java
import clientapi.command.executor.ExecutionContext;
import clientapi.command.executor.parser.ArgumentParser;
import java.lang.reflect.Type;

/*
 * Copyright 2018 ImpactDevelopment
 *
 * 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 clientapi.command.executor.parser.impl;



/**
 * @author Brady
 * @since 10/20/2017
 */
public final class CharParser implements ArgumentParser<Character> {

    @Override
    public final Character parse(ExecutionContext context, Type type, String raw) {
        if (raw.length() == 1) {
            return raw.charAt(0);
        }
        return null;
    }

    @Override
    public final boolean isTarget(Type type) {
        return type instanceof Class && (Character.class.isAssignableFrom((Class) type) || Character.TYPE.isAssignableFrom((Class) type));