diff --git a/common/source/java/ch/systemsx/cisd/common/parser/AbstractPropertiesSetter.java b/common/source/java/ch/systemsx/cisd/common/parser/AbstractPropertiesSetter.java index c63feb4165cd6c1c8c4bd6d6eecd82d54811a35a..9f05c4c67db209357db19ca1355f95d8c349315d 100644 --- a/common/source/java/ch/systemsx/cisd/common/parser/AbstractPropertiesSetter.java +++ b/common/source/java/ch/systemsx/cisd/common/parser/AbstractPropertiesSetter.java @@ -49,6 +49,13 @@ abstract public class AbstractPropertiesSetter<ConstructedType> implements IProp this.availableProperties = toLowerCase(getAvailableProperties(beanClass)); } + protected AbstractPropertiesSetter(Set<String> availableProperties, Set<String> mandatoryFields) + { + this.properties = new HashMap<String, String>(); + this.mandatoryFields = mandatoryFields; + this.availableProperties = availableProperties; + } + private static Set<String> toLowerCase(Set<String> set) { Set<String> result = new HashSet<String>(); diff --git a/common/source/java/ch/systemsx/cisd/common/utilities/BeanUtils.java b/common/source/java/ch/systemsx/cisd/common/utilities/BeanUtils.java index 87727d1b5142bf4104cc5171b970309a47f87a39..a6b5e88f9252f6d646c8aeb4203fb4e21751ce64 100644 --- a/common/source/java/ch/systemsx/cisd/common/utilities/BeanUtils.java +++ b/common/source/java/ch/systemsx/cisd/common/utilities/BeanUtils.java @@ -163,6 +163,29 @@ public final class BeanUtils return createBeanList(clazz, source, null); } + /** + * Creates a new array of Beans of type <var>clazz</var>. See <code>createBeanList()</code> for parameter + * specification. + */ + public static <T, S> T[] createBeanArray(Class<T> clazz, Collection<S> source, Converter converter) + { + assert clazz != null; + + if (source == null) + { + return null; + } + + final T result[] = createArrayOfType(clazz, source.size()); + int i = 0; + for (S element : source) + { + result[i] = BeanUtils.createBean(clazz, element, converter); + i++; + } + return result; + } + /** * Creates a new list of Beans of type <var>clazz</var>. * @@ -383,7 +406,13 @@ public final class BeanUtils @SuppressWarnings("unchecked") private static <T> T createArray(Class<T> beanClass, int length) throws NegativeArraySizeException { - return (T) Array.newInstance(beanClass.getComponentType(), length); + return (T) createArrayOfType(beanClass.getComponentType(), length); + } + + @SuppressWarnings("unchecked") + private static <E> E[] createArrayOfType(Class<E> elemClass, int length) throws NegativeArraySizeException + { + return (E[]) Array.newInstance(elemClass, length); } @SuppressWarnings("unchecked") @@ -777,5 +806,4 @@ public final class BeanUtils throw new CheckedExceptionTunnel(ex); } } - }