Skip to content

Instantly share code, notes, and snippets.

@mlesikov
Created September 1, 2014 06:21
Show Gist options
  • Save mlesikov/6b3b6cb480a4e4dee1d7 to your computer and use it in GitHub Desktop.
Save mlesikov/6b3b6cb480a4e4dee1d7 to your computer and use it in GitHub Desktop.
FieldsSchema builder
/**
* @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