com.factual.driver.ColumnSchema Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of factual-java-driver Show documentation
Show all versions of factual-java-driver Show documentation
Factual's officially supported Java driver
The newest version!
package com.factual.driver;
import java.util.Map;
public class ColumnSchema {
public final String name;
public final String description;
public final boolean faceted;
public final boolean sortable;
public final String label;
public final String datatype;
public final boolean searchable;
/**
* Constructor. Maps raw column schema data into a new ColumnSchema.
*
* @param map
* A column schema map object as provided by Factual.
*/
public ColumnSchema(Map map) {
name = (String)map.get(Constants.SCHEMA_COLUMN_NAME);
description = (String)map.get(Constants.SCHEMA_COLUMN_DESCRIPTION);
label = (String)map.get(Constants.SCHEMA_COLUMN_LABEL);
datatype = (String)map.get(Constants.SCHEMA_COLUMN_DATATYPE);
faceted = resolveBoolean(map.get(Constants.SCHEMA_COLUMN_FACETED), false);
sortable = resolveBoolean(map.get(Constants.SCHEMA_COLUMN_SORTABLE), false);
searchable = resolveBoolean(map.get(Constants.SCHEMA_COLUMN_SEARCHABLE), false);
}
private boolean resolveBoolean(Object val, boolean defaultVal) {
if (val instanceof Boolean)
return (Boolean) val;
return defaultVal;
}
}