_id
stringlengths
2
7
title
stringlengths
3
140
partition
stringclasses
3 values
text
stringlengths
73
34.1k
language
stringclasses
1 value
meta_information
dict
q166100
Auth.form
validation
public Auth form(final String pattern, final Class<? extends Authenticator<UsernamePasswordCredentials>> authenticator) { bindings.put(pattern, (binder, conf) -> { TypeLiteral<Authenticator<UsernamePasswordCredentials>> usernamePasswordAuthenticator = new TypeLiteral<Authenticator<UsernamePasswordCredentials>>() { }; binder.bind(usernamePasswordAuthenticator.getRawType()).to(authenticator); bindProfile(binder, CommonProfile.class); Multibinder.newSetBinder(binder, Client.class) .addBinding().toProvider(FormAuth.class); return new FormFilter(conf.getString("auth.form.loginUrl"), conf.getString("application.path") + authCallbackPath(conf)); }); return this; }
java
{ "resource": "" }
q166101
Auth.basic
validation
public Auth basic(final String pattern, final Class<? extends Authenticator<UsernamePasswordCredentials>> authenticator) { bindings.put(pattern, (binder, config) -> { TypeLiteral<Authenticator<UsernamePasswordCredentials>> usernamePasswordAuthenticator = new TypeLiteral<Authenticator<UsernamePasswordCredentials>>() { }; binder.bind(usernamePasswordAuthenticator.getRawType()).to(authenticator); bindProfile(binder, CommonProfile.class); Multibinder.newSetBinder(binder, Client.class) .addBinding().toProvider(BasicAuth.class); return new AuthFilter(IndirectBasicAuthClient.class, CommonProfile.class); }); return this; }
java
{ "resource": "" }
q166102
Deferred.resolve
validation
public void resolve(@Nullable final Object value) { if (value == null) { handler.handle(null, null); } else { Result result; if (value instanceof Result) { super.set(value); result = (Result) value; } else { super.set(value); result = clone(); } handler.handle(result, null); } }
java
{ "resource": "" }
q166103
Raml.path
validation
public RamlPath path(String pattern) { RamlPath path = resources.get(pattern); if (path == null) { path = new RamlPath(); resources.put(pattern, path); } return path; }
java
{ "resource": "" }
q166104
Raml.define
validation
public RamlType define(Type type) { if (types == null) { types = new LinkedHashMap<>(); } Type componentType = componentType(type); String typeName = MoreTypes.getRawType(componentType).getSimpleName(); RamlType ramlType = RamlType.valueOf(typeName); if (ramlType.isObject()) { RamlType existing = types.get(typeName); if (existing == null) { ModelConverters converter = ModelConverters.getInstance(); Property property = converter.readAsProperty(componentType); Map<PropertyBuilder.PropertyId, Object> args = new EnumMap<>( PropertyBuilder.PropertyId.class); for (Map.Entry<String, Model> entry : converter.readAll(componentType).entrySet()) { define(entry.getKey(), entry.getValue()); } ramlType = define(typeName, PropertyBuilder.toModel(PropertyBuilder.merge(property, args))); } else { ramlType = existing; } } return type != componentType ? ramlType.toArray() : ramlType; }
java
{ "resource": "" }
q166105
Raml.toYaml
validation
public String toYaml() throws IOException { YAMLMapper mapper = new YAMLMapper(); mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); mapper.configure(YAMLGenerator.Feature.ALWAYS_QUOTE_NUMBERS_AS_STRINGS, false); mapper.configure(YAMLGenerator.Feature.MINIMIZE_QUOTES, true); return "#%RAML 1.0\n" + mapper.writer().withDefaultPrettyPrinter().writeValueAsString(this); }
java
{ "resource": "" }
q166106
RouteResponse.status
validation
public Map<Integer, String> status() { return Optional.ofNullable(status).orElse(ImmutableMap.of()); }
java
{ "resource": "" }
q166107
RouteResponse.statusCode
validation
public int statusCode() { return status().entrySet().stream() .map(it -> it.getKey()) .filter(code -> code >= 200 && code < 400) .findFirst() .orElseGet(() -> type() == void.class ? 204 : 200); }
java
{ "resource": "" }
q166108
RouteResponse.status
validation
public RouteResponse status(final Map<Integer, String> status) { if (status != null) { if (this.status == null) { this.status = new LinkedHashMap<>(); this.status.putAll(status); } } return this; }
java
{ "resource": "" }
q166109
RamlResponse.setMediaType
validation
public void setMediaType(final String mediaType, RamlType body) { if (this.mediaType == null) { this.mediaType = new LinkedHashMap<>(); } this.mediaType.put(mediaType, body); }
java
{ "resource": "" }
q166110
Ebeanby.runEnhancer
validation
static Throwing.Runnable runEnhancer() { return () -> { Set<String> packages = PKG.getAndSet(null); if (packages != null) { EbeanEnhancer.newEnhancer().run(packages); } }; }
java
{ "resource": "" }
q166111
RamlMethod.setMediaType
validation
public void setMediaType(final List<String> mediaType) { this.mediaType = mediaType == null ? null : (mediaType.isEmpty() ? null : mediaType); }
java
{ "resource": "" }
q166112
RamlMethod.queryParameter
validation
public RamlParameter queryParameter(String name) { if (queryParameters == null) { queryParameters = new LinkedHashMap<>(); } RamlParameter param = queryParameters.get(name); if (param == null) { param = new RamlParameter(name); queryParameters.put(name, param); } return param; }
java
{ "resource": "" }
q166113
RamlMethod.formParameter
validation
public RamlParameter formParameter(String name) { if (formParameters == null) { formParameters = new LinkedHashMap<>(); } RamlParameter param = formParameters.get(name); if (param == null) { param = new RamlParameter(name); formParameters.put(name, param); } return param; }
java
{ "resource": "" }
q166114
RamlMethod.headerParameter
validation
public RamlParameter headerParameter(String name) { if (headers == null) { headers = new LinkedHashMap<>(); } RamlParameter param = headers.get(name); if (param == null) { param = new RamlParameter(name); headers.put(name, param); } return param; }
java
{ "resource": "" }
q166115
RamlMethod.response
validation
public RamlResponse response(Integer status) { if (responses == null) { responses = new LinkedHashMap<>(); } RamlResponse response = responses.get(status); if (response == null) { response = new RamlResponse(); responses.put(status, response); } return response; }
java
{ "resource": "" }
q166116
Hbv.doWith
validation
public Hbv doWith(final Consumer<HibernateValidatorConfiguration> configurer) { requireNonNull(configurer, "Configurer callback is required."); this.configurer = (hvc, conf) -> configurer.accept(hvc); return this; }
java
{ "resource": "" }
q166117
ReaderInputStream.read
validation
@Override public int read(final byte[] b, int off, int len) throws IOException { int read = 0; while (len > 0) { if (encoderOut.position() > 0) { encoderOut.flip(); int c = Math.min(encoderOut.remaining(), len); encoderOut.get(b, off, c); off += c; len -= c; read += c; encoderOut.compact(); } else { if (!endOfInput && (lastCoderResult == null || lastCoderResult.isUnderflow())) { encoderIn.compact(); int position = encoderIn.position(); // We don't use Reader#read(CharBuffer) here because it is more efficient // to write directly to the underlying char array (the default implementation // copies data to a temporary char array). int c = reader.read(encoderIn.array(), position, encoderIn.remaining()); if (c == -1) { endOfInput = true; } else { encoderIn.position(position + c); } encoderIn.flip(); } lastCoderResult = encoder.encode(encoderIn, encoderOut, endOfInput); if (endOfInput && encoderOut.position() == 0) { break; } } } return read == 0 && endOfInput ? -1 : read; }
java
{ "resource": "" }
q166118
Requery.reactive
validation
public static Requery reactive(final String name, final EntityModel model) { return new Requery(name, ReactiveEntityStore.class, model, conf -> ReactiveSupport.toReactiveStore(new EntityDataStore<>(conf))); }
java
{ "resource": "" }
q166119
Requery.reactor
validation
public static Requery reactor(final String name, final EntityModel model) { return new Requery(name, ReactorEntityStore.class, model, conf -> new ReactorEntityStore<>(new EntityDataStore<>(conf))); }
java
{ "resource": "" }
q166120
Requery.completionStage
validation
public static Requery completionStage(final String name, final EntityModel model) { return new Requery(name, CompletionStageEntityStore.class, model, conf -> new CompletableEntityStore(new EntityDataStore<>(conf))); }
java
{ "resource": "" }
q166121
Requery.kotlin
validation
public static Requery kotlin(final String name, final EntityModel model) { return new Requery(name, KotlinEntityDataStore.class, model, conf -> new KotlinEntityDataStore<>(conf)); }
java
{ "resource": "" }
q166122
XSS.js
validation
public XSS js(final JavaScriptEscapeType type, final JavaScriptEscapeLevel level) { this.jslevel = requireNonNull(level, "Level required."); this.jstype = requireNonNull(type, "Type required."); return this; }
java
{ "resource": "" }
q166123
XSS.html
validation
public XSS html(final HtmlEscapeType type, final HtmlEscapeLevel level) { this.htmllevel = requireNonNull(level, "Level required."); this.htmltype = requireNonNull(type, "Type required."); return this; }
java
{ "resource": "" }
q166124
XSS.json
validation
public XSS json(final JsonEscapeType type, final JsonEscapeLevel level) { this.jsonlevel = requireNonNull(level, "Level required."); this.jsontype = requireNonNull(type, "Type required."); return this; }
java
{ "resource": "" }
q166125
XSS.css
validation
public XSS css(final CssStringEscapeType type, final CssStringEscapeLevel level) { this.csslevel = requireNonNull(level, "Level required."); this.csstype = requireNonNull(type, "Type required."); return this; }
java
{ "resource": "" }
q166126
SvgSymbol.attrs
validation
private Map<String, Object> attrs(final String path, final String... without) { Map<String, Object> attrs = new LinkedHashMap<>(get(path)); Arrays.asList(without).forEach(attrs::remove); return attrs; }
java
{ "resource": "" }
q166127
SvgSymbol.css
validation
private CharSequence css(final String id, final Element svg) { Throwing.Function<String, Tuple<Tuple<Number, String>, Tuple<Number, String>>> viewBox = Throwing .<String, Tuple<Tuple<Number, String>, Tuple<Number, String>>>throwingFunction(name -> { String vbox = svg.attr(name); String[] dimension = vbox.split("\\s+"); return new Tuple(parse(dimension[2]), parse(dimension[_3])); }).memoized(); Tuple<Number, String> w = Optional.ofNullable(Strings.emptyToNull(svg.attr("width"))) .map(this::parse) .orElseGet(() -> viewBox.apply("viewBox")._1); Tuple<Number, String> h = Optional.ofNullable(Strings.emptyToNull(svg.attr("height"))) .map(this::parse) .orElseGet(() -> viewBox.apply("viewBox")._2); StringBuilder css = new StringBuilder(); css.append(get("css.prefix").toString()).append(".").append(id) .append(" {\n width: ").append(w._1).append(w._2).append(";\n") .append(" height: ").append(h._1).append(h._2).append(";\n}"); return css; }
java
{ "resource": "" }
q166128
SvgSymbol.parse
validation
private Tuple<Number, String> parse(final String value) { Matcher matcher = SIZE.matcher(value); if (matcher.find()) { String number = matcher.group(1); String unit = matcher.group(_3); boolean round = get("css.round"); Number num = Double.parseDouble(number); return new Tuple(round ? Math.round(num.doubleValue()) : num, unit); } return null; }
java
{ "resource": "" }
q166129
SvgSymbol.write
validation
private void write(final Path path, final List<CharSequence> sequence) throws IOException { log.debug("writing: {}", path.normalize().toAbsolutePath()); path.toFile().getParentFile().mkdirs(); Files.write(path, sequence); }
java
{ "resource": "" }
q166130
TransactionalRequest.handle
validation
public TransactionalRequest handle(String name) { this.handleKey = Key.get(Handle.class, Names.named(name)); return this; }
java
{ "resource": "" }
q166131
SwaggerBuilder.doModel
validation
private Model doModel(Type type, Model model) { Map<String, Property> properties = model.getProperties(); if (properties != null) { BeanDescription desc = Json.mapper().getSerializationConfig() .introspect(Json.mapper().constructType(type)); for (BeanPropertyDefinition beanProperty : desc.findProperties()) { Property property = properties.get(beanProperty.getName()); if (property != null) { property.setRequired(beanProperty.isRequired()); } } } return model; }
java
{ "resource": "" }
q166132
Sse.lastEventId
validation
@Nonnull public <T> Optional<T> lastEventId(final Class<T> type) { return lastEventId.toOptional(type); }
java
{ "resource": "" }
q166133
Sse.send
validation
@Nonnull public CompletableFuture<Optional<Object>> send(final Object data) { return event(data).send(); }
java
{ "resource": "" }
q166134
View.put
validation
@Nonnull public View put(final String name, final Object value) { requireNonNull(name, "Model name is required."); model.put(name, value); return this; }
java
{ "resource": "" }
q166135
View.put
validation
@Nonnull public View put(final Map<String, ?> values) { values.forEach((k, v) -> model.put(k, v)); return this; }
java
{ "resource": "" }
q166136
AssetClassLoader.classLoader
validation
public static ClassLoader classLoader(final ClassLoader parent) throws IOException { return classLoader(parent, new File(System.getProperty("user.dir"))); }
java
{ "resource": "" }
q166137
AssetClassLoader.classLoader
validation
public static ClassLoader classLoader(final ClassLoader parent, File projectDir) throws IOException { requireNonNull(parent, "ClassLoader required."); File publicDir = new File(projectDir, "public"); if(publicDir.exists()) { return new URLClassLoader(new URL[]{publicDir.toURI().toURL()}, parent); } return parent; }
java
{ "resource": "" }
q166138
RouteMethod.attributes
validation
public RouteMethod attributes(Map<String, Object> attributes) { if (attributes != null) { if (this.attributes == null) { this.attributes = new LinkedHashMap<>(); } this.attributes.putAll(attributes); } return this; }
java
{ "resource": "" }
q166139
RouteMethod.attribute
validation
public RouteMethod attribute(String name, Object value) { if (this.attributes == null) { this.attributes = new LinkedHashMap<>(); } this.attributes.put(name, value); return this; }
java
{ "resource": "" }
q166140
RouteMethod.param
validation
public RouteMethod param(String name, Consumer<RouteParameter> customizer) { parameters().stream() .filter(p -> name.equals(p.name())) .findFirst() .ifPresent(customizer); return this; }
java
{ "resource": "" }
q166141
Status.valueOf
validation
public static Status valueOf(final int statusCode) { Integer key = Integer.valueOf(statusCode); Status status = statusMap.get(key); return status == null? new Status(key, key.toString()) : status; }
java
{ "resource": "" }
q166142
Jdbi3.doWith
validation
public Jdbi3 doWith(Consumer<Jdbi> configurer) { return doWith((jdbi, conf) -> configurer.accept(jdbi)); }
java
{ "resource": "" }
q166143
ExpandedStmtRewriter.rewrite
validation
@Override public RewrittenStatement rewrite(final String sql, final Binding params, final StatementContext ctx) { final ParsedStatement stmt = new ParsedStatement(); try { final String parsedSql = parseString(sql, stmt, params); return new MyRewrittenStatement(parsedSql, stmt, ctx); } catch (IllegalArgumentException e) { throw new UnableToCreateStatementException( "Exception parsing for named parameter replacement", e, ctx); } }
java
{ "resource": "" }
q166144
AssetHandler.send
validation
protected void send(final Request req, final Response rsp, final Asset asset) throws Throwable { rsp.send(asset); }
java
{ "resource": "" }
q166145
Jdbi.doWith
validation
public Jdbi doWith(Consumer<DBI> configurer) { return doWith((dbi, conf) -> configurer.accept(dbi)); }
java
{ "resource": "" }
q166146
jOOQ.doWith
validation
public jOOQ doWith(Consumer<Configuration> configurer) { return doWith((configuration, conf) -> configurer.accept(configuration)); }
java
{ "resource": "" }
q166147
Quartz.with
validation
public Quartz with(final JobDetail job, final Trigger trigger) { requireNonNull(job, "Job is required."); requireNonNull(trigger, "Trigger is required."); jobMap.put(job, trigger); return this; }
java
{ "resource": "" }
q166148
Quartz.with
validation
public Quartz with(final Class<? extends Job> jobClass, final BiConsumer<JobBuilder, TriggerBuilder<Trigger>> configurer) { requireNonNull(jobClass, "Job class is required."); JobBuilder job = JobBuilder.newJob(jobClass) .withIdentity( JobKey.jobKey(jobClass.getSimpleName(), jobClass.getPackage().getName()) ); TriggerBuilder<Trigger> trigger = TriggerBuilder.newTrigger() .withIdentity( TriggerKey.triggerKey(jobClass.getSimpleName(), jobClass.getPackage().getName()) ); configurer.accept(job, trigger); return with(job.build(), trigger.build()); }
java
{ "resource": "" }
q166149
NettyServer.shutdownGracefully
validation
private void shutdownGracefully(final Iterator<EventExecutorGroup> iterator) { if (iterator.hasNext()) { EventExecutorGroup group = iterator.next(); if (!group.isShuttingDown()) { group.shutdownGracefully().addListener(future -> { if (!future.isSuccess()) { log.debug("shutdown of {} resulted in exception", group, future.cause()); } shutdownGracefully(iterator); }); } } }
java
{ "resource": "" }
q166150
Cassandra.doWithCluster
validation
public Cassandra doWithCluster(final Consumer<Cluster> configurer) { requireNonNull(configurer, "Cluster conf callbackrequired."); return doWithCluster((cc, c) -> configurer.accept(cc)); }
java
{ "resource": "" }
q166151
Results.with
validation
@Nonnull public static Result with(final Status status) { requireNonNull(status, "A HTTP status is required."); return new Result().status(status); }
java
{ "resource": "" }
q166152
Jackson.module
validation
public Jackson module(final Module module) { requireNonNull(module, "Jackson Module is required."); modules.add(binder -> binder.addBinding().toInstance(module)); return this; }
java
{ "resource": "" }
q166153
Pac4j.unauthenticated
validation
public Pac4j unauthenticated(Supplier<UserProfile> provider) { requireNonNull(provider, "Unauthenticated provider required."); return unauthenticated(req -> provider.get()); }
java
{ "resource": "" }
q166154
Pac4j.form
validation
public Pac4j form(String pattern) { return clientInternal(pattern, conf -> { showDevLogin = true; return new FormClient("/login", new SimpleTestUsernamePasswordAuthenticator()); }, null); }
java
{ "resource": "" }
q166155
ApiParser.parse
validation
public List<RouteMethod> parse(String application) throws Exception { return new BytecodeRouteParser(loader, dir).parse(application).stream() .filter(filter) .collect(Collectors.toList()); }
java
{ "resource": "" }
q166156
Scanner.scan
validation
public Scanner scan(final Class<?> type) { // standard vs guice annotations if (type == Named.class || type == com.google.inject.name.Named.class) { serviceTypes.add(Named.class); serviceTypes.add(com.google.inject.name.Named.class); } else if (type == Singleton.class || type == com.google.inject.Singleton.class) { serviceTypes.add(Singleton.class); serviceTypes.add(com.google.inject.Singleton.class); } else { serviceTypes.add(type); } return this; }
java
{ "resource": "" }
q166157
ApiTool.swagger
validation
public ApiTool swagger(String path, Consumer<Swagger> swagger) { return swagger(new Options(path, options), swagger); }
java
{ "resource": "" }
q166158
ApiTool.swagger
validation
public ApiTool swagger(Options options, Consumer<Swagger> swagger) { this.swaggerOptions = Objects.requireNonNull(options, "Options required."); this.swagger = swagger; return this; }
java
{ "resource": "" }
q166159
ApiTool.raml
validation
public ApiTool raml(String path, Consumer<Raml> raml) { return raml(new Options(path, options), raml); }
java
{ "resource": "" }
q166160
ApiTool.raml
validation
public ApiTool raml(Options options, Consumer<Raml> raml) { this.ramlOptions = Objects.requireNonNull(options, "Options required."); this.raml = raml; return this; }
java
{ "resource": "" }
q166161
AssetProcessor.process
validation
public String process(String filename, String source, Config conf) throws Exception { return process(filename, source, conf, getClass().getClassLoader()); }
java
{ "resource": "" }
q166162
CteRecepcaoOSCallbackHandler.receiveResultcteRecepcaoOS
validation
public void receiveResultcteRecepcaoOS( com.fincatto.documentofiscal.cte300.webservices.recepcaoOS.CteRecepcaoOSStub.CteRecepcaoOSResult result ) { }
java
{ "resource": "" }
q166163
MDFeRecepcaoCallbackHandler.receiveResultmdfeRecepcaoLote
validation
public void receiveResultmdfeRecepcaoLote( com.fincatto.documentofiscal.mdfe3.webservices.recepcao.MDFeRecepcaoStub.MdfeRecepcaoLoteResult result ) { }
java
{ "resource": "" }
q166164
CteInutilizacaoCallbackHandler.receiveResultcteInutilizacaoCT
validation
public void receiveResultcteInutilizacaoCT( com.fincatto.documentofiscal.cte300.webservices.inutilizacao.CteInutilizacaoStub.CteInutilizacaoCTResult result ) { }
java
{ "resource": "" }
q166165
MDFeRecepcaoEventoCallbackHandler.receiveResultmdfeRecepcaoEvento
validation
public void receiveResultmdfeRecepcaoEvento( com.fincatto.documentofiscal.mdfe3.webservices.recepcaoevento.MDFeRecepcaoEventoStub.MdfeRecepcaoEventoResult result ) { }
java
{ "resource": "" }
q166166
CteConsultaCallbackHandler.receiveResultcteConsultaCT
validation
public void receiveResultcteConsultaCT( com.fincatto.documentofiscal.cte300.webservices.consulta.CteConsultaStub.CteConsultaCTResult result ) { }
java
{ "resource": "" }
q166167
MDFeConsNaoEncCallbackHandler.receiveResultmdfeConsNaoEnc
validation
public void receiveResultmdfeConsNaoEnc( com.fincatto.documentofiscal.mdfe3.webservices.consultanaoencerrado.MDFeConsNaoEncStub.MdfeConsNaoEncResult result ) { }
java
{ "resource": "" }
q166168
MDFeRecepcaoStub.toEnvelope
validation
@SuppressWarnings("unused") private org.apache.axiom.soap.SOAPEnvelope toEnvelope(final org.apache.axiom.soap.SOAPFactory factory) { return factory.getDefaultEnvelope(); }
java
{ "resource": "" }
q166169
RecepcaoEventoStub.getEnvelopeNamespaces
validation
private java.util.Map getEnvelopeNamespaces(final org.apache.axiom.soap.SOAPEnvelope env) { final java.util.Map returnMap = new java.util.HashMap(); final java.util.Iterator namespaceIterator = env.getAllDeclaredNamespaces(); while (namespaceIterator.hasNext()) { final org.apache.axiom.om.OMNamespace ns = (org.apache.axiom.om.OMNamespace) namespaceIterator.next(); returnMap.put(ns.getPrefix(), ns.getNamespaceURI()); } return returnMap; }
java
{ "resource": "" }
q166170
NfeConsultaCallbackHandler.receiveResultnfeConsultaNF
validation
public void receiveResultnfeConsultaNF( com.fincatto.documentofiscal.nfe310.webservices.nota.consulta.NfeConsultaStub.NfeConsultaNFResult result) { }
java
{ "resource": "" }
q166171
WSLoteEnvio.getLoteAssinado
validation
NFLoteEnvio getLoteAssinado(final NFLoteEnvio lote) throws Exception { // adiciona a chave e o dv antes de assinar for (final NFNota nota : lote.getNotas()) { final NFGeraChave geraChave = new NFGeraChave(nota); nota.getInfo().getIdentificacao().setCodigoRandomico(StringUtils.defaultIfBlank(nota.getInfo().getIdentificacao().getCodigoRandomico(), geraChave.geraCodigoRandomico())); nota.getInfo().getIdentificacao().setDigitoVerificador(geraChave.getDV()); nota.getInfo().setIdentificador(geraChave.getChaveAcesso()); } // assina o lote final String documentoAssinado = new AssinaturaDigital(this.config).assinarDocumento(lote.toString()); final NFLoteEnvio loteAssinado = new DFParser().loteParaObjeto(documentoAssinado); // verifica se nao tem NFCe junto com NFe no lote e gera qrcode (apos assinar mesmo, eh assim) int qtdNF = 0, qtdNFC = 0; for (final NFNota nota : loteAssinado.getNotas()) { switch (nota.getInfo().getIdentificacao().getModelo()) { case NFE: qtdNF++; break; case NFCE: final NFGeraQRCode geraQRCode = new NFGeraQRCode(nota, this.config); nota.setInfoSuplementar(new NFNotaInfoSuplementar()); nota.getInfoSuplementar().setQrCode(geraQRCode.getQRCode()); qtdNFC++; break; default: throw new IllegalArgumentException(String.format("Modelo de nota desconhecida: %s", nota.getInfo().getIdentificacao().getModelo())); } } // verifica se todas as notas do lote sao do mesmo modelo if ((qtdNF > 0) && (qtdNFC > 0)) { throw new IllegalArgumentException("Lote contendo notas de modelos diferentes!"); } return loteAssinado; }
java
{ "resource": "" }
q166172
WSFacade.enviaLote
validation
public NFLoteEnvioRetornoDados enviaLote(final NFLoteEnvio lote) throws Exception { if (lote.getIndicadorProcessamento().equals(NFLoteIndicadorProcessamento.PROCESSAMENTO_SINCRONO) && lote.getNotas().size() > 1) { throw new IllegalArgumentException("Apenas uma nota permitida no modo sincrono!"); } else if (lote.getNotas().size() == 0) { throw new IllegalArgumentException("Nenhuma nota informada no envio do Lote!"); } return this.wsLoteEnvio.enviaLote(lote); }
java
{ "resource": "" }
q166173
WSFacade.consultaStatus
validation
public NFStatusServicoConsultaRetorno consultaStatus(final DFUnidadeFederativa uf, final DFModelo modelo) throws Exception { return this.wsStatusConsulta.consultaStatus(uf, modelo); }
java
{ "resource": "" }
q166174
WSFacade.corrigeNota
validation
public NFEnviaEventoRetorno corrigeNota(final String chaveDeAcesso, final String textoCorrecao, final int numeroSequencialEvento) throws Exception { return this.wsCartaCorrecao.corrigeNota(chaveDeAcesso, textoCorrecao, numeroSequencialEvento); }
java
{ "resource": "" }
q166175
WSFacade.cancelaNota
validation
public NFEnviaEventoRetorno cancelaNota(final String chave, final String numeroProtocolo, final String motivo) throws Exception { return this.wsCancelamento.cancelaNota(chave, numeroProtocolo, motivo); }
java
{ "resource": "" }
q166176
WSFacade.inutilizaNota
validation
public NFRetornoEventoInutilizacao inutilizaNota(final int anoInutilizacaoNumeracao, final String cnpjEmitente, final String serie, final String numeroInicial, final String numeroFinal, final String justificativa, final DFModelo modelo) throws Exception { return this.wsInutilizacao.inutilizaNota(anoInutilizacaoNumeracao, cnpjEmitente, serie, numeroInicial, numeroFinal, justificativa, modelo); }
java
{ "resource": "" }
q166177
WSFacade.consultaCadastro
validation
public NFRetornoConsultaCadastro consultaCadastro(final String cnpj, final DFUnidadeFederativa uf) throws Exception { return this.wsConsultaCadastro.consultaCadastro(cnpj, uf); }
java
{ "resource": "" }
q166178
CteRecepcaoCallbackHandler.receiveResultcteRecepcaoLote
validation
public void receiveResultcteRecepcaoLote( com.fincatto.documentofiscal.cte300.webservices.recepcao.CteRecepcaoStub.CteRecepcaoLoteResult result ) { }
java
{ "resource": "" }
q166179
CteRetRecepcaoCallbackHandler.receiveResultcteRetRecepcao
validation
public void receiveResultcteRetRecepcao( com.fincatto.documentofiscal.cte300.webservices.retrecepcao.CteRetRecepcaoStub.CteRetRecepcaoResult result ) { }
java
{ "resource": "" }
q166180
WSCartaCorrecao.getXmlAssinado
validation
public String getXmlAssinado(final String chaveAcesso, final String textoCorrecao, final int numeroSequencialEvento) throws Exception { final String cartaCorrecaoXML = this.gerarDadosCartaCorrecao(chaveAcesso, textoCorrecao, numeroSequencialEvento).toString(); return new AssinaturaDigital(this.config).assinarDocumento(cartaCorrecaoXML); }
java
{ "resource": "" }
q166181
RecepcaoEventoCallbackHandler.receiveResultcteRecepcaoEvento
validation
public void receiveResultcteRecepcaoEvento( com.fincatto.documentofiscal.cte300.webservices.recepcaoevento.RecepcaoEventoStub.CteRecepcaoEventoResult result ) { }
java
{ "resource": "" }
q166182
WSFacade.cancelaNota
validation
public CTeRetornoCancelamento cancelaNota(final String chave, final String numeroProtocolo, final String motivo) throws Exception { return this.wsCancelamento.cancelaNota(chave, numeroProtocolo, motivo); }
java
{ "resource": "" }
q166183
MDFeConsultaCallbackHandler.receiveResultmdfeConsultaMDF
validation
public void receiveResultmdfeConsultaMDF( com.fincatto.documentofiscal.mdfe3.webservices.consulta.MDFeConsultaStub.MdfeConsultaMDFResult result ) { }
java
{ "resource": "" }
q166184
MDFeRetRecepcaoCallbackHandler.receiveResultmdfeRetRecepcao
validation
public void receiveResultmdfeRetRecepcao( com.fincatto.documentofiscal.mdfe3.webservices.retornorecepcao.MDFeRetRecepcaoStub.MdfeRetRecepcaoResult result ) { }
java
{ "resource": "" }
q166185
WSFacade.cancelaMdfe
validation
public MDFeRetorno cancelaMdfe(final String chave, final String numeroProtocolo, final String motivo) throws Exception { return this.wsCancelamento.cancelaNota(chave, numeroProtocolo, motivo); }
java
{ "resource": "" }
q166186
WSFacade.encerramento
validation
public MDFeRetorno encerramento(final String chaveAcesso, final String numeroProtocolo, final String codigoMunicipio, final LocalDate dataEncerramento, final DFUnidadeFederativa unidadeFederativa) throws Exception { return this.wsEncerramento.encerraMdfe(chaveAcesso, numeroProtocolo, codigoMunicipio, dataEncerramento, unidadeFederativa); }
java
{ "resource": "" }
q166187
WSFacade.encerramentoAssinado
validation
public MDFeRetorno encerramentoAssinado(final String chaveAcesso, final String eventoAssinadoXml) throws Exception { return this.wsEncerramento.encerramentoMdfeAssinado(chaveAcesso, eventoAssinadoXml); }
java
{ "resource": "" }
q166188
MDFeStatusServicoCallbackHandler.receiveResultmdfeStatusServicoMDF
validation
public void receiveResultmdfeStatusServicoMDF( com.fincatto.documentofiscal.mdfe3.webservices.statusservico.MDFeStatusServicoStub.MdfeStatusServicoMDFResult result ) { }
java
{ "resource": "" }
q166189
WSStatusConsulta.efetuaConsultaStatusBahia
validation
private OMElement efetuaConsultaStatusBahia(final OMElement omElement) throws RemoteException { final NfeStatusServicoStub.NfeCabecMsg cabec = new NfeStatusServicoStub.NfeCabecMsg(); cabec.setCUF(DFUnidadeFederativa.BA.getCodigoIbge()); cabec.setVersaoDados(this.config.getVersao()); final NfeStatusServicoStub.NfeCabecMsgE cabecEnv = new NfeStatusServicoStub.NfeCabecMsgE(); cabecEnv.setNfeCabecMsg(cabec); final NfeStatusServicoStub.NfeDadosMsg dados = new NfeStatusServicoStub.NfeDadosMsg(); dados.setExtraElement(omElement); final NFAutorizador31 autorizador = NFAutorizador31.valueOfCodigoUF(DFUnidadeFederativa.BA); final String endpoint = autorizador.getNfeStatusServico(this.config.getAmbiente()); if (endpoint == null) { throw new IllegalArgumentException("Nao foi possivel encontrar URL para StatusServico " + DFModelo.NFE.name() + ", autorizador " + autorizador.name() + ", UF " + DFUnidadeFederativa.BA.name()); } return new NfeStatusServicoStub(endpoint).nfeStatusServicoNF(dados, cabecEnv).getExtraElement(); }
java
{ "resource": "" }
q166190
ALSUtils.computeUpdatedXu
validation
public static float[] computeUpdatedXu(Solver solver, double value, float[] Xu, float[] Yi, boolean implicit) { if (Yi == null) { return null; } boolean noXu = Xu == null; double Qui = noXu ? 0.0 : VectorMath.dot(Xu, Yi); // Qui' is the target, new value of Qui // 0.5 reflects a "don't know" state double targetQui = computeTargetQui(implicit, value, noXu ? 0.5 : Qui); if (Double.isNaN(targetQui)) { return null; } double dQui = targetQui - Qui; double[] dQuiYi = new double[Yi.length]; for (int i = 0; i < dQuiYi.length; i++) { dQuiYi[i] = Yi[i] * dQui; } double[] dXu = solver.solveDToD(dQuiYi); float[] newXu = noXu ? new float[dXu.length] : Xu.clone(); for (int i = 0; i < newXu.length; i++) { newXu[i] += dXu[i]; } return newXu; }
java
{ "resource": "" }
q166191
VectorMath.cosineSimilarity
validation
public static double cosineSimilarity(float[] x, float[] y, double normY) { int length = x.length; double dot = 0.0; double totalXSq = 0.0; for (int i = 0; i < length; i++) { double xi = x[i]; totalXSq += xi * xi; dot += xi * y[i]; } return dot / (Math.sqrt(totalXSq) * normY); }
java
{ "resource": "" }
q166192
SolverCache.compute
validation
public void compute() { // Make sure only one attempts to build at one time if (solverUpdating.compareAndSet(false, true)) { executor.execute(LoggingCallable.log(() -> { try { log.info("Computing cached solver"); // Not as much hurry if one already exists boolean lowPriority = solver.get() != null; Solver newYTYSolver = LinearSystemSolver.getSolver(vectorPartitions.getVTV(lowPriority)); if (newYTYSolver != null) { log.info("Computed new solver {}", newYTYSolver); solver.set(newYTYSolver); } } finally { // Allow any threads waiting for initial model to proceed. // It's possible the solver is still null here if there is no input. solverInitialized.countDown(); solverUpdating.set(false); } }).asRunnable()); } }
java
{ "resource": "" }
q166193
IOUtils.deleteRecursively
validation
public static void deleteRecursively(Path rootDir) throws IOException { if (rootDir == null || !Files.exists(rootDir)) { return; } Files.walkFileTree(rootDir, new SimpleFileVisitor<Path>() { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { Files.delete(file); return FileVisitResult.CONTINUE; } @Override public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { Files.delete(dir); return FileVisitResult.CONTINUE; } }); }
java
{ "resource": "" }
q166194
ClassUtils.loadInstanceOf
validation
public static <T> T loadInstanceOf(String implClassName, Class<T> superClass, Class<?>[] constructorTypes, Object[] constructorArgs) { try { Class<? extends T> configClass = loadClass(implClassName, superClass); Constructor<? extends T> constructor = configClass.getConstructor(constructorTypes); return constructor.newInstance(constructorArgs); } catch (NoSuchMethodException | InstantiationException | IllegalAccessException e) { throw new IllegalArgumentException("No valid " + superClass + " binding exists", e); } catch (InvocationTargetException ite) { throw new IllegalStateException("Could not instantiate " + superClass + " due to exception", ite.getCause()); } }
java
{ "resource": "" }
q166195
MLUpdate.publishAdditionalModelData
validation
public void publishAdditionalModelData(JavaSparkContext sparkContext, PMML pmml, JavaRDD<M> newData, JavaRDD<M> pastData, Path modelParentPath, TopicProducer<String, String> modelUpdateTopic) { // Do nothing by default }
java
{ "resource": "" }
q166196
CustomTabsHelper.openCustomTab
validation
public void openCustomTab( final Context context, final CustomTabsIntent customTabsIntent, final Uri uri, CustomTabFallback fallback) { final String packageName = getPackageNameToUse(context); if (packageName != null) { final CustomTabsServiceConnection connection = new CustomTabsServiceConnection() { @Override public void onCustomTabsServiceConnected(ComponentName componentName, CustomTabsClient client) { client.warmup(0L); // This prevents backgrounding after redirection customTabsIntent.intent.setPackage(packageName); customTabsIntent.intent.setData(uri); customTabsIntent.launchUrl(context, uri); } @Override public void onServiceDisconnected(ComponentName name) {} }; CustomTabsClient.bindCustomTabsService(context, packageName, connection); } else if (fallback != null) { fallback.openUri(context, uri); } else { Log.e(UberSdk.UBER_SDK_LOG_TAG, "Use of openCustomTab without Customtab support or a fallback set"); } }
java
{ "resource": "" }
q166197
CustomTabsHelper.getPackageNameToUse
validation
@Nullable public String getPackageNameToUse(Context context) { if (packageNameToUse != null) return packageNameToUse; PackageManager pm = context.getPackageManager(); // Get default VIEW intent handler. Intent activityIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.example.com")); ResolveInfo defaultViewHandlerInfo = pm.resolveActivity(activityIntent, 0); String defaultViewHandlerPackageName = null; if (defaultViewHandlerInfo != null) { defaultViewHandlerPackageName = defaultViewHandlerInfo.activityInfo.packageName; } // Get all apps that can handle VIEW intents. List<ResolveInfo> resolvedActivityList = pm.queryIntentActivities(activityIntent, 0); List<String> packagesSupportingCustomTabs = new ArrayList<>(); for (ResolveInfo info : resolvedActivityList) { Intent serviceIntent = new Intent(); serviceIntent.setAction(ACTION_CUSTOM_TABS_CONNECTION); serviceIntent.setPackage(info.activityInfo.packageName); if (pm.resolveService(serviceIntent, 0) != null) { packagesSupportingCustomTabs.add(info.activityInfo.packageName); } } // Now packagesSupportingCustomTabs contains all apps that can handle both VIEW intents // and service calls. if (packagesSupportingCustomTabs.isEmpty()) { packageNameToUse = null; } else if (packagesSupportingCustomTabs.size() == 1) { packageNameToUse = packagesSupportingCustomTabs.get(0); } else if (!TextUtils.isEmpty(defaultViewHandlerPackageName) && !hasSpecializedHandlerIntents(context, activityIntent) && packagesSupportingCustomTabs.contains(defaultViewHandlerPackageName)) { packageNameToUse = defaultViewHandlerPackageName; } else if (packagesSupportingCustomTabs.contains(STABLE_PACKAGE)) { packageNameToUse = STABLE_PACKAGE; } else if (packagesSupportingCustomTabs.contains(BETA_PACKAGE)) { packageNameToUse = BETA_PACKAGE; } else if (packagesSupportingCustomTabs.contains(DEV_PACKAGE)) { packageNameToUse = DEV_PACKAGE; } else if (packagesSupportingCustomTabs.contains(LOCAL_PACKAGE)) { packageNameToUse = LOCAL_PACKAGE; } return packageNameToUse; }
java
{ "resource": "" }
q166198
CustomTabsHelper.hasSpecializedHandlerIntents
validation
private boolean hasSpecializedHandlerIntents(Context context, Intent intent) { try { PackageManager pm = context.getPackageManager(); List<ResolveInfo> handlers = pm.queryIntentActivities( intent, PackageManager.GET_RESOLVED_FILTER); if (handlers == null || handlers.size() == 0) { return false; } for (ResolveInfo resolveInfo : handlers) { IntentFilter filter = resolveInfo.filter; if (filter == null) continue; if (filter.countDataAuthorities() == 0 || filter.countDataPaths() == 0) continue; if (resolveInfo.activityInfo == null) continue; return true; } } catch (RuntimeException e) { Log.e(TAG, "Runtime exception while getting specialized handlers"); } return false; }
java
{ "resource": "" }
q166199
RideRequestActivity.load
validation
private void load() { AccessToken accessToken = accessTokenStorage.getAccessToken(); if (accessToken != null) { AccessTokenSession session = new AccessTokenSession(sessionConfiguration, accessTokenStorage); rideRequestView.setSession(session); loadRideRequestView(); } else { login(); } }
java
{ "resource": "" }