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

org.cthul.strings.format.MatchResultsBase Maven / Gradle / Ivy

Go to download

Functions for converting strings from and to various formats, such as roman numbers, alpha indices, Java identifiers, and format strings.

The newest version!
package org.cthul.strings.format;

import java.util.*;
import org.cthul.strings.format.ConversionPattern.Intermediate;

/**
 *
 * @author Arian Treffer
 */
public abstract class MatchResultsBase extends AbstractArgs implements MatchResults {
    
    /**
     * Converts an {@link Intermediate} into the final value.
     * @param o
     * @return final value
     */
    protected static Object complete(Object o) {
        if (o instanceof Intermediate) {
            o = ((Intermediate) o).complete();
        }
        return o;
    }
    
    protected static List complete(Collection values) {
        final List result = new ArrayList<>(values.size());
        for (Object o: values) {
            result.add(complete(o));
        }
        return result;
    }
    
    protected static  Map complete(Map values) {
        final Map result = new HashMap<>(values);
        for (Map.Entry e: result.entrySet()) {
            e.setValue(complete(e.getValue()));
        }
        return result;
    }
    
}