All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jboss.forge.convert.CompositeConverter Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2013 Red Hat, Inc. and/or its affiliates.
 *
 * Licensed under the Eclipse Public License version 1.0, available at
 * http://www.eclipse.org/legal/epl-v10.html
 */

package org.jboss.forge.convert;

import java.util.Arrays;
import java.util.List;

import javax.enterprise.inject.Vetoed;

/**
 * A {@link CompositeConverter} converts elements in the specified sequence. 
* * The result of a {@link Converter} serves as the input for the next converter * *
* The {@link CompositeConverter#convert(Object)} method always returns the last object converted * * @author George Gastaldi * */ @Vetoed @SuppressWarnings("rawtypes") public class CompositeConverter implements Converter { private List converters; public CompositeConverter(Converter... converters) { this.converters = Arrays.asList(converters); } /** * This method always returns the last object converted from the list */ @Override public Object convert(Object source) { Object value = source; for (Converter converter : converters) { if (converter != null) { value = converter.convert(value); } } return value; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy