@Test void merge_notContradictoryForField() { RowSpec left = new RowSpec(fields, ImmutableMap.of(A, isNull), Collections.emptyList()); RowSpec right = new RowSpec(fields, ImmutableMap.of(A, isNull), Collections.emptyList()); RowSpec merged = rowSpecMerger.merge(left, right).get(); assertEquals(merged.getSpecForField(A), isNull); }
public Optional<RowSpec> merge(RowSpec left, RowSpec right) { Map<Field, FieldSpec> newMap = new HashMap<>(); for (Field field : left.getFields()) { Optional<FieldSpec> merge = fieldSpecMerger.merge(left.getSpecForField(field), right.getSpecForField(field), false); if (!merge.isPresent()){ return Optional.empty(); } newMap.put(field, merge.get()); } List<FieldSpecRelation> relations = new ArrayList<>( SetUtils.union(left.getRelations(), right.getRelations())); return Optional.of(new RowSpec(left.getFields(), newMap, relations)); }
RowSpecMerger { public Optional<RowSpec> merge(RowSpec left, RowSpec right) { Map<Field, FieldSpec> newMap = new HashMap<>(); for (Field field : left.getFields()) { Optional<FieldSpec> merge = fieldSpecMerger.merge(left.getSpecForField(field), right.getSpecForField(field), false); if (!merge.isPresent()){ return Optional.empty(); } newMap.put(field, merge.get()); } List<FieldSpecRelation> relations = new ArrayList<>( SetUtils.union(left.getRelations(), right.getRelations())); return Optional.of(new RowSpec(left.getFields(), newMap, relations)); } }
RowSpecMerger { public Optional<RowSpec> merge(RowSpec left, RowSpec right) { Map<Field, FieldSpec> newMap = new HashMap<>(); for (Field field : left.getFields()) { Optional<FieldSpec> merge = fieldSpecMerger.merge(left.getSpecForField(field), right.getSpecForField(field), false); if (!merge.isPresent()){ return Optional.empty(); } newMap.put(field, merge.get()); } List<FieldSpecRelation> relations = new ArrayList<>( SetUtils.union(left.getRelations(), right.getRelations())); return Optional.of(new RowSpec(left.getFields(), newMap, relations)); } @Inject  RowSpecMerger(FieldSpecMerger fieldSpecMerger); }
RowSpecMerger { public Optional<RowSpec> merge(RowSpec left, RowSpec right) { Map<Field, FieldSpec> newMap = new HashMap<>(); for (Field field : left.getFields()) { Optional<FieldSpec> merge = fieldSpecMerger.merge(left.getSpecForField(field), right.getSpecForField(field), false); if (!merge.isPresent()){ return Optional.empty(); } newMap.put(field, merge.get()); } List<FieldSpecRelation> relations = new ArrayList<>( SetUtils.union(left.getRelations(), right.getRelations())); return Optional.of(new RowSpec(left.getFields(), newMap, relations)); } @Inject  RowSpecMerger(FieldSpecMerger fieldSpecMerger); Optional<RowSpec> merge(RowSpec left, RowSpec right); }
RowSpecMerger { public Optional<RowSpec> merge(RowSpec left, RowSpec right) { Map<Field, FieldSpec> newMap = new HashMap<>(); for (Field field : left.getFields()) { Optional<FieldSpec> merge = fieldSpecMerger.merge(left.getSpecForField(field), right.getSpecForField(field), false); if (!merge.isPresent()){ return Optional.empty(); } newMap.put(field, merge.get()); } List<FieldSpecRelation> relations = new ArrayList<>( SetUtils.union(left.getRelations(), right.getRelations())); return Optional.of(new RowSpec(left.getFields(), newMap, relations)); } @Inject  RowSpecMerger(FieldSpecMerger fieldSpecMerger); Optional<RowSpec> merge(RowSpec left, RowSpec right);  }