Example usage for com.google.common.primitives Longs stringConverter

List of usage examples for com.google.common.primitives Longs stringConverter

Introduction

In this page you can find the example usage for com.google.common.primitives Longs stringConverter.

Prototype

@Beta
public static Converter<String, Long> stringConverter() 

Source Link

Document

Returns a serializable converter object that converts between strings and longs using Long#decode and Long#toString() .

Usage

From source file:com.dssmp.pipeline.config.Configuration.java

public Configuration(Map<String, Object> map) {
    Preconditions.checkNotNull(map);//from  w  ww. j  a  v  a2  s .c o  m
    this.configMap = map;
    this.stringConverter = new Function<Object, String>() {
        @Override
        public String apply(Object input) {
            return (input == null || input instanceof String) ? ((String) input) : input.toString();
        }
    };
    this.converters.put(String.class, this.stringConverter);
    this.doubleConverter = new StringConverterWrapper<>(Doubles.stringConverter());
    this.converters.put(String.class, this.stringConverter);
    this.integerConverter = new StringConverterWrapper<>(Ints.stringConverter());
    this.converters.put(Integer.class, this.integerConverter);
    this.longConverter = new StringConverterWrapper<>(Longs.stringConverter());
    this.converters.put(Long.class, this.longConverter);
    this.booleanConverter = new BooleanConverter();
    this.converters.put(Boolean.class, this.booleanConverter);
    this.pathConverter = new PathConverter();
    this.converters.put(Path.class, this.pathConverter);
    this.configurationConverter = new ConfigurationConverter();
    this.converters.put(Configuration.class, this.configurationConverter);

    this.stringReader = new ScalarValueReader<>(String.class, this.stringConverter);
    this.readers.put(String.class, this.stringReader);
    this.doubleReader = new ScalarValueReader<>(Double.class, this.doubleConverter);
    this.readers.put(Double.class, doubleReader);
    this.integerReader = new ScalarValueReader<>(Integer.class, this.integerConverter);
    this.readers.put(Integer.class, integerReader);
    this.longReader = new ScalarValueReader<>(Long.class, this.longConverter);
    this.readers.put(Long.class, longReader);
    this.booleanReader = new ScalarValueReader<>(Boolean.class, this.booleanConverter);
    this.readers.put(Boolean.class, booleanReader);
    this.pathReader = new ScalarValueReader<>(Path.class, this.pathConverter);
    this.readers.put(Path.class, pathReader);
    this.configurationReader = new ScalarValueReader<>(Configuration.class, this.configurationConverter);
    this.readers.put(Configuration.class, this.configurationReader);
}

From source file:com.amazon.kinesis.streaming.agent.config.Configuration.java

/**
 * @param config/* w w w. ja  v  a  2s . co m*/
 */
public Configuration(Map<String, Object> map) {
    Preconditions.checkNotNull(map);
    this.configMap = map;
    this.stringConverter = new Function<Object, String>() {
        @Override
        @Nullable
        public String apply(@Nullable Object input) {
            return (input == null || input instanceof String) ? ((String) input) : input.toString();
        }
    };
    this.converters.put(String.class, this.stringConverter);
    this.doubleConverter = new StringConverterWrapper<>(Doubles.stringConverter());
    this.converters.put(String.class, this.stringConverter);
    this.integerConverter = new StringConverterWrapper<>(Ints.stringConverter());
    this.converters.put(Integer.class, this.integerConverter);
    this.longConverter = new StringConverterWrapper<>(Longs.stringConverter());
    this.converters.put(Long.class, this.longConverter);
    this.booleanConverter = new BooleanConverter();
    this.converters.put(Boolean.class, this.booleanConverter);
    this.pathConverter = new PathConverter();
    this.converters.put(Path.class, this.pathConverter);
    this.configurationConverter = new ConfigurationConverter();
    this.converters.put(Configuration.class, this.configurationConverter);

    this.stringReader = new ScalarValueReader<>(String.class, this.stringConverter);
    this.readers.put(String.class, this.stringReader);
    this.doubleReader = new ScalarValueReader<>(Double.class, this.doubleConverter);
    this.readers.put(Double.class, doubleReader);
    this.integerReader = new ScalarValueReader<>(Integer.class, this.integerConverter);
    this.readers.put(Integer.class, integerReader);
    this.longReader = new ScalarValueReader<>(Long.class, this.longConverter);
    this.readers.put(Long.class, longReader);
    this.booleanReader = new ScalarValueReader<>(Boolean.class, this.booleanConverter);
    this.readers.put(Boolean.class, booleanReader);
    this.pathReader = new ScalarValueReader<>(Path.class, this.pathConverter);
    this.readers.put(Path.class, pathReader);
    this.configurationReader = new ScalarValueReader<>(Configuration.class, this.configurationConverter);
    this.readers.put(Configuration.class, this.configurationReader);
}