private static List<Filter> initFilterList(Servlet servlet, Filter... filters) { Filter[] allFilters = ObjectUtils.addObjectToArray(filters, new ServletFilterProxy(servlet)); return Arrays.asList(allFilters); }
@Override public void visit(String attributeName, Object attributeValue) { Object newValue = attributeValue; Object existingValue = this.attributes.get(this.attributeName); if (existingValue != null) { newValue = ObjectUtils.addObjectToArray((Object[]) existingValue, newValue); } else { Class<?> arrayClass = newValue.getClass(); if (Enum.class.isAssignableFrom(arrayClass)) { while (arrayClass.getSuperclass() != null && !arrayClass.isEnum()) { arrayClass = arrayClass.getSuperclass(); } } Object[] newArray = (Object[]) Array.newInstance(arrayClass, 1); newArray[0] = newValue; newValue = newArray; } this.attributes.put(this.attributeName, newValue); }
private static List<Filter> initFilterList(Servlet servlet, Filter... filters) { Filter[] allFilters = ObjectUtils.addObjectToArray(filters, new ServletFilterProxy(servlet)); return Arrays.asList(allFilters); }
@Override public void visit(String attributeName, Object attributeValue) { Object newValue = attributeValue; Object existingValue = this.attributes.get(this.attributeName); if (existingValue != null) { newValue = ObjectUtils.addObjectToArray((Object[]) existingValue, newValue); } else { Class<?> arrayClass = newValue.getClass(); if (Enum.class.isAssignableFrom(arrayClass)) { while (arrayClass.getSuperclass() != null && !arrayClass.isEnum()) { arrayClass = arrayClass.getSuperclass(); } } Object[] newArray = (Object[]) Array.newInstance(arrayClass, 1); newArray[0] = newValue; newValue = newArray; } this.attributes.put(this.attributeName, newValue); }
private static List<Filter> initFilterList(Servlet servlet, Filter... filters) { Filter[] allFilters = ObjectUtils.addObjectToArray(filters, new ServletFilterProxy(servlet)); return Arrays.asList(allFilters); }
/** * Append the specified bean name to the list of beans that this definition * depends on. */ public BeanDefinitionBuilder addDependsOn(String beanName) { if (this.beanDefinition.getDependsOn() == null) { this.beanDefinition.setDependsOn(beanName); } else { String[] added = ObjectUtils.addObjectToArray(this.beanDefinition.getDependsOn(), beanName); this.beanDefinition.setDependsOn(added); } return this; }
@Test public void addNullObjectToNullArray() throws Exception { Object[] newArray = ObjectUtils.addObjectToArray(null, null); assertEquals(1, newArray.length); assertEquals(null, newArray[0]); }
@Test public void addObjectToArraySunnyDay() { String[] array = new String[] {"foo", "bar"}; String newElement = "baz"; Object[] newArray = ObjectUtils.addObjectToArray(array, newElement); assertEquals(3, newArray.length); assertEquals(newElement, newArray[2]); }
/** * Append the specified bean name to the list of beans that this definition * depends on. */ public BeanDefinitionBuilder addDependsOn(String beanName) { if (this.beanDefinition.getDependsOn() == null) { this.beanDefinition.setDependsOn(beanName); } else { String[] added = ObjectUtils.addObjectToArray(this.beanDefinition.getDependsOn(), beanName); this.beanDefinition.setDependsOn(added); } return this; }
@Test public void addObjectToNullArray() throws Exception { String newElement = "foo"; String[] newArray = ObjectUtils.addObjectToArray(null, newElement); assertEquals(1, newArray.length); assertEquals(newElement, newArray[0]); }
@Test public void addObjectToArrayWhenEmpty() { String[] array = new String[0]; String newElement = "foo"; String[] newArray = ObjectUtils.addObjectToArray(array, newElement); assertEquals(1, newArray.length); assertEquals(newElement, newArray[0]); }
@Test public void addObjectToSingleNullElementArray() { String[] array = new String[] {null}; String newElement = "bar"; String[] newArray = ObjectUtils.addObjectToArray(array, newElement); assertEquals(2, newArray.length); assertEquals(null, newArray[0]); assertEquals(newElement, newArray[1]); }
@Test public void addObjectToSingleNonNullElementArray() { String existingElement = "foo"; String[] array = new String[] {existingElement}; String newElement = "bar"; String[] newArray = ObjectUtils.addObjectToArray(array, newElement); assertEquals(2, newArray.length); assertEquals(existingElement, newArray[0]); assertEquals(newElement, newArray[1]); }
if (scriptFactory.requiresConfigInterface() && !bd.getPropertyValues().isEmpty()) { Class<?> configInterface = createConfigInterface(bd, interfaces); scriptedInterfaces = ObjectUtils.addObjectToArray(interfaces, configInterface);
if (scriptFactory.requiresConfigInterface() && !bd.getPropertyValues().isEmpty()) { Class<?> configInterface = createConfigInterface(bd, interfaces); scriptedInterfaces = ObjectUtils.addObjectToArray(interfaces, configInterface);
@Override public void visit(String attributeName, Object attributeValue) { Object newValue = attributeValue; Object existingValue = this.attributes.get(this.attributeName); if (existingValue != null) { newValue = ObjectUtils.addObjectToArray((Object[]) existingValue, newValue); } else { Object[] newArray = (Object[]) Array.newInstance(newValue.getClass(), 1); newArray[0] = newValue; newValue = newArray; } this.attributes.put(this.attributeName, newValue); }
/** * Append the specified bean name to the list of beans that this definition * depends on. */ public BeanDefinitionBuilder addDependsOn(String beanName) { if (this.beanDefinition.getDependsOn() == null) { this.beanDefinition.setDependsOn(new String[] {beanName}); } else { String[] added = ObjectUtils.addObjectToArray(this.beanDefinition.getDependsOn(), beanName); this.beanDefinition.setDependsOn(added); } return this; }
private static List<Filter> initFilterList(Servlet servlet, Filter... filters) { Filter[] allFilters = ObjectUtils.addObjectToArray(filters, new ServletFilterProxy(servlet)); return Arrays.asList(allFilters); }
private static List<Filter> initFilterList(Servlet servlet, Filter... filters) { Filter[] allFilters = ObjectUtils.addObjectToArray(filters, new ServletFilterProxy(servlet)); return Arrays.asList(allFilters); }
@Override public ConfigurableWebServerApplicationContext createManagementContext( ApplicationContext parent, Class<?>... configClasses) { AnnotationConfigReactiveWebServerApplicationContext child = new AnnotationConfigReactiveWebServerApplicationContext(); child.setParent(parent); Class<?>[] combinedClasses = ObjectUtils.addObjectToArray(configClasses, ReactiveWebServerFactoryAutoConfiguration.class); child.register(combinedClasses); registerReactiveWebServerFactory(parent, child); return child; }