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;
021
022/**
023 * Enumeration for possible scope of execution from callback methods.
024 */
025public enum CallbackScope
026{
027    /**
028     * Value that means that a callback method is invoked 
029     * before {@code add} {@link Repository#add(Queryable)}
030     * or {@link Repository#add(Object)} methods
031     */
032    ADD,
033    /**
034     * Value that means that a callback method is invoked 
035     * before {@code update} {@link Repository#update(Queryable)}
036     * or {@link Repository#update(Object)} methods
037     */
038    UPDATE,
039    /**
040     * Value that means that a callback method is invoked 
041     * before {@code remove} {@link Repository#remove(Queryable)}
042     * or {@link Repository#remove(Object)} methods
043     */
044    REMOVE,
045    /**
046     * Value that means that a callback method is invoked 
047     * before {@code get} and {@code list} methods
048     * like: {@link Repository#get(Queryable)}, 
049     * {@link Repository#get(Object)}, {@link Repository#list(Queryable)}
050     * etc.
051     */
052    SELECT,
053    /**
054     * Value that means that a callback method is invoked 
055     * after all columns from a tuple are setted with all select 
056     * methods like: {@link Repository#list(Queryable)}, {@link Repository#get(Queryable)}
057     */
058    /*
059    LOAD,
060    /**
061     * Value that means that a callback method is invoked 
062     * after an successful {@code COMMIT} is execute, this annotation
063     * must be followed with another scope like {@code ADD}, 
064     * {@code UPDATE}, {@code REMOVE} or {@code SELECT}.
065     *
066    COMMIT,
067    /**
068     * Value that means that a callback method is invoked 
069     * after an {@code exception} is generate, this annotation
070     * must be followed with another scope like {@code ADD}, 
071     * {@code UPDATE}, {@code REMOVE} or {@code SELECT}.
072     *
073    EXCEPTION,
074    */
075    /**
076     * Value that indicates that no callback method is invoked.
077     */
078    NONE;
079    
080    public boolean isAdd()
081    {
082        return (this == ADD ? true : false);
083    }
084    
085    public boolean isUpdate()
086    {
087        return (this == UPDATE ? true : false);
088    }
089    
090    public boolean isRemove()
091    {
092        return (this == REMOVE ? true : false);
093    }
094    
095    public boolean isSelect()
096    {
097        return (this == SELECT ? true : false);
098    }
099    /*
100    public boolean isException()
101    {
102        return (this == CallbackScope.EXCEPTION ? true : false);
103    }
104    
105    public boolean isCommit()
106    {
107        return (this == COMMIT ? true : false);
108    }
109
110    public boolean isLoad()
111    {
112        return (this == LOAD ? true : false);
113    }
114    */
115    
116}