/** * This method gets the singleton instance of this {@link CollectionReflectionUtilImpl}. <br> * <b>ATTENTION:</b><br> * Please prefer dependency-injection instead of using this method. * * @return the singleton instance. */ public static CollectionReflectionUtilImpl getInstance() { if (instance == null) { synchronized (CollectionReflectionUtilImpl.class) { if (instance == null) { CollectionReflectionUtilImpl util = new CollectionReflectionUtilImpl(); util.initialize(); instance = util; } } } return instance; }
@Override public Object get(Object arrayOrList, int index) { return get(arrayOrList, index, true); }
@Override public Object set(Object arrayOrList, int index, Object item) { return set(arrayOrList, index, item, null, this.maximumListGrowth); }
@Override protected void doInitialize() { super.doInitialize(); if (this.reflectionUtil == null) { this.reflectionUtil = ReflectionUtilImpl.getInstance(); } if (this.collectionReflectionUtil == null) { this.collectionReflectionUtil = CollectionReflectionUtilImpl.getInstance(); } }
@Override @SuppressWarnings("unchecked") public <T> T[] toArrayTyped(Collection<T> collection, Class<T> componentType) { return (T[]) toArray(collection, componentType); }
@Bean public CollectionReflectionUtil collectionReflectionUtil() { return new CollectionReflectionUtilImpl(); }
/** * This method sets the {@link #getMaximumListGrowth() maximumListGrowth}. * * @param maximumListGrowth is the maximumListGrowth to set. */ public void setMaximumListGrowth(int maximumListGrowth) { getInitializationState().requireNotInitilized(); this.maximumListGrowth = maximumListGrowth; }
@Override protected void doInitialize() { super.doInitialize(); if (this.descriptorBuilderFactory == null) { PojoDescriptorBuilderFactoryImpl factory = new PojoDescriptorBuilderFactoryImpl(); factory.initialize(); this.descriptorBuilderFactory = factory; } if (this.nlsMessageFactory == null) { this.nlsMessageFactory = NlsAccess.getFactory(); } if (this.converter == null) { this.converter = DefaultComposedValueConverter.getInstance(); } if (this.reflectionUtil == null) { this.reflectionUtil = ReflectionUtilImpl.getInstance(); } if (this.collectionReflectionUtil == null) { this.collectionReflectionUtil = CollectionReflectionUtilImpl.getInstance(); } if (this.collectionFactoryManager == null) { this.collectionFactoryManager = CollectionFactoryManagerImpl.getInstance(); } if (this.lineWrapper == null) { DefaultLineWrapper wrapper = new DefaultLineWrapper(); wrapper.initialize(); this.lineWrapper = wrapper; } }
@Override public Object set(Object arrayOrList, int index, Object item, GenericBean<Object> arrayReceiver) { return set(arrayOrList, index, item, arrayReceiver, this.maximumListGrowth); }