01: /* DataValueDecoratorTransformer.java
02: *
03: * DDSteps - Data Driven JUnit Test Steps
04: * Copyright (C) 2005 Jayway AB
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License version 2.1 as published by the Free Software Foundation.
09: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library; if not, visit
17: * http://www.opensource.org/licenses/lgpl-license.php
18: */
19: package org.ddsteps.dataset.decorator;
20:
21: import org.apache.commons.collections.Transformer;
22: import org.apache.commons.lang.Validate;
23: import org.ddsteps.dataset.DataValue;
24:
25: /**
26: * Transforms a DataValue by wrapping it in a DataValueDecorator.
27: *
28: * @author Adam
29: * @version $Id: DataValueDecoratorTransformer.java,v 1.1 2005/12/03 12:51:40 adamskogman Exp $
30: */
31: public class DataValueDecoratorTransformer implements Transformer {
32:
33: final Transformer dataValueTransformer;
34:
35: /**
36: * @param dataValueTransformer
37: */
38: public DataValueDecoratorTransformer(
39: Transformer dataValueTransformer) {
40: super ();
41: Validate.notNull(dataValueTransformer);
42: this .dataValueTransformer = dataValueTransformer;
43: }
44:
45: /**
46: * Decorate a DataRow with a DataRowDecorator.
47: *
48: * @see org.apache.commons.collections.Transformer#transform(java.lang.Object)
49: */
50: public Object transform(Object arg0) {
51: Validate.notNull(arg0, "Argument must not be null");
52: Validate.isTrue(arg0 instanceof DataValue,
53: "Argument must be a DataValue");
54: DataValue value = (DataValue) arg0;
55:
56: DataValueDecorator decorator = new DataValueDecorator(value);
57: decorator.setDataValueTransformer(dataValueTransformer);
58: return decorator;
59: }
60:
61: }
|