Skip to content
Snippets Groups Projects
Commit c817ec0c authored by tpylak's avatar tpylak
Browse files

general material properties: changing DTOs

SVN: 2360
parent 2ebcad7c
No related branches found
No related tags found
No related merge requests found
...@@ -49,6 +49,13 @@ abstract public class AbstractPropertiesSetter<ConstructedType> implements IProp ...@@ -49,6 +49,13 @@ abstract public class AbstractPropertiesSetter<ConstructedType> implements IProp
this.availableProperties = toLowerCase(getAvailableProperties(beanClass)); 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) private static Set<String> toLowerCase(Set<String> set)
{ {
Set<String> result = new HashSet<String>(); Set<String> result = new HashSet<String>();
......
...@@ -163,6 +163,29 @@ public final class BeanUtils ...@@ -163,6 +163,29 @@ public final class BeanUtils
return createBeanList(clazz, source, null); 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>. * Creates a new list of Beans of type <var>clazz</var>.
* *
...@@ -383,7 +406,13 @@ public final class BeanUtils ...@@ -383,7 +406,13 @@ public final class BeanUtils
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private static <T> T createArray(Class<T> beanClass, int length) throws NegativeArraySizeException 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") @SuppressWarnings("unchecked")
...@@ -777,5 +806,4 @@ public final class BeanUtils ...@@ -777,5 +806,4 @@ public final class BeanUtils
throw new CheckedExceptionTunnel(ex); throw new CheckedExceptionTunnel(ex);
} }
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment