List of usage examples for org.apache.commons.lang ArrayUtils EMPTY_OBJECT_ARRAY
Object[] EMPTY_OBJECT_ARRAY
To view the source code for org.apache.commons.lang ArrayUtils EMPTY_OBJECT_ARRAY.
Click Source Link
Object
array. From source file:org.eclipse.wb.tests.designer.core.databinding.ObjectsTreeContentProviderTest.java
public void test_input() throws Exception { ObjectsTreeContentProvider provider = new ObjectsTreeContentProvider(); ///* ww w. j av a 2 s . com*/ assertSame(ArrayUtils.EMPTY_OBJECT_ARRAY, provider.getElements(null)); assertSame(ArrayUtils.EMPTY_OBJECT_ARRAY, provider.getElements("test")); // TestObjectInfo testObject = new TestObjectInfo("testObject"); // Assertions.assertThat(provider.getElements(new Object[] { testObject })).containsOnly(testObject); // List<TestObjectInfo> input = new ArrayList<TestObjectInfo>(); input.add(testObject); Assertions.assertThat(provider.getElements(input)).containsOnly(testObject); // TestObjectInfo childObject = new TestObjectInfo("childObject"); testObject.addChild(childObject); // Assertions.assertThat(provider.getElements(testObject)).containsOnly(childObject); // not used provider.inputChanged(null, null, null); provider.dispose(); }
From source file:org.eclipse.wb.tests.designer.core.databinding.ObjectsTreeContentProviderTest.java
public void test_getChildren() throws Exception { ObjectsTreeContentProvider provider = new ObjectsTreeContentProvider(); ////ww w . jav a 2 s .com assertSame(ArrayUtils.EMPTY_OBJECT_ARRAY, provider.getChildren(null)); assertSame(ArrayUtils.EMPTY_OBJECT_ARRAY, provider.getChildren("test")); // TestObjectInfo testObject = new TestObjectInfo("testObject"); // Assertions.assertThat(provider.getChildren(testObject)).isNotNull().isEmpty(); // TestObjectInfo childObject = new TestObjectInfo("childObject"); testObject.addChild(childObject); // Assertions.assertThat(provider.getChildren(testObject)).containsOnly(childObject); }
From source file:org.eclipse.wb.tests.designer.editor.UndoManagerTest.java
/** * Test that when we select component, its parent become expanded. *//*from www . j a va 2s .c o m*/ public void test_expandOnSelection() throws Exception { ContainerInfo frame = openContainer("// filler filler filler", "public class Test extends JFrame {", " public Test() {", " }", "}"); ContainerInfo contentPane = (ContainerInfo) frame.getChildrenComponents().get(0); IComponentsTree componentTree = DesignPageSite.Helper.getSite(frame).getComponentTree(); // collapse all { componentTree.setExpandedElements(ArrayUtils.EMPTY_OBJECT_ARRAY); assertEquals(0, componentTree.getExpandedElements().length); } // select "contentPane", "frame" should be expanded { canvas.select(contentPane); assertExpandedComponents(frame); } }
From source file:org.jboss.as.test.integration.domain.rbac.JmxRBACProviderHostScopedRolesTestCase.java
private void doOperation(boolean successExpected, String objectName, String operationName, JmxManagementInterface jmx) throws Exception { MBeanServerConnection connection = jmx.getConnection(); ObjectName domain = new ObjectName(objectName); try {//from w w w .j av a2 s. co m connection.invoke(domain, operationName, ArrayUtils.EMPTY_OBJECT_ARRAY, ArrayUtils.EMPTY_STRING_ARRAY); assertTrue("Failure was expected but success happened", successExpected); } catch (JMRuntimeException e) { if (e.getMessage().contains("WFLYJMX0037")) { assertFalse("Success was expected but failure happened: " + e, successExpected); } else { throw e; } } }
From source file:org.jboss.as.test.integration.mgmt.access.AbstractJmxNonCoreMBeansSensitivityTestCase.java
private void doOperation(boolean successExpected, String operationName, JmxManagementInterface jmx) throws Exception { MBeanServerConnection connection = jmx.getConnection(); ObjectName domain = new ObjectName("jboss.test:service=testdeployments"); try {/* w w w . j ava 2s. c o m*/ connection.invoke(domain, operationName, ArrayUtils.EMPTY_OBJECT_ARRAY, ArrayUtils.EMPTY_STRING_ARRAY); assertTrue("Failure was expected but success happened", successExpected); } catch (JMRuntimeException e) { if (e.getMessage().contains("WFLYJMX0037")) { assertFalse("Success was expected but failure happened: " + e, successExpected); } else { throw e; } } }
From source file:org.jdto.util.MethodUtils.java
/** * <p>Invoke a named method whose parameter type matches the object * type.</p>/*from w ww .j ava 2 s.co m*/ * * <p>This method delegates the method search to {@link #getMatchingAccessibleMethod(Class, String, Class[])}.</p> * * <p>This method supports calls to methods taking primitive parameters via * passing in wrapping classes. So, for example, a * <code>Boolean</code> object would match a * <code>boolean</code> primitive.</p> * * <p> This is a convenient wrapper for * {@link #invokeMethod(Object object,String methodName, Object[] args, Class[] parameterTypes)}. * </p> * * @param object invoke method on this object * @param methodName get method with this name * @param args use these arguments - treat null as empty array * @return The value returned by the invoked method * * @throws NoSuchMethodException if there is no such accessible method * @throws InvocationTargetException wraps an exception thrown by the method * invoked * @throws IllegalAccessException if the requested method is not accessible * via reflection */ public static Object invokeMethod(Object object, String methodName, Object[] args) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { if (args == null) { args = ArrayUtils.EMPTY_OBJECT_ARRAY; } int arguments = args.length; Class[] parameterTypes = new Class[arguments]; for (int i = 0; i < arguments; i++) { parameterTypes[i] = args[i].getClass(); } return invokeMethod(object, methodName, args, parameterTypes); }
From source file:org.jdto.util.MethodUtils.java
/** * <p>Invoke a named method whose parameter type matches the object * type.</p>// w w w . j av a2 s . c om * * <p>This method delegates the method search to {@link #getMatchingAccessibleMethod(Class, String, Class[])}.</p> * * <p>This method supports calls to methods taking primitive parameters via * passing in wrapping classes. So, for example, a * <code>Boolean</code> object would match a * <code>boolean</code> primitive.</p> * * @param object invoke method on this object * @param methodName get method with this name * @param args use these arguments - treat null as empty array * @param parameterTypes match these parameters - treat null as empty array * @return The value returned by the invoked method * * @throws NoSuchMethodException if there is no such accessible method * @throws InvocationTargetException wraps an exception thrown by the method * invoked * @throws IllegalAccessException if the requested method is not accessible * via reflection */ public static Object invokeMethod(Object object, String methodName, Object[] args, Class[] parameterTypes) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { if (parameterTypes == null) { parameterTypes = ArrayUtils.EMPTY_CLASS_ARRAY; } if (args == null) { args = ArrayUtils.EMPTY_OBJECT_ARRAY; } Method method = getMatchingAccessibleMethod(object.getClass(), methodName, parameterTypes); if (method == null) { throw new NoSuchMethodException( "No such accessible method: " + methodName + "() on object: " + object.getClass().getName()); } return method.invoke(object, args); }
From source file:org.jdto.util.MethodUtils.java
/** * <p>Invoke a named static method whose parameter type matches the object * type.</p>//from ww w. ja v a 2s .co m * * <p>This method delegates the method search to {@link #getMatchingAccessibleMethod(Class, String, Class[])}.</p> * * <p>This method supports calls to methods taking primitive parameters via * passing in wrapping classes. So, for example, a * <code>Boolean</code> class would match a * <code>boolean</code> primitive.</p> * * <p> This is a convenient wrapper for * {@link #invokeStaticMethod(Class objectClass,String methodName,Object [] args,Class[] parameterTypes)}. * </p> * * @param cls invoke static method on this class * @param methodName get method with this name * @param args use these arguments - treat null as empty array * @return The value returned by the invoked method * * @throws NoSuchMethodException if there is no such accessible method * @throws InvocationTargetException wraps an exception thrown by the method * invoked * @throws IllegalAccessException if the requested method is not accessible * via reflection */ public static Object invokeStaticMethod(Class cls, String methodName, Object[] args) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { if (args == null) { args = ArrayUtils.EMPTY_OBJECT_ARRAY; } int arguments = args.length; Class[] parameterTypes = new Class[arguments]; for (int i = 0; i < arguments; i++) { parameterTypes[i] = args[i].getClass(); } return invokeStaticMethod(cls, methodName, args, parameterTypes); }
From source file:org.jdto.util.MethodUtils.java
/** * <p>Invoke a named static method whose parameter type matches the object * type.</p>/* w ww .j a v a 2 s .c o m*/ * * <p>This method delegates the method search to {@link #getMatchingAccessibleMethod(Class, String, Class[])}.</p> * * <p>This method supports calls to methods taking primitive parameters via * passing in wrapping classes. So, for example, a * <code>Boolean</code> class would match a * <code>boolean</code> primitive.</p> * * * @param cls invoke static method on this class * @param methodName get method with this name * @param args use these arguments - treat null as empty array * @param parameterTypes match these parameters - treat null as empty array * @return The value returned by the invoked method * * @throws NoSuchMethodException if there is no such accessible method * @throws InvocationTargetException wraps an exception thrown by the method * invoked * @throws IllegalAccessException if the requested method is not accessible * via reflection */ public static Object invokeStaticMethod(Class cls, String methodName, Object[] args, Class[] parameterTypes) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { if (parameterTypes == null) { parameterTypes = ArrayUtils.EMPTY_CLASS_ARRAY; } if (args == null) { args = ArrayUtils.EMPTY_OBJECT_ARRAY; } Method method = getMatchingAccessibleMethod(cls, methodName, parameterTypes); if (method == null) { throw new NoSuchMethodException( "No such accessible method: " + methodName + "() on class: " + cls.getName()); } return method.invoke(null, args); }
From source file:org.jnap.core.persistence.hibernate.DynaQueryBuilder.java
/** * /*from w ww . j a v a 2 s . com*/ * @param session * @param entityName * @param dynaQuery * @param queryParams */ public DynaQueryBuilder(Session session, String entityName, String dynaQuery, Object... queryParams) { Assert.notNull(session); Assert.hasText(entityName); Assert.hasText(dynaQuery); this.session = session; this.entityName = entityName; this.dynaQuery = dynaQuery; this.queryParams = queryParams == null ? ArrayUtils.EMPTY_OBJECT_ARRAY : queryParams; this.entityMetadata = this.session.getSessionFactory().getClassMetadata(this.entityName); buildCriterionBuilderStrategy(); }