001/* 
002 * JKNIV, whinstone one contract to access your database.
003 * 
004 * Copyright (C) 2017, the original author or authors.
005 *
006 * This library is free software; you can redistribute it and/or
007 * modify it under the terms of the GNU Lesser General Public
008 * License as published by the Free Software Foundation; either
009 * version 2.1 of the License.
010 * 
011 * This library is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014 * Lesser General Public License for more details.
015 * 
016 * You should have received a copy of the GNU Lesser General Public
017 * License along with this library; if not, write to the Free Software Foundation, Inc., 
018 * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
019 */
020package net.sf.jkniv.whinstone.commands;
021
022import net.sf.jkniv.exception.HandleableException;
023import net.sf.jkniv.sqlegance.Sql;
024import net.sf.jkniv.sqlegance.SqlType;
025import net.sf.jkniv.sqlegance.builder.RepositoryConfig;
026import net.sf.jkniv.whinstone.Queryable;
027import net.sf.jkniv.whinstone.ResultRow;
028
029/**
030 * Dummy/Empty implementation for {@link CommandHandler}
031 * 
032 * @author Alisson Gomes
033 * @since 0.6.0
034 *
035 */
036public class NoCommandHandler implements CommandHandler
037{
038    private static final CommandHandler NO_COMMAND_HANDLER = new NoCommandHandler();
039    
040    public static CommandHandler getInstance()
041    {
042        return NO_COMMAND_HANDLER;
043    }
044    
045    private NoCommandHandler() { }
046    
047//    @Override
048//    public CommandHandler with(CommandHandler handler)
049//    {
050//        return this;
051//    }
052    
053    @Override
054    public CommandHandler with(ResultRow<?, ?> overloadResultRow)
055    {
056        return this;
057    }
058    
059    @Override
060    public CommandHandler with(Queryable queryable)
061    {
062        return this;
063    }
064    
065    @Override
066    public CommandHandler with(Sql sql)
067    {
068        return this;
069    }
070    
071//    @Override
072//    public CommandHandler with(RepositoryConfig repositoryConfig)
073//    {
074//        return this;
075//    }
076    
077    @Override
078    public CommandHandler with(HandleableException handlerException)
079    {
080        return this;
081    }
082    
083    @Override
084    public Command asCommand()
085    {
086        return NoCommand.getInstance();
087    }
088    
089    @Override
090    public CommandHandler preCallback()
091    {
092        return this;
093    }
094    
095    @Override
096    public CommandHandler postCallback()
097    {
098        return this;
099    }
100    
101    @Override
102    public CommandHandler postCommit()
103    {
104        return this;
105    }
106    
107    @Override
108    public CommandHandler postException()
109    {
110        return this;
111    }
112    
113    @Override
114    public <T> T run()
115    {
116        return null;
117    }
118 
119    @Override
120    public CommandHandler checkSqlType(SqlType expected)
121    {
122        return this;
123    }
124}