PipelineInfo { public int getUnusedBindingNumber() { List<Integer> bindings = dictionary.entrySet().stream() .filter(item -> item.getValue().getAsJsonObject().has("binding")) .map(item -> item.getValue().getAsJsonObject() .get("binding").getAsInt()).collect(Collectors.toList()); for (int number = 0; number < Integer.MAX_VALUE; number++) { if (!bindings.contains(number)) { return number; } } throw new RuntimeException("Unreachable code. MAX_VALUE should never been used in bindings."); } private  PipelineInfo(JsonObject dictionary);  PipelineInfo();  PipelineInfo(File file);  PipelineInfo(String string); void addUniform(String name, BasicType basicType,
                         Optional<Integer> arrayCount, List<? extends Number> values); void addUniform(String name, SamplerType samplerType, BuiltInTexture value); boolean hasUniform(String uniformName); @Override String toString(); void setUniforms(TranslationUnit tu,
      Supplier<Float> floatSupplier, Supplier<Integer> intSupplier,
      Supplier<Integer> uintSupplier,
      Supplier<Integer> boolSupplier,
      Supplier<BuiltInTexture> textureSupplier); void zeroUnsetUniforms(TranslationUnit tu); void addUniformBinding(String uniformName, boolean pushConstant, int number); void removeUniformBinding(String uniformName); int appendValueToUniform(String uniformName, Number value); List<String> getUniformNames(); int getNumUniforms(); void removeUniform(String uniformName); PipelineInfo renameUniforms(Map<String, String> uniformMapping); List<String> getArgs(String uniformName); boolean hasBindingOrIsPushConstant(String uniformName); boolean hasBinding(String uniformName); boolean isPushConstant(String uniformName); boolean isSampler(String uniformName); int getBinding(String uniformName); void addComputeInfo(int numGroupsX, int numGroupsY, int numGroupsZ,
                             int ssboBinding,
                             List<SsboFieldData> ssboFields); boolean hasGridInfo(); int getGridColumns(); int getGridRows(); void addGridInfo(int columns, int rows); int getUnusedBindingNumber(); void addSamplerInfo(String name, String samplerType, String textureName); @Override PipelineInfo clone();  }
@Test public void testGetUnusedBindingNumber() { final PipelineInfo pipelineInfo = new PipelineInfo(); assertEquals(pipelineInfo.getUnusedBindingNumber(), 0); pipelineInfo.addUniform("A", BasicType.INT, Optional.of(0), new ArrayList<>()); pipelineInfo.addUniformBinding("A", false, pipelineInfo.getUnusedBindingNumber()); assertEquals(pipelineInfo.getBinding("A"), 0); assertEquals(pipelineInfo.getUnusedBindingNumber(), 1); pipelineInfo.addUniform("B", BasicType.INT, Optional.of(0), new ArrayList<>()); pipelineInfo.addUniformBinding("B", false, pipelineInfo.getUnusedBindingNumber()); assertEquals(pipelineInfo.getBinding("B"), 1); assertEquals(pipelineInfo.getUnusedBindingNumber(), 2); pipelineInfo.addUniform("C", BasicType.INT, Optional.of(0), new ArrayList<>()); pipelineInfo.addUniformBinding("C", false, pipelineInfo.getUnusedBindingNumber()); assertEquals(pipelineInfo.getBinding("C"), 2); assertEquals(pipelineInfo.getUnusedBindingNumber(), 3); pipelineInfo.removeUniform("B"); assertEquals(pipelineInfo.getUnusedBindingNumber(), 1); pipelineInfo.addUniform("D", BasicType.INT, Optional.of(0), new ArrayList<>()); pipelineInfo.addUniformBinding("D", false, pipelineInfo.getUnusedBindingNumber()); assertEquals(pipelineInfo.getBinding("D"), 1); assertEquals(pipelineInfo.getUnusedBindingNumber(), 3); }