code
stringlengths
73
34.1k
label
stringclasses
1 value
static void constructTotalHitsGraph(Map.Entry<String, LrProjectScenarioResults> scenarioResults, JSONObject scenarioGraphData) { Map<Integer, WholeRunResult> totalHitsResults = scenarioResults.getValue().getTotalHitsResults(); JSONObject totalHitsGraphSet = extrac...
java
private static String digestToString(byte[] b) { StringBuilder result = new StringBuilder(128); for (byte aB : b) { result.append(Integer.toString((aB & 0xff) + 0x100, 16).substring(1)); } return result.toString(); }
java
@JavaScriptMethod public JSONArray getScenarioList() { JSONArray scenarioList = new JSONArray(); for (String scenarioName : _projectResult.getScenarioResults().keySet()) { JSONObject scenario = new JSONObject(); scenario.put("ScenarioName", scenarioName); scenario...
java
@JavaScriptMethod public JSONObject getGraphData() { JSONObject projectDataSet = new JSONObject(); if (_projectResult == null) { // getUpdatedData(); return new JSONObject(); } for (SortedMap.Entry<String, LrProjectScenarioResults> scenarioResults : _projectR...
java
boolean isVisible() { List<? extends Run<?, ?>> builds = currentProject.getBuilds(); for (Run run : builds) { if (run.getAction(PerformanceJobReportAction.class) != null) { return true; } } return false; }
java
public synchronized void getUpdatedData() { if (!isUpdateDataNeeded()) { return; } this._projectResult = new ProjectLrResults(); _workedBuilds = new ArrayList<Integer>(); RunList<? extends Run> projectBuilds = currentProject.getBuilds(); // updateLastBuild...
java
public JSONObject getJobDetails(String mcUrl, String proxyAddress, String proxyUserName, String proxyPassword){ if(StringUtils.isBlank(fsUserName) || StringUtils.isBlank(fsPassword.getPlainText())){ return null; } return JobConfigurationProxy.getInstance().getJobById(mcUrl, fsUserNam...
java
@Override public SWNativeAlignerResult align(byte[] refArray, byte[] altArray, SWParameters parameters, SWOverhangStrategy overhangStrategy) { int intStrategy = getStrategy(overhangStrategy); byte[] cigar = new byte[2*Integer.max(refArray.length, altArray.length)]; int offset = alignNa...
java
public Deflater makeDeflater(final int compressionLevel, final boolean gzipCompatible) { if (intelDeflaterSupported) { if ((compressionLevel == 1 && gzipCompatible) || compressionLevel != 1) { return new IntelDeflater(compressionLevel, gzipCompatible); } } ...
java
public void initialize(PairHMMNativeArguments args) { if (args == null) { args = new PairHMMNativeArguments(); args.useDoublePrecision = false; args.maxNumberOfThreads = 1; } if(!useFpga && gklUtils.isAvx512Supported()) { logger.info("Using CPU-su...
java
@Override public void execute() { if ( "pom".equals( project.getPackaging() ) ) { return; } File managedPath = new File( project.getBuild().getDirectory(), "src_managed" ); String managedPathStr = managedPath.getAbsolutePath(); if ( !project.getCompil...
java
@Override public void execute() { if ( "pom".equals( project.getPackaging() ) ) { return; } File baseDir = project.getBasedir(); File mainScalaPath = new File( baseDir, "src/main/scala" ); if ( mainScalaPath.isDirectory() ) { Stri...
java
public static File getCacheDirectory( File classesDirectory ) { String classesDirectoryName = classesDirectory.getName(); String cacheDirectoryName = classesDirectoryName.replace( TEST_CLASSES, CACHE ).replace( CLASSES, CACHE ); return new File( classesDirectory.getParentFile(), cacheDirecto...
java
private CompilationProblem[] getScalacProblems( Problem[] problems ) { CompilationProblem[] result = new CompilationProblem[problems.length]; for ( int i = 0; i < problems.length; i++ ) { Problem problem = problems[i]; Position position = problem.position(); ...
java
private static void submitScalaProgram(QdsClient client) throws Exception { String sampleProgram = "println(\"hello world\")"; SparkCommandBuilder sparkBuilder = client.command().spark(); // Give a name to the command. (Optional) sparkBuilder.name("spark-scala-test"); //Settin...
java
private static void submitSQLQuery(QdsClient client) throws Exception { String sampleSqlQuery = "select * from default_qubole_airline_origin_destination limit 100"; SparkCommandBuilder sparkBuilder = client.command().spark(); // Give a name to the command. (Optional) sparkB...
java
private void secondWalk(TreeNode v, double m, int level, double levelStart) { // construct the position from the prelim and the level information // The rootLocation affects the way how x and y are changed and in what // direction. double levelChangeSign = getLevelChangeSign(); boolean levelChangeOnYAxis = i...
java
public void dumpTree(PrintStream printStream, DumpConfiguration dumpConfiguration) { dumpTree(printStream,tree.getRoot(),0, dumpConfiguration); }
java
public static void main(String[] args) throws IOException { String s = doc(svg( 160, 200, rect(0, 0, 160, 200, "fill:red;") + svg(10, 10, 100, 100, rect(0, 0, 100, 100, "fill:orange; stroke:rgb(0,0,0);")) + line(20, 20, 100, 100, "stroke:black;...
java
public Reader getResults(ResultValue resultValue) throws Exception { if (resultValue.isInline()) { return new StringReader(resultValue.getResults()); } return readFromS3(resultValue.getResult_location()); }
java
private boolean checkCommandTypeSupported(BaseCommand command) { // for command type none or composite // we dont support adding it as base command if ((command.getCommandType() == BaseCommand.COMMAND_TYPE.NONE) || (command.getCommandType() == BaseCommand.COMMAND_TYPE.COMPOSITE))...
java
public static String quote(String s, String nullResult) { if (s == null) { return nullResult; } StringBuffer result = new StringBuffer(); result.append('"'); int length = s.length(); for (int i = 0; i < length; i++) { char c = s.charAt(i); switch (c) { case '\b': { result.append("\\b"); ...
java
public static Document parse(JsonReader reader) throws IOException, NotImplemented { reader.beginArray(); int nodeType = reader.nextInt(); CoreDocumentImpl doc = new DocumentImpl(); if (nodeType == Node.ELEMENT_NODE) { addInitialElement(reader, doc); } else if (nod...
java
public Document toXml(InputStream json) throws IOException, NotImplemented { JsonReader reader = null; try { reader = new JsonReader(new InputStreamReader(json, "utf-8")); return parse(reader); } catch (UnsupportedEncodingException e) { throw new IllegalStateE...
java
@Override public CombinedStatus getCombinedStatus(String owner, String repository, String ref) { Map<String, Object> uriVariables = new HashMap<>(); uriVariables.put("owner", owner); uriVariables.put("repository", repository); uriVariables.put("ref", ref); return getRestOperations().exchange(buildUri("/repo...
java
public void waitForLogMessage(final String logSearchString, int waitTime) throws TimeoutException { WaitForContainer.waitForCondition(new LogChecker(this, logSearchString), waitTime, describe()); }
java
public void waitForExit() throws InterruptedException { try { dockerClient.waitContainer(container.id()); } catch (DockerException e) { throw new IllegalStateException(e); } }
java
public String getLog() { try (LogStream stream = dockerClient.logs(container.id(), LogsParam.stdout(), LogsParam.stderr());) { String fullLog = stream.readFully(); if (log.isTraceEnabled()) { log.trace("{} full log: {}", containerShortId, StringUtils.replace(fullLog, "\n"...
java
public DockerRuleBuilder keepContainer(boolean keepContainer) { if (keepContainer) { this.stopOptions.setOptions(StopOption.KEEP); } else { this.stopOptions.setOptions(StopOption.REMOVE); } return this; }
java
public DockerRuleBuilder env(String envName, String envValue) { env.add(String.format("%s=%s", envName, envValue)); return this; }
java
static void waitForCondition(final StartConditionCheck condition, int timeoutSeconds, final String containerDescription) throws TimeoutException { try { log.info("wait for {} started", condition.describe()); new WaitForUnit(TimeUnit.SECONDS, timeoutSeconds, TimeUnit.SECONDS, 1, new WaitF...
java
public void update( Client client ) { RestfulUtils.update( ClientService.PATH, client, Client.class, super.httpClient ); }
java
public void delete( Client client ) { RestfulUtils.delete( ClientService.PATH, client, Client.class, super.httpClient ); }
java
public void delete( final Preauthorization preauthorization ) { RestfulUtils.delete( PreauthorizationService.PATH, preauthorization, Preauthorization.class, super.httpClient ); }
java
public void delete(Offer offer, boolean removeWithSubscriptions) { ParameterMap<String, String> params = new ParameterMap<String, String>(); params.add("remove_with_subscriptions", String.valueOf(removeWithSubscriptions)); RestfulUtils.delete(OfferService.PATH, offer, params, Offer.class, super....
java
public <O extends Schema> O setId(String schemaId) { getJson().put("id", schemaId); return (O)this; }
java
public static Matcher<JsonElement> withCharsLessOrEqualTo(final int value) { return new TypeSafeDiagnosingMatcher<JsonElement>() { @Override protected boolean matchesSafely(JsonElement item, Description mismatchDescription) { //we do not care for the properties if parent...
java
public static Matcher<JsonElement> isOfType(final String type) { return new TypeSafeDiagnosingMatcher<JsonElement>() { @Override protected boolean matchesSafely(JsonElement item, Description mismatchDescription) { if (type.equals(item.getJsonType())) r...
java
public static Matcher<JsonElement> areItemsValid(final Validator validator) { return new TypeSafeDiagnosingMatcher<JsonElement>() { @Override protected boolean matchesSafely(JsonElement item, Description mismatchDescription) { //we do not care for the properties if parent...
java
public static Matcher<JsonElement> maxProperties(final int maxProperties) { return new TypeSafeDiagnosingMatcher<JsonElement>() { @Override protected boolean matchesSafely(JsonElement item, Description mismatchDescription) { //we do not care for the properties if parent i...
java
public static JsonElement wrap(Object o) throws JsonException { if (o == null) { //null value means not specified i.e.-> no valued will be mapped //Json.null is specific value return null; } if (o instanceof JsonElement) { return (JsonElement) o; ...
java
@Override public Schema fetch(URI targetUri, URI srcOrigUri, URI srcId) { Schema res = null; URI schemaUri = convertUri(resolveUri(targetUri, srcOrigUri, srcId)); if(!schemaUri.isAbsolute()) throw new RuntimeException("Json Schema Fetcher works only with absolute URIs"); try { ...
java
private MetaInfo tryFetchMetaInfo(URI jsonSchemaUri) { if (jsonSchemaUri == null) return null; try { metaInfo = doFetchMetaInfo(jsonSchemaUri); Validator validator = metaInfo.getDefaultValidator(); if (validator != null) { getValidators().add(validator...
java
public static String numberToString(Number number) throws JsonException { if (number == null) { throw new JsonException("Number must be non-null"); } double doubleValue = number.doubleValue(); // the original returns "-0" instead of "-0.0" for negative zero if (numb...
java
public JsonObject merge(JsonObject another) { for (Map.Entry<String, JsonElement> anotherEntry : another) { JsonElement curr = this.opt(anotherEntry.getKey()); if (curr == null) { try { this.put(anotherEntry.getKey(), anotherEntry.getValue()); ...
java
public void sync() throws MarkLogicSesameException { if(WRITE_CACHE_ENABLED && timerWriteCache != null) timerWriteCache.forceRun(); if(DELETE_CACHE_ENABLED && timerDeleteCache != null) timerDeleteCache.forceRun(); }
java
public void sendAdd(File file, String baseURI, RDFFormat dataFormat, Resource... contexts) throws RDFParseException { getClient().performAdd(file, baseURI, dataFormat, this.tx, contexts); }
java
public void sendAdd(InputStream in, String baseURI, RDFFormat dataFormat, Resource... contexts) throws RDFParseException, MarkLogicSesameException { getClient().performAdd(in, baseURI, dataFormat, this.tx, contexts); }
java
public void sendAdd(String baseURI, Resource subject, URI predicate, Value object, Resource... contexts) throws MarkLogicSesameException { if (WRITE_CACHE_ENABLED) { timerWriteCache.add(subject, predicate, object, contexts); } else { getClient().performAdd(baseURI, (Resource) skolemize(subject), (URI) skolemi...
java
public void sendRemove(String baseURI, Resource subject,URI predicate, Value object, Resource... contexts) throws MarkLogicSesameException { if (DELETE_CACHE_ENABLED) { timerDeleteCache.add(subject, predicate, object, contexts); } else { if (WRITE_CACHE_ENABLED) sync(); getClient().performRemove(baseUR...
java
public void commitTransaction() throws MarkLogicTransactionException { if (isActiveTransaction()) { try { sync(); this.tx.commit(); this.tx=null; } catch (MarkLogicSesameException e) { logger.error(e.getLocalizedMessage()); throw new MarkLogicTransactionException(e); } }else{ throw n...
java
public void setGraphPerms(GraphPermissions graphPerms){ if (graphPerms != null) { getClient().setGraphPerms(graphPerms); }else { getClient().setGraphPerms(getClient().getDatabaseClient().newGraphManager().newGraphPermissions()); } }
java
@Override public synchronized MarkLogicClient getMarkLogicClient() { if(null != databaseClient){ this.client = new MarkLogicClient(databaseClient); }else{ this.client = new MarkLogicClient(host, port, user, password, auth); } return this.client; }
java
private void setDatabaseClient(DatabaseClient databaseClient) { this.databaseClient = databaseClient; this.sparqlManager = getDatabaseClient().newSPARQLQueryManager(); this.graphManager = getDatabaseClient().newGraphManager(); }
java
public void performAdd(File file, String baseURI, RDFFormat dataFormat, Transaction tx, Resource... contexts) throws RDFParseException { try { graphManager.setDefaultMimetype(dataFormat.getDefaultMIMEType()); if (dataFormat.equals(RDFFormat.NQUADS) || dataFormat.equals(RDFFormat.TRIG)) {...
java
public void performAdd(InputStream in, String baseURI, RDFFormat dataFormat, Transaction tx, Resource... contexts) throws RDFParseException, MarkLogicSesameException { try { graphManager.setDefaultMimetype(dataFormat.getDefaultMIMEType()); if (dataFormat.equals(RDFFormat.NQUADS) || dataF...
java
public void performAdd(String baseURI, Resource subject, URI predicate, Value object, Transaction tx, Resource... contexts) throws MarkLogicSesameException { StringBuilder sb = new StringBuilder(); if(notNull(contexts) && contexts.length>0) { if (notNull(baseURI)) sb.append("BASE <" + baseUR...
java
public void performClear(Transaction tx, Resource... contexts) { if(notNull(contexts)) { for (int i = 0; i < contexts.length; i++) { if (notNull(contexts[i])) { graphManager.delete(contexts[i].stringValue(), tx); } else { graphM...
java
public void setRulesets(SPARQLRuleset ... rulesets) { if(notNull(rulesets)) { List<SPARQLRuleset> list = new ArrayList<>(); for(Object r : rulesets) { if(r != null && rulesets.length > 0) { list.add((SPARQLRuleset)r); } } ...
java
protected SPARQLBindings getSPARQLBindings(SPARQLQueryBindingSet bindings) { SPARQLBindings sps = new SPARQLBindingsImpl(); for (Binding binding : bindings) { sps.bind(binding.getName(), binding.getValue().stringValue()); } return sps; }
java
@Override public synchronized void run(){ Date now = new Date(); if ( !cache.isEmpty() && ((cache.size() > cacheSize - 1) || (now.getTime() - lastCacheAccess.getTime() > cacheMillis))) { try { flush(); } catch (RepositoryException e) { ...
java
public synchronized void forceRun() throws MarkLogicSesameException { log.debug(String.valueOf(cache.size())); if( !cache.isEmpty()) { try { flush(); } catch (RepositoryException e) { throw new MarkLogicSesameException("Could not flush write cache,...
java
public synchronized void add(Resource subject, URI predicate, Value object, Resource... contexts) throws MarkLogicSesameException { cache.add(subject,predicate,object,contexts); if( cache.size() > cacheSize - 1){ forceRun(); } }
java
@Override public Query prepareQuery(String queryString, String baseURI) throws RepositoryException, MalformedQueryException { return prepareQuery(QueryLanguage.SPARQL, queryString, baseURI); }
java
@Override public MarkLogicQuery prepareQuery(QueryLanguage queryLanguage, String queryString, String baseURI) throws RepositoryException, MalformedQueryException { // function routing based on query form if (SPARQL.equals(queryLanguage)) { String queryStringWithoutProlog ...
java
@Override public MarkLogicGraphQuery prepareGraphQuery(String queryString,String baseURI) throws RepositoryException, MalformedQueryException { return prepareGraphQuery(QueryLanguage.SPARQL, queryString, baseURI); }
java
@Override public MarkLogicBooleanQuery prepareBooleanQuery(String queryString) throws RepositoryException, MalformedQueryException { return prepareBooleanQuery(QueryLanguage.SPARQL, queryString, null); }
java
@Override public MarkLogicUpdateQuery prepareUpdate(String queryString,String baseURI) throws RepositoryException, MalformedQueryException { return prepareUpdate(QueryLanguage.SPARQL, queryString, baseURI); }
java
@Override public MarkLogicUpdateQuery prepareUpdate(QueryLanguage queryLanguage, String queryString, String baseURI) throws RepositoryException, MalformedQueryException { if (QueryLanguage.SPARQL.equals(queryLanguage)) { return new MarkLogicUpdateQuery(this.client, new SPARQLQueryBindingSet(), b...
java
@Override public RepositoryResult<Resource> getContextIDs() throws RepositoryException { try{ TupleQuery tupleQuery = prepareTupleQuery(QueryLanguage.SPARQL, ALL_GRAPH_URIS); TupleQueryResult result = tupleQuery.evaluate(); return new RepositoryResult<...
java
public RepositoryResult<Statement> getStatements(Resource subj, URI pred, Value obj, boolean includeInferred) throws RepositoryException { try { if (isQuadMode()) { TupleQuery tupleQuery = prepareTupleQuery(GET_STATEMENTS); setBindings(tupleQuery, subj, pred, obj); ...
java
@Override public RepositoryResult<Statement> getStatements(Resource subj, URI pred, Value obj, boolean includeInferred, Resource... contexts) throws RepositoryException { if (contexts == null) { contexts = new Resource[] { null }; } try { if (isQuadMode()) { ...
java
@Override public long size() throws RepositoryException{ try { MarkLogicTupleQuery tupleQuery = prepareTupleQuery(COUNT_EVERYTHING); tupleQuery.setIncludeInferred(false); tupleQuery.setRulesets((SPARQLRuleset)null); tupleQuery.setConstrainingQueryDefinition((Q...
java
@Override public long size(Resource... contexts) throws RepositoryException { if (contexts == null) { contexts = new Resource[] { null }; } try { StringBuilder sb = new StringBuilder(); sb.append("SELECT (count(?s) as ?ct) where { GRAPH ?g { ?s ?p ?o }"); ...
java
@Override public void add(InputStream in, String baseURI, RDFFormat dataFormat, Resource... contexts) throws IOException, RDFParseException, RepositoryException { getClient().sendAdd(in, baseURI, dataFormat, contexts); }
java
@Override public void add(File file, String baseURI, RDFFormat dataFormat, Resource... contexts) throws IOException, RDFParseException, RepositoryException { if(notNull(baseURI)) { getClient().sendAdd(file, baseURI, dataFormat, contexts); }else{ getClient().sendAdd(file, file...
java
@Override public void add(Reader reader, String baseURI, RDFFormat dataFormat, Resource... contexts) throws IOException, RDFParseException, RepositoryException { getClient().sendAdd(reader, baseURI, dataFormat, contexts); }
java
@Override public void add(URL url, String baseURI, RDFFormat dataFormat, Resource... contexts) throws IOException, RDFParseException, RepositoryException { if(notNull(baseURI)) { getClient().sendAdd(new URL(url.toString()).openStream(), baseURI, dataFormat, contexts); }else{ ...
java
@Override protected void addWithoutCommit(Resource subject, URI predicate, Value object, Resource... contexts) throws RepositoryException { add(subject, predicate, object, contexts); }
java
@Override protected void removeWithoutCommit(Resource subject, URI predicate, Value object, Resource... contexts) throws RepositoryException { remove(subject, predicate, object, contexts); }
java
@Override public void setDefaultGraphPerms(GraphPermissions graphPerms) { if(notNull(graphPerms)) { this.defaultGraphPerms = graphPerms; }else{ this.defaultGraphPerms = client.emptyGraphPerms(); } }
java
@Override public void configureWriteCache(long initDelay, long delayCache, long cacheSize){ client.initTimer(initDelay, delayCache,cacheSize); }
java
private static Resource[] mergeResource(Resource o, Resource... arr) { if(o != null) { Resource[] newArray = new Resource[arr.length + 1]; newArray[0] = o; System.arraycopy(arr, 0, newArray, 1, arr.length); return newArray; }else{ return arr; ...
java
protected synchronized void flush() throws RepositoryException, MalformedQueryException, UpdateExecutionException, IOException { if (cache.isEmpty()) { return; } StringBuffer entireQuery = new StringBuffer(); SPARQLQueryBindingSet bindingSet = new SPARQLQueryBindingSet(); for (Namespace...
java
@Override public boolean evaluate() throws QueryEvaluationException { try { sync(); return getMarkLogicClient().sendBooleanQuery(getQueryString(), getBindings(), getIncludeInferred(),getBaseURI()); }catch (RepositoryException e) { throw new QueryEvaluationExceptio...
java
@Override protected void handleClose() throws QueryEvaluationException { try { super.handleClose(); }catch(Exception e){ logger.error("MarkLogicBackgroundGraphResult handleClose() stream closed exception",e); throw new QueryEvaluationException(e); } }
java
@Override public GraphQueryResult evaluate() throws QueryEvaluationException { try { sync(); return getMarkLogicClient().sendGraphQuery(getQueryString(),getBindings(),getIncludeInferred(),getBaseURI()); } catch (IOException e) { throw new QueryEvaluati...
java
public void setBinding(String name, String stringValue) { bindingSet.addBinding(name, ValueFactoryImpl.getInstance().createURI(stringValue)); }
java
@Override public void setBinding(String name, Value value) { bindingSet.addBinding(name, value); }
java
public TupleQueryResult evaluate(long start, long pageLength) throws QueryEvaluationException { try { sync(); return getMarkLogicClient().sendTupleQuery(getQueryString(), getBindings(), start, pageLength, getIncludeInferred(), getBaseURI()); }catch (RepositoryExceptio...
java
@Override public void execute() throws UpdateExecutionException { try { sync(); getMarkLogicClient().sendUpdateQuery(getQueryString(), getBindings(), getIncludeInferred(), getBaseURI()); }catch(ForbiddenUserException | FailedRequestException e){ throw new UpdateEx...
java
public int getMatchLen(int index, int distance, int limit) { if (_streamEndWasReached) { if ((_pos + index) + limit > _streamPos) { limit = _streamPos - (_pos + index); } } distance++; // Byte *pby = _buffer + (siz...
java
public EtcdResponse get(String key) throws EtcdException { UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(KEYSPACE); builder.pathSegment(key); return execute(builder, HttpMethod.GET, null, EtcdResponse.class); }
java
public EtcdResponse put(final String key, final String value) throws EtcdException { UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(KEYSPACE); builder.pathSegment(key); MultiValueMap<String, String> payload = new LinkedMultiValueMap<>(1); payload.set("value", value); return execute(builde...
java
public EtcdResponse delete(final String key) throws EtcdException { UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(KEYSPACE); builder.pathSegment(key); return execute(builder, HttpMethod.DELETE, null, EtcdResponse.class); }
java
public EtcdMemberResponse listMembers() throws EtcdException { UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(MEMBERSPACE); return execute(builder, HttpMethod.GET, null, EtcdMemberResponse.class); }
java
private void updateMembers() { try { List<String> locations = new ArrayList<String>(); EtcdMemberResponse response = listMembers(); EtcdMember[] members = response.getMembers(); for (EtcdMember member : members) { String[] clientUrls = member.getClientURLs(); if (clientUrls != null) { for (...
java
private <T> T execute(UriComponentsBuilder uriTemplate, HttpMethod method, MultiValueMap<String, String> requestData, Class<T> responseType) throws EtcdException { long startTimeMillis = System.currentTimeMillis(); int retry = -1; ResourceAccessException lastException = null; do { lastException = null; ...
java
public static <X> Iterator<X> before(final Iterator<X> iterator, final Runnable f) { return new Iterator<X>() { private final Runnable fOnlyOnce = new RunOnlyOnce(f); @Override public boolean hasNext() { fOnlyOnce.run(); return iterator.hasNext(); } @Overr...
java
public static <X> Iterator<X> after(final Iterator<X> iterator, final Runnable f) { return new Iterator<X>() { private final Runnable fOnlyOnce = new RunOnlyOnce(f); @Override public boolean hasNext() { final boolean hasNext = iterator.hasNext(); if (!hasNext) { ...
java