DataRowDecoratorTransformer.java :  » Testing » DDSteps » org » ddsteps » dataset » decorator » Java Open Source

Java Open Source » Testing » DDSteps 
DDSteps » org » ddsteps » dataset » decorator » DataRowDecoratorTransformer.java
/* DataRowDecoratorTransformer.java
 * 
 * DDSteps - Data Driven JUnit Test Steps
 * Copyright (C) 2005 Jayway AB
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License version 2.1 as published by the Free Software Foundation.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, visit 
 * http://www.opensource.org/licenses/lgpl-license.php
 */
package org.ddsteps.dataset.decorator;

import org.apache.commons.collections.Transformer;
import org.apache.commons.lang.Validate;
import org.ddsteps.dataset.DataRow;


/**
 * @author Adam
 * @version $Id: DataRowDecoratorTransformer.java,v 1.1 2005/12/03 12:51:40 adamskogman Exp $
 */
public class DataRowDecoratorTransformer implements Transformer {

    final Transformer dataValueTransformer;

    /**
     * @param dataValueTransformer
     */
    public DataRowDecoratorTransformer(Transformer dataValueTransformer) {
        super();
        Validate.notNull(dataValueTransformer);
        this.dataValueTransformer = dataValueTransformer;
    }

    /**
     * Decorate a DataRow with a DataRowDecorator.
     * 
     * @see org.apache.commons.collections.Transformer#transform(java.lang.Object)
     */
    public Object transform(Object arg0) {
        Validate.notNull(arg0, "Argument must not be null");
        Validate.isTrue(arg0 instanceof DataRow, "Argument must be a DataRow");
        DataRow row = (DataRow) arg0;

        DataRowDecorator decorator = new DataRowDecorator(row);
        decorator.setDataValueTransformer(dataValueTransformer);
        return decorator;
    }

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.