@Test(expected = IllegalArgumentException.class) public void testNoSetting() { InboundSettings.create(ConfigUtils.getDefaultConfig()); }
public static InboundSettings create(Config config) { Config inbound = config.getConfig("inbound"); List<String> columnNames = inbound.getStringList("column-names"); Function<Object,Integer> lookup = new LookupFunction(columnNames); Iterable<Integer> allColumns = Collections2.transform(columnNames, lookup); Collection<Integer> idColumns; if (inbound.hasPath("id-columns")) { idColumns = ImmutableSet.copyOf( Collections2.transform(inbound.getAnyRefList("id-columns"), lookup)); } else { idColumns = ImmutableSet.of(); } Collection<Integer> ignoredColumns; if (inbound.hasPath("ignored-columns")) { ignoredColumns = ImmutableSet.copyOf( Collections2.transform(inbound.getAnyRefList("ignored-columns"), lookup)); } else { ignoredColumns = ImmutableSet.of(); } Collection<Integer> categoricalColumns; Collection<Integer> numericColumns; if (inbound.hasPath("categorical-columns")) { Preconditions.checkState(!inbound.hasPath("numeric-columns")); categoricalColumns = Sets.newHashSet( Collections2.transform(inbound.getAnyRefList("categorical-columns"), lookup)); numericColumns = Sets.newHashSet(allColumns); numericColumns.removeAll(categoricalColumns); } else if (inbound.hasPath("numeric-columns")) { Preconditions.checkState(!inbound.hasPath("categorical-columns")); numericColumns = Sets.newHashSet( Collections2.transform(inbound.getAnyRefList("numeric-columns"), lookup)); categoricalColumns = Sets.newHashSet(allColumns); categoricalColumns.removeAll(numericColumns); } else { throw new IllegalArgumentException("No categorical-columns or numeric-columns set"); } numericColumns.removeAll(idColumns); numericColumns.removeAll(ignoredColumns); categoricalColumns.removeAll(idColumns); categoricalColumns.removeAll(ignoredColumns); Integer targetColumn = null; if (inbound.hasPath("target-column")) { targetColumn = lookup.apply(inbound.getAnyRef("target-column")); Preconditions.checkState(categoricalColumns.contains(targetColumn) || numericColumns.contains(targetColumn), "Target column not specified as numeric or categorical"); } return new InboundSettings(columnNames, idColumns, categoricalColumns, numericColumns, ignoredColumns, targetColumn); }
InboundSettings implements Serializable { public static InboundSettings create(Config config) { Config inbound = config.getConfig("inbound"); List<String> columnNames = inbound.getStringList("column-names"); Function<Object,Integer> lookup = new LookupFunction(columnNames); Iterable<Integer> allColumns = Collections2.transform(columnNames, lookup); Collection<Integer> idColumns; if (inbound.hasPath("id-columns")) { idColumns = ImmutableSet.copyOf( Collections2.transform(inbound.getAnyRefList("id-columns"), lookup)); } else { idColumns = ImmutableSet.of(); } Collection<Integer> ignoredColumns; if (inbound.hasPath("ignored-columns")) { ignoredColumns = ImmutableSet.copyOf( Collections2.transform(inbound.getAnyRefList("ignored-columns"), lookup)); } else { ignoredColumns = ImmutableSet.of(); } Collection<Integer> categoricalColumns; Collection<Integer> numericColumns; if (inbound.hasPath("categorical-columns")) { Preconditions.checkState(!inbound.hasPath("numeric-columns")); categoricalColumns = Sets.newHashSet( Collections2.transform(inbound.getAnyRefList("categorical-columns"), lookup)); numericColumns = Sets.newHashSet(allColumns); numericColumns.removeAll(categoricalColumns); } else if (inbound.hasPath("numeric-columns")) { Preconditions.checkState(!inbound.hasPath("categorical-columns")); numericColumns = Sets.newHashSet( Collections2.transform(inbound.getAnyRefList("numeric-columns"), lookup)); categoricalColumns = Sets.newHashSet(allColumns); categoricalColumns.removeAll(numericColumns); } else { throw new IllegalArgumentException("No categorical-columns or numeric-columns set"); } numericColumns.removeAll(idColumns); numericColumns.removeAll(ignoredColumns); categoricalColumns.removeAll(idColumns); categoricalColumns.removeAll(ignoredColumns); Integer targetColumn = null; if (inbound.hasPath("target-column")) { targetColumn = lookup.apply(inbound.getAnyRef("target-column")); Preconditions.checkState(categoricalColumns.contains(targetColumn) || numericColumns.contains(targetColumn), "Target column not specified as numeric or categorical"); } return new InboundSettings(columnNames, idColumns, categoricalColumns, numericColumns, ignoredColumns, targetColumn); } }
InboundSettings implements Serializable { public static InboundSettings create(Config config) { Config inbound = config.getConfig("inbound"); List<String> columnNames = inbound.getStringList("column-names"); Function<Object,Integer> lookup = new LookupFunction(columnNames); Iterable<Integer> allColumns = Collections2.transform(columnNames, lookup); Collection<Integer> idColumns; if (inbound.hasPath("id-columns")) { idColumns = ImmutableSet.copyOf( Collections2.transform(inbound.getAnyRefList("id-columns"), lookup)); } else { idColumns = ImmutableSet.of(); } Collection<Integer> ignoredColumns; if (inbound.hasPath("ignored-columns")) { ignoredColumns = ImmutableSet.copyOf( Collections2.transform(inbound.getAnyRefList("ignored-columns"), lookup)); } else { ignoredColumns = ImmutableSet.of(); } Collection<Integer> categoricalColumns; Collection<Integer> numericColumns; if (inbound.hasPath("categorical-columns")) { Preconditions.checkState(!inbound.hasPath("numeric-columns")); categoricalColumns = Sets.newHashSet( Collections2.transform(inbound.getAnyRefList("categorical-columns"), lookup)); numericColumns = Sets.newHashSet(allColumns); numericColumns.removeAll(categoricalColumns); } else if (inbound.hasPath("numeric-columns")) { Preconditions.checkState(!inbound.hasPath("categorical-columns")); numericColumns = Sets.newHashSet( Collections2.transform(inbound.getAnyRefList("numeric-columns"), lookup)); categoricalColumns = Sets.newHashSet(allColumns); categoricalColumns.removeAll(numericColumns); } else { throw new IllegalArgumentException("No categorical-columns or numeric-columns set"); } numericColumns.removeAll(idColumns); numericColumns.removeAll(ignoredColumns); categoricalColumns.removeAll(idColumns); categoricalColumns.removeAll(ignoredColumns); Integer targetColumn = null; if (inbound.hasPath("target-column")) { targetColumn = lookup.apply(inbound.getAnyRef("target-column")); Preconditions.checkState(categoricalColumns.contains(targetColumn) || numericColumns.contains(targetColumn), "Target column not specified as numeric or categorical"); } return new InboundSettings(columnNames, idColumns, categoricalColumns, numericColumns, ignoredColumns, targetColumn); } private  InboundSettings(List<String> columnNames,
                          Collection<Integer> idColumns,
                          Collection<Integer> categoricalColumns,
                          Collection<Integer> numericColumns,
                          Collection<Integer> ignoredColumns,
                          Integer targetColumn); }
InboundSettings implements Serializable { public static InboundSettings create(Config config) { Config inbound = config.getConfig("inbound"); List<String> columnNames = inbound.getStringList("column-names"); Function<Object,Integer> lookup = new LookupFunction(columnNames); Iterable<Integer> allColumns = Collections2.transform(columnNames, lookup); Collection<Integer> idColumns; if (inbound.hasPath("id-columns")) { idColumns = ImmutableSet.copyOf( Collections2.transform(inbound.getAnyRefList("id-columns"), lookup)); } else { idColumns = ImmutableSet.of(); } Collection<Integer> ignoredColumns; if (inbound.hasPath("ignored-columns")) { ignoredColumns = ImmutableSet.copyOf( Collections2.transform(inbound.getAnyRefList("ignored-columns"), lookup)); } else { ignoredColumns = ImmutableSet.of(); } Collection<Integer> categoricalColumns; Collection<Integer> numericColumns; if (inbound.hasPath("categorical-columns")) { Preconditions.checkState(!inbound.hasPath("numeric-columns")); categoricalColumns = Sets.newHashSet( Collections2.transform(inbound.getAnyRefList("categorical-columns"), lookup)); numericColumns = Sets.newHashSet(allColumns); numericColumns.removeAll(categoricalColumns); } else if (inbound.hasPath("numeric-columns")) { Preconditions.checkState(!inbound.hasPath("categorical-columns")); numericColumns = Sets.newHashSet( Collections2.transform(inbound.getAnyRefList("numeric-columns"), lookup)); categoricalColumns = Sets.newHashSet(allColumns); categoricalColumns.removeAll(numericColumns); } else { throw new IllegalArgumentException("No categorical-columns or numeric-columns set"); } numericColumns.removeAll(idColumns); numericColumns.removeAll(ignoredColumns); categoricalColumns.removeAll(idColumns); categoricalColumns.removeAll(ignoredColumns); Integer targetColumn = null; if (inbound.hasPath("target-column")) { targetColumn = lookup.apply(inbound.getAnyRef("target-column")); Preconditions.checkState(categoricalColumns.contains(targetColumn) || numericColumns.contains(targetColumn), "Target column not specified as numeric or categorical"); } return new InboundSettings(columnNames, idColumns, categoricalColumns, numericColumns, ignoredColumns, targetColumn); } private  InboundSettings(List<String> columnNames,
                          Collection<Integer> idColumns,
                          Collection<Integer> categoricalColumns,
                          Collection<Integer> numericColumns,
                          Collection<Integer> ignoredColumns,
                          Integer targetColumn); static InboundSettings create(Config config); Function<Object, Integer> getLookupFunction(); List<String> getColumnNames(); Collection<Integer> getIdColumns(); Collection<Integer> getCategoricalColumns(); Collection<Integer> getNumericColumns(); Collection<Integer> getIgnoredColumns(); boolean isIgnored(int col); boolean isNumeric(int index); boolean isCategorical(int index); Integer getTargetColumn(); }
InboundSettings implements Serializable { public static InboundSettings create(Config config) { Config inbound = config.getConfig("inbound"); List<String> columnNames = inbound.getStringList("column-names"); Function<Object,Integer> lookup = new LookupFunction(columnNames); Iterable<Integer> allColumns = Collections2.transform(columnNames, lookup); Collection<Integer> idColumns; if (inbound.hasPath("id-columns")) { idColumns = ImmutableSet.copyOf( Collections2.transform(inbound.getAnyRefList("id-columns"), lookup)); } else { idColumns = ImmutableSet.of(); } Collection<Integer> ignoredColumns; if (inbound.hasPath("ignored-columns")) { ignoredColumns = ImmutableSet.copyOf( Collections2.transform(inbound.getAnyRefList("ignored-columns"), lookup)); } else { ignoredColumns = ImmutableSet.of(); } Collection<Integer> categoricalColumns; Collection<Integer> numericColumns; if (inbound.hasPath("categorical-columns")) { Preconditions.checkState(!inbound.hasPath("numeric-columns")); categoricalColumns = Sets.newHashSet( Collections2.transform(inbound.getAnyRefList("categorical-columns"), lookup)); numericColumns = Sets.newHashSet(allColumns); numericColumns.removeAll(categoricalColumns); } else if (inbound.hasPath("numeric-columns")) { Preconditions.checkState(!inbound.hasPath("categorical-columns")); numericColumns = Sets.newHashSet( Collections2.transform(inbound.getAnyRefList("numeric-columns"), lookup)); categoricalColumns = Sets.newHashSet(allColumns); categoricalColumns.removeAll(numericColumns); } else { throw new IllegalArgumentException("No categorical-columns or numeric-columns set"); } numericColumns.removeAll(idColumns); numericColumns.removeAll(ignoredColumns); categoricalColumns.removeAll(idColumns); categoricalColumns.removeAll(ignoredColumns); Integer targetColumn = null; if (inbound.hasPath("target-column")) { targetColumn = lookup.apply(inbound.getAnyRef("target-column")); Preconditions.checkState(categoricalColumns.contains(targetColumn) || numericColumns.contains(targetColumn), "Target column not specified as numeric or categorical"); } return new InboundSettings(columnNames, idColumns, categoricalColumns, numericColumns, ignoredColumns, targetColumn); } private  InboundSettings(List<String> columnNames,
                          Collection<Integer> idColumns,
                          Collection<Integer> categoricalColumns,
                          Collection<Integer> numericColumns,
                          Collection<Integer> ignoredColumns,
                          Integer targetColumn); static InboundSettings create(Config config); Function<Object, Integer> getLookupFunction(); List<String> getColumnNames(); Collection<Integer> getIdColumns(); Collection<Integer> getCategoricalColumns(); Collection<Integer> getNumericColumns(); Collection<Integer> getIgnoredColumns(); boolean isIgnored(int col); boolean isNumeric(int index); boolean isCategorical(int index); Integer getTargetColumn();  }