@Test public void filtering() { when(field1.getName()).thenReturn("field1"); when(field2.getName()).thenReturn("field2"); final ActionFieldList afl = new ActionInsertFact(); final ActionFieldValue afv = new ActionFieldValue(); afv.setField("field1"); afl.addFieldValue(afv); final ModelField[] result = ModelFieldUtil.getAvailableFieldCompletions(new ModelField[]{field1, field2}, afl); assertEquals(1, result.length); assertEquals(field2, result[0]); }
public static ModelField[] getAvailableFieldCompletions(final ModelField[] fieldCompletions, final ActionFieldList afl) { if (fieldCompletions == null || fieldCompletions.length == 0) { return fieldCompletions; } if (afl == null || afl.getFieldValues().length == 0) { return fieldCompletions; } final List<ModelField> availableModelFields = new ArrayList<>(); availableModelFields.addAll(Arrays.asList(fieldCompletions)); for (ActionFieldValue afv : afl.getFieldValues()) { final List<ModelField> usedModelFields = availableModelFields.stream().filter(m -> m.getName().equals(afv.getField())).collect(Collectors.toList()); availableModelFields.removeAll(usedModelFields); } return availableModelFields.toArray(new ModelField[availableModelFields.size()]); }
ModelFieldUtil { public static ModelField[] getAvailableFieldCompletions(final ModelField[] fieldCompletions, final ActionFieldList afl) { if (fieldCompletions == null || fieldCompletions.length == 0) { return fieldCompletions; } if (afl == null || afl.getFieldValues().length == 0) { return fieldCompletions; } final List<ModelField> availableModelFields = new ArrayList<>(); availableModelFields.addAll(Arrays.asList(fieldCompletions)); for (ActionFieldValue afv : afl.getFieldValues()) { final List<ModelField> usedModelFields = availableModelFields.stream().filter(m -> m.getName().equals(afv.getField())).collect(Collectors.toList()); availableModelFields.removeAll(usedModelFields); } return availableModelFields.toArray(new ModelField[availableModelFields.size()]); } }
ModelFieldUtil { public static ModelField[] getAvailableFieldCompletions(final ModelField[] fieldCompletions, final ActionFieldList afl) { if (fieldCompletions == null || fieldCompletions.length == 0) { return fieldCompletions; } if (afl == null || afl.getFieldValues().length == 0) { return fieldCompletions; } final List<ModelField> availableModelFields = new ArrayList<>(); availableModelFields.addAll(Arrays.asList(fieldCompletions)); for (ActionFieldValue afv : afl.getFieldValues()) { final List<ModelField> usedModelFields = availableModelFields.stream().filter(m -> m.getName().equals(afv.getField())).collect(Collectors.toList()); availableModelFields.removeAll(usedModelFields); } return availableModelFields.toArray(new ModelField[availableModelFields.size()]); }  }
ModelFieldUtil { public static ModelField[] getAvailableFieldCompletions(final ModelField[] fieldCompletions, final ActionFieldList afl) { if (fieldCompletions == null || fieldCompletions.length == 0) { return fieldCompletions; } if (afl == null || afl.getFieldValues().length == 0) { return fieldCompletions; } final List<ModelField> availableModelFields = new ArrayList<>(); availableModelFields.addAll(Arrays.asList(fieldCompletions)); for (ActionFieldValue afv : afl.getFieldValues()) { final List<ModelField> usedModelFields = availableModelFields.stream().filter(m -> m.getName().equals(afv.getField())).collect(Collectors.toList()); availableModelFields.removeAll(usedModelFields); } return availableModelFields.toArray(new ModelField[availableModelFields.size()]); }  static ModelField[] getAvailableFieldCompletions(final ModelField[] fieldCompletions,
                                                            final ActionFieldList afl); static ModelField modelField(final String fieldName,
                                        final String fieldDataType); }
ModelFieldUtil { public static ModelField[] getAvailableFieldCompletions(final ModelField[] fieldCompletions, final ActionFieldList afl) { if (fieldCompletions == null || fieldCompletions.length == 0) { return fieldCompletions; } if (afl == null || afl.getFieldValues().length == 0) { return fieldCompletions; } final List<ModelField> availableModelFields = new ArrayList<>(); availableModelFields.addAll(Arrays.asList(fieldCompletions)); for (ActionFieldValue afv : afl.getFieldValues()) { final List<ModelField> usedModelFields = availableModelFields.stream().filter(m -> m.getName().equals(afv.getField())).collect(Collectors.toList()); availableModelFields.removeAll(usedModelFields); } return availableModelFields.toArray(new ModelField[availableModelFields.size()]); }  static ModelField[] getAvailableFieldCompletions(final ModelField[] fieldCompletions,
                                                            final ActionFieldList afl); static ModelField modelField(final String fieldName,
                                        final String fieldDataType);  }