Source:
public MethodsGroupBuilder methodWithExplicitJavaTypes(String methodName, List<Optional<Class<?>>> types) { requireNonNull(methodName, "methodName is null"); List<MethodAndNativeContainerTypes> matchingMethod = asList(clazz.getMethods()).stream() .filter(method -> methodName.equals(method.getName())) .map(method -> new MethodAndNativeContainerTypes(method, types)) .collect(toImmutableList()); checkState(!matchingMethod.isEmpty(), "method %s was not found in %s", methodName, clazz); checkState(matchingMethod.size() == 1, "multiple methods %s was not found in %s", methodName, clazz); MethodAndNativeContainerTypes methodAndNativeContainerTypes = matchingMethod.get(0); int argumentSize = signature.getArgumentTypes().size(); checkState(types.size() == argumentSize, "not matching number of arguments from signature: %s (should have %s)", types.size(), argumentSize); checkState(types.size() == argumentProperties.size(), "not matching number of arguments from argument properties: %s (should have %s)", types.size(), argumentProperties.size()); Iterator<ArgumentProperty> argumentPropertyIterator = argumentProperties.iterator(); Iterator<Optional<Class<?>>> typesIterator = types.iterator(); while (argumentPropertyIterator.hasNext() && typesIterator.hasNext()) { Optional<Class<?>> classOptional = typesIterator.next(); ArgumentProperty argumentProperty = argumentPropertyIterator.next(); if (classOptional.isPresent()) { checkState(argumentProperty.getNullConvention() == BLOCK_AND_POSITION, "Null convention should be BLOCK_AND_POSITION"); } if (argumentProperty.getNullConvention() == BLOCK_AND_POSITION) { checkState(classOptional.isPresent(), "Explicit type is not set when null convention is BLOCK_AND_POSITION"); } } methodAndNativeContainerTypesList.add(methodAndNativeContainerTypes); return this; }

Target:
public MethodsGroupBuilder methodWithExplicitJavaTypes(String methodName, List<Optional<Class<?>>> types) { requireNonNull(methodName, "methodName is null"); List<MethodAndNativeContainerTypes> matchingMethod = asList(clazz.getMethods()).stream() .filter(method -> methodName.equals(method.getName())) .map(method -> new MethodAndNativeContainerTypes(method, types)) .collect(toImmutableList()); checkState(!matchingMethod.isEmpty(), "method %s was not found in %s", methodName, clazz); checkState(matchingMethod.size() == 1, "multiple methods %s was not found in %s", methodName, clazz); MethodAndNativeContainerTypes methodAndNativeContainerTypes = matchingMethod.get(0); int argumentSize = signature.getArgumentTypes().size(); checkState(types.size() == argumentSize, "not matching number of arguments from signature: %s (should have %s)", types.size(), argumentSize); checkState(types.size() == argumentProperties.size(), "not matching number of arguments from argument properties: %s (should have %s)", types.size(), argumentProperties.size()); Iterator<ArgumentProperty> argumentPropertyIterator = argumentProperties.iterator(); Iterator<Optional<Class<?>>> typesIterator = types.iterator(); while (argumentPropertyIterator.hasNext() && typesIterator.hasNext()) { Optional<Class<?>> classOptional = typesIterator.next(); ArgumentProperty argumentProperty = argumentPropertyIterator.next(); checkState((argumentProperty.getNullConvention() == BLOCK_AND_POSITION) == classOptional.isPresent(), "Explicit type is not set when null convention is BLOCK_AND_POSITION"); } methodAndNativeContainerTypesList.add(methodAndNativeContainerTypes); return this; }