if (codigoDeBarras.length()!= 44){
throw new IllegalArgumentException("O código de barras" +
" precisa ter 44 digitos");
}
GeradorDeDigito dvGenerator = banco.getGeradorDeDigito();
StringBuilder builder = new StringBuilder();
builder.append(codigoDeBarras.substring(0, 3));
builder.append(codigoDeBarras.substring(3, 4));
builder.append(codigoDeBarras.substring(19, 24));
builder.append(dvGenerator.geraDigitoMod10(builder.toString()));
builder.append(codigoDeBarras.substring(24, 34));
builder.append(dvGenerator.geraDigitoMod10(builder.substring(10, 20)));
builder.append(codigoDeBarras.substring(34));
builder.append(dvGenerator.geraDigitoMod10(builder.substring(21, 31)));
builder.append(codigoDeBarras.substring(4, 5));
builder.append(codigoDeBarras.substring(5, 9));
builder.append(codigoDeBarras.substring(9, 19));
return formata(builder).toString();