@Override public String getByteLengthFunctionName(FieldModel typeRef) { if (typeRef.isMessage()) { return "gax.createByteLengthFunction(protoFilesRoot.lookup('" + typeRef.getTypeFullName() + "'))"; } else if (typeRef.isString() || typeRef.isBytes()) { return "s => s.length"; } else { // There is no easy way to say the actual length of the numeric fields. // For now throwing an exception. throw new IllegalArgumentException( "Can't determine the byte length function for " + typeRef.getKind()); } }