@Test public void fieldTestNull() throws IOException { BundleFilterRandomField bfrf = Configs.decodeObject( BundleFilterRandomField.class, "{op:\"random-field\", inFields:[\"f0\", \"f1\"], " + "out:\"out0\"}"); MapBundle bundle = MapBundle.createBundle(new String[]{"f0", null, "f1", "bar"}); bfrf.filter(bundle); assertEquals("bar", bundle.get("out0")); }
@Override public boolean filter(Bundle bundle) { List<AutoField> inFieldsShuffle = new ArrayList<>(Arrays.asList(inFields)); Collections.shuffle(inFieldsShuffle); for (AutoField bf : inFieldsShuffle) { if (bf != null && bf.getValue(bundle) != null) { out.setValue(bundle, bf.getValue(bundle)); break; } } return true; }
BundleFilterRandomField implements BundleFilter { @Override public boolean filter(Bundle bundle) { List<AutoField> inFieldsShuffle = new ArrayList<>(Arrays.asList(inFields)); Collections.shuffle(inFieldsShuffle); for (AutoField bf : inFieldsShuffle) { if (bf != null && bf.getValue(bundle) != null) { out.setValue(bundle, bf.getValue(bundle)); break; } } return true; } }
BundleFilterRandomField implements BundleFilter { @Override public boolean filter(Bundle bundle) { List<AutoField> inFieldsShuffle = new ArrayList<>(Arrays.asList(inFields)); Collections.shuffle(inFieldsShuffle); for (AutoField bf : inFieldsShuffle) { if (bf != null && bf.getValue(bundle) != null) { out.setValue(bundle, bf.getValue(bundle)); break; } } return true; } @JsonCreator  BundleFilterRandomField(@JsonProperty(value = "inFields", required = true) AutoField[] inFields,
                                   @JsonProperty(value = "out", required = true) AutoField out); }
BundleFilterRandomField implements BundleFilter { @Override public boolean filter(Bundle bundle) { List<AutoField> inFieldsShuffle = new ArrayList<>(Arrays.asList(inFields)); Collections.shuffle(inFieldsShuffle); for (AutoField bf : inFieldsShuffle) { if (bf != null && bf.getValue(bundle) != null) { out.setValue(bundle, bf.getValue(bundle)); break; } } return true; } @JsonCreator  BundleFilterRandomField(@JsonProperty(value = "inFields", required = true) AutoField[] inFields,
                                   @JsonProperty(value = "out", required = true) AutoField out); @Override boolean filter(Bundle bundle); }
BundleFilterRandomField implements BundleFilter { @Override public boolean filter(Bundle bundle) { List<AutoField> inFieldsShuffle = new ArrayList<>(Arrays.asList(inFields)); Collections.shuffle(inFieldsShuffle); for (AutoField bf : inFieldsShuffle) { if (bf != null && bf.getValue(bundle) != null) { out.setValue(bundle, bf.getValue(bundle)); break; } } return true; } @JsonCreator  BundleFilterRandomField(@JsonProperty(value = "inFields", required = true) AutoField[] inFields,
                                   @JsonProperty(value = "out", required = true) AutoField out); @Override boolean filter(Bundle bundle);  }