NamingPolicy.java revision 674060f01e9090cd21b3c5656cc3204912ad17a6
11b3afd1cab9087ca3c4e585d3da77d374d65c082mstarzinger@chromium.org/* 23484964a86451e86dcf04be9bd8c0d76ee04f081rossberg@chromium.org * Copyright 2003 The Apache Software Foundation 33484964a86451e86dcf04be9bd8c0d76ee04f081rossberg@chromium.org * 4cec079d8ed1f0920a0ea3dc9a3e81966013287c1whesse@chromium.org * Licensed under the Apache License, Version 2.0 (the "License"); 5cec079d8ed1f0920a0ea3dc9a3e81966013287c1whesse@chromium.org * you may not use this file except in compliance with the License. 6cec079d8ed1f0920a0ea3dc9a3e81966013287c1whesse@chromium.org * You may obtain a copy of the License at 7cec079d8ed1f0920a0ea3dc9a3e81966013287c1whesse@chromium.org * 8196eb601290dc49c3754da728dc58700dff2de1bmachenbach@chromium.org * http://www.apache.org/licenses/LICENSE-2.0 9cec079d8ed1f0920a0ea3dc9a3e81966013287c1whesse@chromium.org * 10cec079d8ed1f0920a0ea3dc9a3e81966013287c1whesse@chromium.org * Unless required by applicable law or agreed to in writing, software 11cec079d8ed1f0920a0ea3dc9a3e81966013287c1whesse@chromium.org * distributed under the License is distributed on an "AS IS" BASIS, 12cec079d8ed1f0920a0ea3dc9a3e81966013287c1whesse@chromium.org * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13cec079d8ed1f0920a0ea3dc9a3e81966013287c1whesse@chromium.org * See the License for the specific language governing permissions and 14e20e19efeef112c26d0e63b1e5118e695b42d855machenbach@chromium.org * limitations under the License. 15e20e19efeef112c26d0e63b1e5118e695b42d855machenbach@chromium.org */ 16cec079d8ed1f0920a0ea3dc9a3e81966013287c1whesse@chromium.orgpackage org.mockito.cglib.core; 17cec079d8ed1f0920a0ea3dc9a3e81966013287c1whesse@chromium.org 18cec079d8ed1f0920a0ea3dc9a3e81966013287c1whesse@chromium.orgimport java.util.Set; 19cec079d8ed1f0920a0ea3dc9a3e81966013287c1whesse@chromium.org 20cec079d8ed1f0920a0ea3dc9a3e81966013287c1whesse@chromium.org/** 21cec079d8ed1f0920a0ea3dc9a3e81966013287c1whesse@chromium.org * Customize the generated class name for {@link AbstractClassGenerator}-based utilities. 22cec079d8ed1f0920a0ea3dc9a3e81966013287c1whesse@chromium.org */ 23cec079d8ed1f0920a0ea3dc9a3e81966013287c1whesse@chromium.orgpublic interface NamingPolicy { 24cec079d8ed1f0920a0ea3dc9a3e81966013287c1whesse@chromium.org /** 25303ada708275d2d425b846fb237f1ba7598ee239lrn@chromium.org * Choose a name for a generated class. 26303ada708275d2d425b846fb237f1ba7598ee239lrn@chromium.org * @param prefix a dotted-name chosen by the generating class (possibly to put the generated class in a particular package) 27cec079d8ed1f0920a0ea3dc9a3e81966013287c1whesse@chromium.org * @param source the fully-qualified class name of the generating class (for example "org.mockito.cglib.Enhancer") 28cec079d8ed1f0920a0ea3dc9a3e81966013287c1whesse@chromium.org * @param key A key object representing the state of the parameters; for caching to work properly, equal keys should result 29cec079d8ed1f0920a0ea3dc9a3e81966013287c1whesse@chromium.org * in the same generated class name. The default policy incorporates <code>key.hashCode()</code> into the class name. 30cec079d8ed1f0920a0ea3dc9a3e81966013287c1whesse@chromium.org * @param names a predicate that returns true if the given classname has already been used in the same ClassLoader. 31303ada708275d2d425b846fb237f1ba7598ee239lrn@chromium.org * @return the fully-qualified class name 32303ada708275d2d425b846fb237f1ba7598ee239lrn@chromium.org */ 33cec079d8ed1f0920a0ea3dc9a3e81966013287c1whesse@chromium.org String getClassName(String prefix, String source, Object key, Predicate names); 3401fe7df37ce9858e3d0069ec6a2d7c667256b95aager@chromium.org 3501fe7df37ce9858e3d0069ec6a2d7c667256b95aager@chromium.org /** 36cec079d8ed1f0920a0ea3dc9a3e81966013287c1whesse@chromium.org * The <code>NamingPolicy</code> in use does not currently, but may 37e3c177a423baa3c30225c4e422b6f6c76d38b951machenbach@chromium.org * in the future, affect the caching of classes generated by {@link 38e3c177a423baa3c30225c4e422b6f6c76d38b951machenbach@chromium.org * AbstractClassGenerator}, so this is a reminder that you should 39cec079d8ed1f0920a0ea3dc9a3e81966013287c1whesse@chromium.org * correctly implement <code>equals</code> and <code>hashCode</code> 40cec079d8ed1f0920a0ea3dc9a3e81966013287c1whesse@chromium.org * to avoid generating too many classes. 41cec079d8ed1f0920a0ea3dc9a3e81966013287c1whesse@chromium.org */ 4201fe7df37ce9858e3d0069ec6a2d7c667256b95aager@chromium.org boolean equals(Object o); 43cec079d8ed1f0920a0ea3dc9a3e81966013287c1whesse@chromium.org} 44e3c177a423baa3c30225c4e422b6f6c76d38b951machenbach@chromium.org