// Path: retired/format/src/main/java/org/javamoney/format/tokens/LiteralTokenStyleableItem.java
// public final class LiteralTokenStyleableItem<R> implements StyleableItemFormatToken<R>, Serializable {
// 
// 	/**
// 	 * The literal part.
// 	 */
// 	private String token;
// 
// 	/**
// 	 * Constructor.
// 	 * 
// 	 * @param token
// 	 *            The literal token part.
// 	 */
// 	public LiteralTokenStyleableItem(String token) {
// 		if (token == null) {
// 			throw new IllegalArgumentException("Token is required.");
// 		}
// 		this.token = token;
// 	}
// 
// 
// 	/*
// 	 * (non-Javadoc)
// 	 * 
// 	 * @see
// 	 * javax.money.format.StyleableItemFormatToken#parse(javax.money.format.ItemParseContext,
// 	 * java.util.Locale, javax.money.format.LocalizationStyle)
// 	 */
// 	@Override
// 	public void parse(ItemParseContext<R> context, Locale locale,
// 			LocalizationContext style)
// 			throws ItemParseException{
// 		if (!context.consume(token)) {
// 			throw new ItemParseException("Expected '" + token + "' in "
// 					+ context.getInput().toString());
// 		}
// 	}
// 
// 	/*
// 	 * (non-Javadoc)
// 	 * 
// 	 * @see javax.money.format.StyleableItemFormatToken#print(java.lang.Appendable,
// 	 * java.lang.Object, java.util.Locale, javax.money.format.LocalizationStyle)
// 	 */
// 	@Override
// 	public void print(Appendable appendable, R item, Locale locale,
// 			LocalizationContext style)
// 			throws IOException {
// 		appendable.append(this.token);
// 	}
// 
// 	/*
// 	 * (non-Javadoc)
// 	 * 
// 	 * @see java.lang.Object#toString()
// 	 */
// 	@Override
// 	public String toString() {
// 		return "LiteralTokenStyleableItem [token=" + token + "]";
// 	}
// 
// }


import org.javamoney.format.tokens.LiteralTokenStyleableItem;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
/*
 * Copyright (c) 2012, 2013, Credit Suisse (Anatole Tresch), Werner Keil.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package org.javamoney.format;



/**
 * This class implements a builder that allows creating of {@link ItemFormat}
 * instances programmatically using a fluent API. The formatting hereby is
 * modeled by a concatenation of {@link StyleableItemFormatToken} instances. The same
 * {@link StyleableItemFormatToken} instances also are responsible for implementing the
 * opposite, parsing, of an item from an input character sequence. Each
 * {@link StyleableItemFormatToken} gets access to the current parsing location, and the
 * original and current character input sequence, modeled by the
 * {@link ItemParseContext}. Finall if parsing of a part failed, a
 * {@link StyleableItemFormatToken} throws an {@link ItemParseException} describing the
 * problem.
 * <p>
 * This class is not thread-safe and therefore should not be shared among
 * different threads.
 *
 * @param <T> the target type.
 * @author Anatole Tresch
 */
public class ItemFormatBuilder<T>{
    /**
     * The tokens to be used for formatting/parsing.
     */
    private List<StyleableItemFormatToken<T>> tokens = new ArrayList<StyleableItemFormatToken<T>>();
    /**
     * The localization configuration.
     */
    private LocalizationContext localizationContext;
    /**
     * The target type being parsed/formatted.
     */
    private Class<T> targetType;
    /**
     * The item factory to be used.
     */
    private ParseResultFactory<T> parseResultFactory;

    /**
     * Creates a new Builder.
     */
    public ItemFormatBuilder(){

    }

    /**
     * Creates a new Builder.
     *
     * @param targetType the target class.
     */
    public ItemFormatBuilder(Class<T> targetType){
        if(targetType == null){
            throw new IllegalArgumentException("targetType must not be null.");
        }
        this.targetType = targetType;
    }

    /**
     * Access the target class, which this formatter can handle with.
     *
     * @return the target class, never null.
     */
    public Class<T> getTargetType(){
        return this.targetType;
    }

    /**
     * Configure the format with the given {@link LocalizationContext}.
     *
     * @param style the localizationStyle to be applied.
     * @return the builder instance, for chaining.
     */
    public ItemFormatBuilder<T> withStyle(LocalizationContext style){
// Path: retired/format/src/main/java/org/javamoney/format/tokens/LiteralTokenStyleableItem.java
// public final class LiteralTokenStyleableItem<R> implements StyleableItemFormatToken<R>, Serializable {
// 
// 	/**
// 	 * The literal part.
// 	 */
// 	private String token;
// 
// 	/**
// 	 * Constructor.
// 	 * 
// 	 * @param token
// 	 *            The literal token part.
// 	 */
// 	public LiteralTokenStyleableItem(String token) {
// 		if (token == null) {
// 			throw new IllegalArgumentException("Token is required.");
// 		}
// 		this.token = token;
// 	}
// 
// 
// 	/*
// 	 * (non-Javadoc)
// 	 * 
// 	 * @see
// 	 * javax.money.format.StyleableItemFormatToken#parse(javax.money.format.ItemParseContext,
// 	 * java.util.Locale, javax.money.format.LocalizationStyle)
// 	 */
// 	@Override
// 	public void parse(ItemParseContext<R> context, Locale locale,
// 			LocalizationContext style)
// 			throws ItemParseException{
// 		if (!context.consume(token)) {
// 			throw new ItemParseException("Expected '" + token + "' in "
// 					+ context.getInput().toString());
// 		}
// 	}
// 
// 	/*
// 	 * (non-Javadoc)
// 	 * 
// 	 * @see javax.money.format.StyleableItemFormatToken#print(java.lang.Appendable,
// 	 * java.lang.Object, java.util.Locale, javax.money.format.LocalizationStyle)
// 	 */
// 	@Override
// 	public void print(Appendable appendable, R item, Locale locale,
// 			LocalizationContext style)
// 			throws IOException {
// 		appendable.append(this.token);
// 	}
// 
// 	/*
// 	 * (non-Javadoc)
// 	 * 
// 	 * @see java.lang.Object#toString()
// 	 */
// 	@Override
// 	public String toString() {
// 		return "LiteralTokenStyleableItem [token=" + token + "]";
// 	}
// 
// }


// Path: retired/format/src/main/java/org/javamoney/format/ItemFormatBuilder.java
import org.javamoney.format.tokens.LiteralTokenStyleableItem;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Locale;

/*
 * Copyright (c) 2012, 2013, Credit Suisse (Anatole Tresch), Werner Keil.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package org.javamoney.format;



/**
 * This class implements a builder that allows creating of {@link ItemFormat}
 * instances programmatically using a fluent API. The formatting hereby is
 * modeled by a concatenation of {@link StyleableItemFormatToken} instances. The same
 * {@link StyleableItemFormatToken} instances also are responsible for implementing the
 * opposite, parsing, of an item from an input character sequence. Each
 * {@link StyleableItemFormatToken} gets access to the current parsing location, and the
 * original and current character input sequence, modeled by the
 * {@link ItemParseContext}. Finall if parsing of a part failed, a
 * {@link StyleableItemFormatToken} throws an {@link ItemParseException} describing the
 * problem.
 * <p>
 * This class is not thread-safe and therefore should not be shared among
 * different threads.
 *
 * @param <T> the target type.
 * @author Anatole Tresch
 */
public class ItemFormatBuilder<T>{
    /**
     * The tokens to be used for formatting/parsing.
     */
    private List<StyleableItemFormatToken<T>> tokens = new ArrayList<StyleableItemFormatToken<T>>();
    /**
     * The localization configuration.
     */
    private LocalizationContext localizationContext;
    /**
     * The target type being parsed/formatted.
     */
    private Class<T> targetType;
    /**
     * The item factory to be used.
     */
    private ParseResultFactory<T> parseResultFactory;

    /**
     * Creates a new Builder.
     */
    public ItemFormatBuilder(){

    }

    /**
     * Creates a new Builder.
     *
     * @param targetType the target class.
     */
    public ItemFormatBuilder(Class<T> targetType){
        if(targetType == null){
            throw new IllegalArgumentException("targetType must not be null.");
        }
        this.targetType = targetType;
    }

    /**
     * Access the target class, which this formatter can handle with.
     *
     * @return the target class, never null.
     */
    public Class<T> getTargetType(){
        return this.targetType;
    }

    /**
     * Configure the format with the given {@link LocalizationContext}.
     *
     * @param style the localizationStyle to be applied.
     * @return the builder instance, for chaining.
     */
    public ItemFormatBuilder<T> withStyle(LocalizationContext style){
        if(style == null){