Same as above, but with type-safe arguments.

@param instances the instances to which this helper is applied.
@param options   the options of this helper invocation.
@return a string result.
@throws IOException if a template cannot be loaded.
351210
private String safeApply( Collection<InstanceContextBean> instances, Options options, String componentPath )
	throws IOException {

		// Parse the filter.
		String installerName = (String) options.hash.get( "installer" );
		final InstanceFilter filter = InstanceFilter.createFilter( componentPath, installerName );

		// Apply the filter.
		final Collection<InstanceContextBean> selectedInstances = filter.apply( instances );

		// Apply the content template of the helper to each selected instance.
		final StringBuilder buffer = new StringBuilder();
		final Context parent = options.context;
		int index = 0;
		final int last = selectedInstances.size() - 1;

		for( final InstanceContextBean instance : selectedInstances ) {
			final Context current = Context.newBuilder( parent, instance )
					.combine( "@index", index )
					.combine( "@first", index == 0 ? "first" : "" )
					.combine( "@last", index == last ? "last" : "" )
					.combine( "@odd", index % 2 == 0 ? "" : "odd" )
					.combine( "@even", index % 2 == 0 ? "even" : "" )
					.build();

			index++;
			buffer.append( options.fn( current ));
		}

		return buffer.toString();
	}
933835
public static void renderTemplateAsExcel(String templateName, Object... args) {

		// Template datas
		Scope.RenderArgs templateBinding = Scope.RenderArgs.current();
		for (Object o : args) {
			List<String> names = LocalvariablesNamesEnhancer.LocalVariablesNamesTracer
					.getAllLocalVariableNames(o);
			for (String name : names) {
				templateBinding.put(name, o);
			}
		}
		templateBinding.put("session", Scope.Session.current());
		templateBinding.put("request", Http.Request.current());
		templateBinding.put("flash", Scope.Flash.current());
		templateBinding.put("params", Scope.Params.current());
		if (null == templateBinding.get("fileName")) {
			templateBinding.put("fileName", templateName.substring(templateName.lastIndexOf("/") + 1) + ".xls");
		}
		//Logger.trace("fileName: " + templateBinding.get("fileName"));
		try {
			templateBinding.put("errors", Validation.errors());
		} catch (Exception ex) {
			throw new UnexpectedException(ex);
		}
		try {
			throw new RenderExcelTemplate(templateName + ".xls", templateBinding.data, templateBinding.get("fileName").toString());
		} catch (TemplateNotFoundException ex) {
			if (ex.isSourceAvailable()) {
				throw ex;
			}
			StackTraceElement element = PlayException
					.getInterestingStrackTraceElement(ex);
			if (element != null) {
				throw new TemplateNotFoundException(templateName, Play.classes
						.getApplicationClass(element.getClassName()), element
						.getLineNumber());
			} else {
				throw ex;
			}
		}
	}
1177203
public void setInstancesToProtect(java.util.Collection<String> instancesToProtect) {
        if (instancesToProtect == null) {
            this.instancesToProtect = null;
            return;
        }

        this.instancesToProtect = new com.amazonaws.internal.SdkInternalList<String>(instancesToProtect);
    }
833796
public Instances samoaInstancesInformation(weka.core.Instances instances) {
        Instances samoaInstances;
        List<Attribute> attInfo = new ArrayList<Attribute>();
        for (int i = 0; i < instances.numAttributes(); i++) {
            attInfo.add(samoaAttribute(i, instances.attribute(i)));
        }
        samoaInstances = new Instances(instances.relationName(), attInfo, 0);
        
        if(instances.classIndex() >= 0) { // class attribute is present
            samoaInstances.setClassIndex(instances.classIndex());
        }
        
        return samoaInstances;
    }
94285
static public IParserInput getInstance(
            final char commandPrefix,
            final File args)
                    throws IOException
    {
        return getInstance(commandPrefix, false, args);
    }
765111
public Instances samoaInstances(weka.core.Instances instances) {
        Instances samoaInstances = samoaInstancesInformation(instances);
        //We assume that we have only one samoaInstanceInformation for WekaToSamoaInstanceConverter
        this.samoaInstanceInformation = samoaInstances;
        for (int i = 0; i < instances.numInstances(); i++) {
            samoaInstances.add(samoaInstance(instances.instance(i)));
        }
        return samoaInstances;
    }
622222
public ArrayList<OvhSiteBuilderDomain> packName_siteBuilderStart_options_domains_GET(String packName) throws IOException {
		String qPath = "/pack/xdsl/{packName}/siteBuilderStart/options/domains";
		StringBuilder sb = path(qPath, packName);
		String resp = exec(qPath, "GET", sb.toString(), null);
		return convertTo(resp, t9);
	}
1045429
@SuppressWarnings("unchecked")
	@Override
	public <O> Option<O> map(Function<? super T, ? extends O> mapper) {
		return (Option<O>) INSTANCE;
	}
690316
public Output compileString(String string, Options options) throws CompilationException {
    return compileString(string, null, null, options);
  }
656959
function getInstance (options) {
  return new XTemplate({
    name: options.name,
    extname: options.extname,
    loader: {
      cache: {},
      load: function (tpl, callback) {
        console.log(tpl)
      }
    }
  })
}
348704
public Template getTemplate(String name, Locale locale, Object args) throws IOException, ParseException {
        if (args instanceof String)
            return getTemplate(name, locale, (String) args);
        return getTemplate(name, locale, null, args);
    }
1337747
public static <T> List<Option<T>> createOptions(Collection<T> domainObjects) { 
        List<Option<T>> options = new ArrayList<Option<T>>();
    
        for (T value : domainObjects) {
            String id = String.valueOf(getId(value));
            options.add(new Option<T>(id, value));
        }
    
        return options;
    }
462376
@SuppressWarnings("unchecked")
    public static <T extends Tuple> T create(Object... objects) {
        Class<? extends Tuple> tupleClass = classOfTuple(objects.length);
        try {
            return (T) tupleClass.getMethod("fromArray", Object[].class)
                    .invoke(null, new Object[]{objects});
        } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
            throw BusinessException.wrap(e, BusinessErrorCode.UNABLE_TO_CREATE_TUPLE);
        }
    }
380048
public OvhInterface project_serviceName_instance_instanceId_interface_interfaceId_GET(String serviceName, String instanceId, String interfaceId) throws IOException {
		String qPath = "/cloud/project/{serviceName}/instance/{instanceId}/interface/{interfaceId}";
		StringBuilder sb = path(qPath, serviceName, instanceId, interfaceId);
		String resp = exec(qPath, "GET", sb.toString(), null);
		return convertTo(resp, OvhInterface.class);
	}
520423
public void instanceOfType(Local<?> target, Local<?> source, TypeId<?> type) {
        addInstruction(new ThrowingCstInsn(Rops.INSTANCE_OF, sourcePosition,
                RegisterSpecList.make(source.spec()), catches, type.constant));
        moveResult(target, true);
    }
1091166
@Override
    public Optional<TemplateContentData> load(String responseTemplateName, Input input) throws TemplateLoaderException {
        TemplateEnumerator templateEnumerator = templateEnumeratorSupplier.apply(responseTemplateName, input);
        while (templateEnumerator.hasNext()) {
            String templateName = (String) templateEnumerator.next();
            String templatePath = buildCompletePath(templateName);
            try {
                URI templateUri = getResourceURI(templatePath);
                if (templateUri != null) {
                    String templateIdentifier = templateUri.toString();
                    TemplateContentData templateContentData = templateCache.get(templateIdentifier);
                    if (templateContentData == null) {
                        try (InputStream inputStream = getTemplateAsStream(templatePath)) {
                            byte[] templateByteArray = new byte[inputStream.available()];
                            inputStream.read(templateByteArray);
                            templateContentData = TemplateContentData.builder()
                                    .withIdentifier(templateIdentifier)
                                    .withTemplateContent(templateByteArray)
                                    .withTemplateBaseDir(directoryPath)
                                    .build();
                        } catch (IOException e) {
                            String message = String.format("Fail to read template file: %s with error: %s", templatePath, e.getMessage());
                            LOGGER.error(message);
                            throw new TemplateLoaderException(message);
                        }
                        templateCache.put(templateIdentifier, templateContentData);
                    }
                    return Optional.of(templateContentData);
                }
            } catch (URISyntaxException e) {
                String message = String.format("Cannot get valid URI for template file path: %s with error: %s", templatePath, e.getMessage());
                LOGGER.error(message);
                throw new TemplateLoaderException(message);
            }
        }
        String message = String.format("Cannot find template file: %s given directory path: %s and file extension: %s, returning empty.",
                responseTemplateName, directoryPath, fileExtension);
        LOGGER.warn(message);
        return Optional.empty();
    }
670446
public static <T> Collection<T> findAmongst(Class<T> clazz, Collection<?> instances) {
    return findStreamAmongst(clazz, instances)
      .collect(Collectors.toList());
  }