    001package com.typesafe.config;
    002
    003import java.net.URL;
    004
    005import com.typesafe.config.impl.ConfigImpl;
    006
    007/**
    008 * This class contains some static factory methods for building a {@link
    009 * ConfigOrigin}. {@code ConfigOrigin}s are automatically created when you
    010 * call other API methods to get a {@code ConfigValue} or {@code Config}.
    011 * But you can also set the origin of an existing {@code ConfigValue}, using
    012 * {@link ConfigValue#withOrigin(ConfigOrigin)}.
    013 *
    014 */
    015public final class ConfigOriginFactory {
    016    private ConfigOriginFactory() {
    017    }
    018
    019    /**
    020     * Returns the default origin for values when no other information is
    021     * provided. This is the origin used in {@link ConfigValueFactory
    022     * #fromAnyRef(Object)}.
    023     *
    024     * @return the default origin
    025     */
    026    public static ConfigOrigin newSimple() {
    027        return newSimple(null);
    028    }
    029
    030    /**
    031     * Returns an origin with the given description.
    032     *
    033     * @param description brief description of what the origin is
    034     * @return a new origin
    035     */
    036    public static ConfigOrigin newSimple(String description) {
    037        return ConfigImpl.newSimpleOrigin(description);
    038    }
    039
    040    /**
    041     * Creates a file origin with the given filename.
    042     *
    043     * @param filename the filename of this origin
    044     * @return a new origin
    045     */
    046    public static ConfigOrigin newFile(String filename) {
    047        return ConfigImpl.newFileOrigin(filename);
    048    }
    049
    050    /**
    051     * Creates a url origin with the given URL object.
    052     *
    053     * @param url the url of this origin
    054     * @return a new origin
    055     */
    056    public static ConfigOrigin newURL(URL url) {
    057        return ConfigImpl.newURLOrigin(url);
    058    }
    059}