make ConfigTransformer private, don't think it's useful

This commit is contained in:
Havoc Pennington 2011-11-08 21:37:19 -05:00
parent 619ce047c2
commit e11f117200
16 changed files with 27 additions and 53 deletions

View File

@ -10,7 +10,7 @@ public final class Config {
}
public static ConfigObject load(String rootPath) {
return ConfigImpl.loadConfig(new ConfigConfig(rootPath, null));
return ConfigImpl.loadConfig(new ConfigConfig(rootPath));
}
private static String getUnits(String s) {

View File

@ -6,17 +6,12 @@ package com.typesafe.config;
public final class ConfigConfig {
private String rootPath;
private ConfigTransformer extraTransformer;
public ConfigConfig(String rootPath, ConfigTransformer extraTransformer) {
public ConfigConfig(String rootPath) {
this.rootPath = rootPath;
}
public String rootPath() {
return rootPath;
}
public ConfigTransformer extraTransformer() {
return extraTransformer;
}
}

View File

@ -1,11 +0,0 @@
package com.typesafe.config;
/**
* A ConfigTransformer converts values in the config to other values, most often
* it's used to parse strings and treat them as some other kind of value.
* There's no implementation of ConfigValue included in the public API of this
* library, you have to just create one.
*/
public interface ConfigTransformer {
ConfigValue transform(ConfigValue value, ConfigValueType requested);
}

View File

@ -11,7 +11,6 @@ import com.typesafe.config.Config;
import com.typesafe.config.ConfigException;
import com.typesafe.config.ConfigObject;
import com.typesafe.config.ConfigOrigin;
import com.typesafe.config.ConfigTransformer;
import com.typesafe.config.ConfigValue;
import com.typesafe.config.ConfigValueType;

View File

@ -11,7 +11,6 @@ import java.util.Properties;
import com.typesafe.config.ConfigConfig;
import com.typesafe.config.ConfigException;
import com.typesafe.config.ConfigObject;
import com.typesafe.config.ConfigTransformer;
import com.typesafe.config.ConfigValue;
/** This is public but is only supposed to be used by the "config" package */
@ -30,8 +29,7 @@ public class ConfigImpl {
if (system != null)
stack.add(system);
ConfigTransformer transformer = withExtraTransformer(configConfig
.extraTransformer());
ConfigTransformer transformer = withExtraTransformer(null);
AbstractConfigObject merged = AbstractConfigObject
.merge(new SimpleConfigOrigin("config for "
@ -40,20 +38,18 @@ public class ConfigImpl {
return merged;
}
public static ConfigObject getEnvironmentAsConfig(
ConfigTransformer extraTransformer) {
public static ConfigObject getEnvironmentAsConfig() {
// This should not need to create a new config object
// as long as the transformer is just the default transformer.
return AbstractConfigObject.transformed(envVariablesConfig(),
withExtraTransformer(extraTransformer));
withExtraTransformer(null));
}
public static ConfigObject getSystemPropertiesAsConfig(
ConfigTransformer extraTransformer) {
public static ConfigObject getSystemPropertiesAsConfig() {
// This should not need to create a new config object
// as long as the transformer is just the default transformer.
return AbstractConfigObject.transformed(systemPropertiesConfig(),
withExtraTransformer(extraTransformer));
withExtraTransformer(null));
}
private static ConfigTransformer withExtraTransformer(

View File

@ -0,0 +1,17 @@
package com.typesafe.config.impl;
import com.typesafe.config.ConfigValue;
import com.typesafe.config.ConfigValueType;
/**
* A ConfigTransformer converts values in the config to other values, most often
* it's used to parse strings and treat them as some other kind of value.
*
* This was originally in the public API but I'm now thinking it is not useful
* to customize, so it's not public for now. It's still used internally, but
* probably the code could be cleaned up by just hard-coding the equivalent of
* the DefaultTransformer.
*/
interface ConfigTransformer {
ConfigValue transform(ConfigValue value, ConfigValueType requested);
}

View File

@ -1,9 +1,11 @@
package com.typesafe.config.impl;
import com.typesafe.config.ConfigTransformer;
import com.typesafe.config.ConfigValue;
import com.typesafe.config.ConfigValueType;
/**
* Default automatic type transformations.
*/
class DefaultTransformer implements ConfigTransformer {
@Override

View File

@ -7,7 +7,6 @@ import java.util.Set;
import com.typesafe.config.ConfigException;
import com.typesafe.config.ConfigObject;
import com.typesafe.config.ConfigOrigin;
import com.typesafe.config.ConfigTransformer;
import com.typesafe.config.ConfigValue;
class SimpleConfigObject extends AbstractConfigObject {

View File

@ -8,7 +8,6 @@ import java.util.Map;
import java.util.Set;
import com.typesafe.config.ConfigOrigin;
import com.typesafe.config.ConfigTransformer;
import com.typesafe.config.ConfigValue;
/**

View File

@ -2,7 +2,6 @@ package com.typesafe.config.impl;
import java.util.List;
import com.typesafe.config.ConfigTransformer;
import com.typesafe.config.ConfigValue;
import com.typesafe.config.ConfigValueType;

View File

@ -2,7 +2,6 @@ package com.typesafe.config.impl;
import java.util.Set;
import com.typesafe.config.ConfigTransformer;
import com.typesafe.config.ConfigValue;
class TransformedConfigObject extends AbstractConfigObject {

View File

@ -9,10 +9,6 @@ import java.util.HashMap
class ConfParserTest extends TestUtils {
@org.junit.Before
def setup() {
}
def parse(s: String): ConfigValue = {
Parser.parse(SyntaxFlavor.CONF, new SimpleConfigOrigin("test conf string"), s)
}

View File

@ -6,10 +6,6 @@ import com.typesafe.config.ConfigValue
class ConfigValueTest extends TestUtils {
@org.junit.Before
def setup() {
}
@Test
def configIntEquality() {
val a = new ConfigInt(fakeOrigin(), 42)

View File

@ -10,10 +10,6 @@ import java.util.HashMap
class ParseTest extends TestUtils {
@org.junit.Before
def setup() {
}
def parse(s: String): ConfigValue = {
Parser.parse(SyntaxFlavor.JSON, new SimpleConfigOrigin("test json string"), s)
}

View File

@ -5,10 +5,6 @@ import org.junit._
class TokenTest extends TestUtils {
@org.junit.Before
def setup() {
}
@Test
def tokenEquality() {
checkEqualObjects(Tokens.START, Tokens.START)

View File

@ -10,10 +10,6 @@ import java.util.HashMap
class TokenizerTest extends TestUtils {
@org.junit.Before
def setup() {
}
def tokenTrue = Tokens.newBoolean(fakeOrigin(), true)
def tokenFalse = Tokens.newBoolean(fakeOrigin(), false)
def tokenNull = Tokens.newNull(fakeOrigin())