本文整理匯總了Java中org.apache.commons.lang3.ClassUtils.getPackageName方法的典型用法代碼示例。如果您正苦於以下問題:Java ClassUtils.getPackageName方法的具體用法?Java ClassUtils.getPackageName怎麽用?Java ClassUtils.getPackageName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.commons.lang3.ClassUtils
的用法示例。
在下文中一共展示了ClassUtils.getPackageName方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testEmptyMap
import org.apache.commons.lang3.ClassUtils; //導入方法依賴的package包/類
/**
* JAVADOC Method Level Comments
*/
@Test
public void testEmptyMap() {
InstanceFactory instanceFactory = new PackageBasedInstanceFactory(ClassUtils.getPackageName(
Foo.class));
SearchQueryGeneratorFactory factory = new SearchQueryGeneratorFactory(instanceFactory,
searchQueryGenerator, postProcessSearchQueryGenerator);
SearchBean sb = new SearchBean();
sb.setAliasByType(new LinkedHashMap<String, String>());
assertEquals(searchQueryGenerator, factory.getSearchQueryGenerator(sb));
}
示例2: onSetUp
import org.apache.commons.lang3.ClassUtils; //導入方法依賴的package包/類
/**
* Sets up for test
*/
@SuppressWarnings("unchecked")
@Before
public void onSetUp()
throws Exception {
queryGenerator = new JpaSearchQueryGenerator();
EntityManager entityManager = mock(EntityManager.class);
Metamodel mm = mock(Metamodel.class);
ManagedType<Baz> bazm = mock(ManagedType.class);
when(mm.managedType(Baz.class)).thenReturn(bazm);
ManagedType<Bar> barm = mock(ManagedType.class);
when(mm.managedType(Bar.class)).thenReturn(barm);
ManagedType<Foo> foom = mock(ManagedType.class);
when(mm.managedType(Foo.class)).thenReturn(foom);
when(entityManager.getMetamodel()).thenReturn(mm);
queryGenerator.setEntityManager(entityManager);
InstanceFactory instanceFactory = new PackageBasedInstanceFactory(ClassUtils.getPackageName(
Foo.class) + ".");
queryGenerator.setInstanceFactory(instanceFactory);
defaultAliasByType = new LinkedHashMap<String, String>();
defaultAliasByType.put(Foo.TYPE, FOO_ALIAS);
defaultTypeByAlias = new LinkedHashMap<String, String>();
defaultTypeByAlias.put(FOO_ALIAS, Foo.TYPE);
}
示例3: createsProjections
import org.apache.commons.lang3.ClassUtils; //導入方法依賴的package包/類
/**
* Projections are created as expected.
*/
@Test
public void createsProjections() {
Map<String, Object> params = new HashMap<String, Object>();
params.put(ProjectionPopulator.PROJECTIONS, PROJECTIONS_LIST);
ProjectionFactory factory = mock(ProjectionFactory.class);
when(factory.create(Bar.TYPE, "foo.id", null, BAR_ALIAS, null))
.thenReturn(new SimplePropertyProjection("foo.id", null, Bar.TYPE));
when(factory.create(Bar.TYPE, "foo.value", null, BAR_ALIAS, "max"))
.thenReturn(new MaxProjection("foo.value", null, Bar.TYPE));
when(factory.create(Foo.class.getSimpleName(), "name", null, HISTORY_ALIAS, null))
.thenReturn(new SimplePropertyProjection("baz.foo", null, Foo.class.getSimpleName()));
when(factory.create(Foo.class.getSimpleName(), "value", null, HISTORY_ALIAS, null))
.thenReturn(new SimplePropertyProjection("value", null, Baz.class.getSimpleName()));
populator = new ExpressionProjectionPopulator(new PackageBasedInstanceFactory(
ClassUtils.getPackageName(Bar.class)), factory, mock(SearchBeanFactory.class));
populator.populate(Bar.TYPE, bean, params);
assertEquals("Incorrect number of projections", 4, bean.getProjections().size());
assertNotNull("Should have created foo.id projection", bean.getProjection("foo.id"));
assertNotNull("Should have created foo.value projection", bean.getProjection("foo.value"));
assertNotNull("Should have created baz.foo projection", bean.getProjection("baz.foo"));
assertNotNull("Should have created value projection", bean.getProjection("value"));
}
示例4: noProjectionsList
import org.apache.commons.lang3.ClassUtils; //導入方法依賴的package包/類
/**
* No projectionslist provided so delegates to SearchBeanFactory. Test fixed 11/12/12 by AJ
*/
@Test
public void noProjectionsList() {
Map<String, Object> params = new HashMap<String, Object>();
SearchBeanFactory factory = mock(SearchBeanFactory.class);
populator = new ExpressionProjectionPopulator(new PackageBasedInstanceFactory(
ClassUtils.getPackageName(Bar.class)), mock(ProjectionFactory.class), factory);
populator.populate(Bar.TYPE, bean, params);
verify(factory).addProjections(Bar.TYPE, bean);
}
示例5: setup
import org.apache.commons.lang3.ClassUtils; //導入方法依賴的package包/類
/**
* Sets up for test.
*/
@Before
public void setup() {
populator = new ExpressionProjectionPopulator(new PackageBasedInstanceFactory(
ClassUtils.getPackageName(Bar.class)), mock(ProjectionFactory.class),
mock(SearchBeanFactory.class));
LinkedHashMap<String, String> aliasByType = new LinkedHashMap<String, String>();
aliasByType.put(Bar.TYPE, BAR_ALIAS);
aliasByType.put(Foo.class.getSimpleName(), HISTORY_ALIAS);
bean = new SearchBean();
bean.setAliasByType(aliasByType);
}
示例6: getPackageName
import org.apache.commons.lang3.ClassUtils; //導入方法依賴的package包/類
/**
* 返回PackageName
*/
public static String getPackageName(final Class<?> cls) {
return ClassUtils.getPackageName(cls);
}
示例7: setup
import org.apache.commons.lang3.ClassUtils; //導入方法依賴的package包/類
/**
* Sets up for test.
*/
@Before
public void setup() {
instanceFactory = new PackageBasedInstanceFactory(ClassUtils.getPackageName(Foo.class));
factory = new JpaProjectionFactory(instanceFactory);
}
示例8: instanceFactory
import org.apache.commons.lang3.ClassUtils; //導入方法依賴的package包/類
@Bean
public InstanceFactory instanceFactory() {
return new CompositeInstanceFactory(new PackageBasedInstanceFactory(
ClassUtils.getPackageName(Workflow.class)), new PackageBasedInstanceFactory(
ClassUtils.getPackageName(Attachment.class)));
}
示例9: canUse
import org.apache.commons.lang3.ClassUtils; //導入方法依賴的package包/類
public static boolean canUse(Constructor<?> c) {
if (c.isSynthetic()) {
return false;
}
// synthetic constructors are OK
if (Modifier.isAbstract(c.getDeclaringClass().getModifiers()))
return false;
// TODO we could enable some methods from Object, like getClass
//if (c.getDeclaringClass().equals(java.lang.Object.class))
// return false;// handled here to avoid printing reasons
if (c.getDeclaringClass().equals(java.lang.Thread.class))
return false;// handled here to avoid printing reasons
if (c.getDeclaringClass().isAnonymousClass())
return false;
if (c.getDeclaringClass().isLocalClass()) {
logger.debug("Skipping constructor of local class " + c.getName());
return false;
}
if (c.getDeclaringClass().isMemberClass() && !TestUsageChecker.canUse(c.getDeclaringClass()))
return false;
if (!Properties.USE_DEPRECATED && c.isAnnotationPresent(Deprecated.class)) {
final Class<?> targetClass = Properties.getTargetClassAndDontInitialise();
if(Properties.hasTargetClassBeenLoaded() && !c.getDeclaringClass().equals(targetClass)) {
logger.debug("Excluding deprecated constructor " + c.getName());
return false;
}
}
if (isForbiddenNonDeterministicCall(c)) {
return false;
}
if (Modifier.isPublic(c.getModifiers())) {
TestClusterUtils.makeAccessible(c);
return true;
}
for(java.lang.reflect.Type paramType : c.getGenericParameterTypes()) {
if(!canUse(paramType))
return false;
}
// If default access rights, then check if this class is in the same package as the target class
if (!Modifier.isPrivate(c.getModifiers())) {
// && !Modifier.isProtected(c.getModifiers())) {
String packageName = ClassUtils.getPackageName(c.getDeclaringClass());
if (packageName.equals(Properties.CLASS_PREFIX)) {
TestClusterUtils.makeAccessible(c);
return true;
}
}
return false;
}
示例10: canUse
import org.apache.commons.lang3.ClassUtils; //導入方法依賴的package包/類
/**
* This replicates TestUsageChecker.canUse but we need to avoid that
* we try to access Properties.getTargetClassAndDontInitialise
*
* @param f
* @return
*/
public static boolean canUse(Field f) {
if (f.getDeclaringClass().equals(java.lang.Object.class))
return false;// handled here to avoid printing reasons
if (f.getDeclaringClass().equals(java.lang.Thread.class))
return false;// handled here to avoid printing reasons
if (f.isSynthetic()) {
logger.debug("Skipping synthetic field " + f.getName());
return false;
}
if (f.getName().startsWith("ajc$")) {
logger.debug("Skipping AspectJ field " + f.getName());
return false;
}
// in, out, err
if(f.getDeclaringClass().equals(FileDescriptor.class)) {
return false;
}
if (Modifier.isPublic(f.getModifiers())) {
// It may still be the case that the field is defined in a non-visible superclass of the class
// we already know we can use. In that case, the compiler would be fine with accessing the
// field, but reflection would start complaining about IllegalAccess!
// Therefore, we set the field accessible to be on the safe side
TestClusterUtils.makeAccessible(f);
return true;
}
// If default access rights, then check if this class is in the same package as the target class
if (!Modifier.isPrivate(f.getModifiers())) {
String packageName = ClassUtils.getPackageName(f.getDeclaringClass());
if (packageName.equals(Properties.CLASS_PREFIX)) {
TestClusterUtils.makeAccessible(f);
return true;
}
}
return false;
}
示例11: instanceFactory
import org.apache.commons.lang3.ClassUtils; //導入方法依賴的package包/類
/**
* JAVADOC Method Level Comments
*
* @return JAVADOC.
*/
@Bean
public InstanceFactory instanceFactory() {
return new PackageBasedInstanceFactory(ClassUtils.getPackageName(Message.class));
}