Created
September 1, 2014 06:21
-
-
Save mlesikov/6b3b6cb480a4e4dee1d7 to your computer and use it in GitHub Desktop.
FieldsSchema builder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @author Mihail Lesikov ([email protected]) | |
*/ | |
public class FieldsSchema { | |
public static Builder aNewFieldSchema() { | |
return new Builder(); | |
} | |
public static class Builder { | |
private ImmutableMap.Builder<String, String> fields = ImmutableMap.<String, String>builder(); | |
public FieldsSchema build() { | |
FieldsSchema object = new FieldsSchema(); | |
object.fields = this.fields.build(); | |
return object; | |
} | |
public Builder string(String key) { | |
fields.put(key, "string"); | |
return this; | |
} | |
public Builder integer(String key) { | |
fields.put(key, "integer"); | |
return this; | |
} | |
public Builder doubleValue(String key) { | |
fields.put(key, "float"); | |
return this; | |
} | |
public Builder timestamp(String key) { | |
fields.put(key, "timestamp"); | |
return this; | |
} | |
} | |
private ImmutableMap<String, String> fields; | |
public FieldsSchema() { | |
} | |
public Map<String, String> getFields() { | |
return fields; | |
} | |
public boolean isEmpty() { | |
return fields.isEmpty(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment