001/* 002 * JKNIV, SQLegance keeping queries maintainable. 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.sqlegance; 021 022/** 023 * <p> 024 * A set of rules for determining the query name to a set of methods (get, list, 025 * add, remove, update) from Repository that don't have a query object as 026 * parameter. To change the strategy implements this interface and configure at 027 * persistence.xml one property called <code>jkniv.repository.query_namestrategy</code>. 028 * 029 * <p> 030 * Sample: 031 * 032 * <pre> 033 * <properties> 034 * <property name="jkniv.repository.query_namestrategy" value="com.acme.MyQueryNameStrategy" /> 035 * </properties> 036 * </pre> 037 * 038 * @author Alisson Gomes 039 * @since 0.5.0 040 */ 041public interface QueryNameStrategy 042{ 043 //public static String PROPERTY_NAME_STRATEGY = "jkniv.repository.namestrategy"; 044 045 /** 046 * Return the default query name at XML file to retrieve an object by 'get' 047 * method. 048 * 049 * @param o 050 * instance of object that will be persisted 051 * @return name of query method 052 */ 053 String toGetName(Object o); 054 055 /** 056 * Return the default query name at XML file to retrieve an object by 'add' 057 * method. 058 * 059 * @param o 060 * instance of object that will be persisted 061 * @return name of query method 062 */ 063 String toAddName(Object o); 064 065 /** 066 * Return the default query name at XML file to retrieve an object by 067 * 'remove' method. 068 * 069 * @param o 070 * instance of object that will be persisted 071 * @return name of query method 072 */ 073 String toRemoveName(Object o); 074 075 /** 076 * Return the default query name at XML file to retrieve an object by 077 * 'update' method. 078 * 079 * @param o 080 * instance of object that will be persisted 081 * @return name of query method 082 */ 083 String toUpdateName(Object o); 084 085 /** 086 * Return the default query name at XML file to retrieve an object by 'list' 087 * method. 088 * 089 * @param o 090 * instance of object that will be persisted 091 * @return name of query method 092 */ 093 String toListName(Object o); 094}