01: /*
02: * Copyright (C) 2006 Joe Walnes.
03: * Copyright (C) 2006, 2007 XStream Committers.
04: * All rights reserved.
05: *
06: * The software in this package is published under the terms of the BSD
07: * style license a copy of which has been included with this distribution in
08: * the LICENSE.txt file.
09: *
10: * Created on 15. July 2006 by Joe Walnes
11: */
12: package com.thoughtworks.xstream.tools.benchmark.targets;
13:
14: import com.thoughtworks.xstream.tools.benchmark.Target;
15:
16: import java.util.ArrayList;
17: import java.util.List;
18:
19: /**
20: * An ArrayList of user defined class ({@link Person}) instances to serialize.
21: *
22: * @author Joe Walnes
23: * @see com.thoughtworks.xstream.tools.benchmark.Harness
24: * @see Target
25: */
26: public class ListTarget implements Target {
27:
28: private List list = new ArrayList();
29:
30: public ListTarget(int size) {
31: for (int i = 0; i < size; i++) {
32: Person person = new Person();
33: person.firstName = "First name " + i;
34: person.lastName = "Last name " + i;
35: list.add(person);
36: }
37: }
38:
39: public String toString() {
40: return "List of " + list.size() + " user defined objects";
41: }
42:
43: public Object target() {
44: return list;
45: }
46:
47: public boolean isEqual(Object other) {
48: return list.equals(other);
49: }
50: }
|