当前位置: 首页>>代码示例>>Java>>正文


Java ClassUtils.getPackageName方法代码示例

本文整理汇总了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));
}
 
开发者ID:cucina,项目名称:opencucina,代码行数:16,代码来源:SearchQueryGeneratorFactoryTest.java

示例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);
}
 
开发者ID:cucina,项目名称:opencucina,代码行数:38,代码来源:JpaSearchQueryGeneratorTest.java

示例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"));
}
 
开发者ID:cucina,项目名称:opencucina,代码行数:32,代码来源:ExpressionProjectionPopulatorTest.java

示例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);
}
 
开发者ID:cucina,项目名称:opencucina,代码行数:15,代码来源:ExpressionProjectionPopulatorTest.java

示例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);
}
 
开发者ID:cucina,项目名称:opencucina,代码行数:18,代码来源:ExpressionProjectionPopulatorTest.java

示例6: getPackageName

import org.apache.commons.lang3.ClassUtils; //导入方法依赖的package包/类
/**
 * 返回PackageName
 */
public static String getPackageName(final Class<?> cls) {
	return ClassUtils.getPackageName(cls);
}
 
开发者ID:zhangjunfang,项目名称:util,代码行数:7,代码来源:ClassUtil.java

示例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);
}
 
开发者ID:cucina,项目名称:opencucina,代码行数:9,代码来源:JpaProjectionFactoryTest.java

示例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)));
}
 
开发者ID:cucina,项目名称:opencucina,代码行数:7,代码来源:ProcessConfiguration.java

示例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;
	}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:63,代码来源:TestUsageChecker.java

示例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;
}
 
开发者ID:EvoSuite,项目名称:evosuite,代码行数:52,代码来源:ReplaceVariable.java

示例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));
}
 
开发者ID:cucina,项目名称:opencucina,代码行数:10,代码来源:I18nApplication.java


注:本文中的org.apache.commons.lang3.ClassUtils.getPackageName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。