TypeSupplier implements Supplier<Type> { @Override public Type get() { if (types.size() > 1) { throw new SemanticAnalysisException( String.format("Field [%s] have conflict type [%s]", symbolName, types)); } else { return symbolType; } } TypeSupplier(String symbolName, Type symbolType); TypeSupplier add(Type type); @Override Type get();  }
@Test public void haveOneTypeShouldPass() { TypeSupplier age = new TypeSupplier("age", ESDataType.INTEGER); assertEquals(ESDataType.INTEGER, age.get()); }