code
stringlengths
146
466k
prompt
stringlengths
54
1.5k
Of course, here is the Java code you requested: ```java public String getStringValue(DataBinder binder) { // binder can't get a non existent param if (this.name == null || this.name.equals("")) { return null; } String value = (String) binder.getLocal(this.name); if (value == null && this.re...
Create a Java method that does the following: "Get the value of the parameter.".
Of course, here is the Java code you requested: ```java public void setOptNoAbbrev(boolean optNoAbbrev) { if (optVerbose) { if (optAbbrev && optNoAbbrev) { throw new IllegalArgumentException(ExceptionMessageMap.getMessage("000120") + " --no-abbrev cannot be used with --abbrev."); }...
Create a Java method that does the following: "Sets the flag that specifies if the verbose option is set to true.".
Of course, here is the Java code you requested: ```java public void setOptNoTrack(boolean optNoTrack) { checkCanSetNoArgOption("--no-track"); if (optNoTrack && optTrack) { throw new IllegalArgumentException(ExceptionMessageMap.getMessage("000120") + " --no-track cannot be used with --track.");...
Create a Java method that does the following: "Sets the flag indicating if the no - track option is being used.".
Of course, here is the Java code you requested: ```java public void setOptColor(boolean optColor) { checkCanSetNoArgOption("--color"); if (optNoColor && optColor) { throw new IllegalArgumentException(ExceptionMessageMap.getMessage("000120") + " --color cannot be used with --no-color."); } ...
Create a Java method that does the following: "Sets the color flag.".
Of course, here is the Java code you requested: ```java public void setOptMerged(boolean optMerged) { checkCanSetNoArgOption("--merged"); if (optNoMerged && optMerged) { throw new IllegalArgumentException(ExceptionMessageMap.getMessage("000120") + " --merged cannot be used with --no-merged.");...
Create a Java method that does the following: "Sets the flag indicating whether the merged rule is to be used.".
Of course, here is the Java code you requested: ```java public void setOptDUpper(boolean optDUpper) { checkCanSetDeleteOption("-D"); if (optDLower && optDUpper) { throw new IllegalArgumentException(ExceptionMessageMap.getMessage("000120") + " -D cannot be used with -d."); } this.optDU...
Create a Java method that does the following: "Sets the option DUpper.".
Of course, here is the Java code you requested: ```java public void setOptMLower(boolean optMLower) { checkCanSetRenameOption("-m"); if (optMLower && optMUpper) { throw new IllegalArgumentException(ExceptionMessageMap.getMessage("000120") + " -m cannot be used with -M."); } this.optML...
Create a Java method that does the following: "Sets the option to use for the M - Upper or M - Lower case.".
Of course, here is the Java code you requested: ```java public void setOptMUpper(boolean optMUpper) { checkCanSetRenameOption("-M"); if (optMLower && optMUpper) { throw new IllegalArgumentException(ExceptionMessageMap.getMessage("000120") + " -M cannot be used with -m."); } this.optMU...
Create a Java method that does the following: "Sets the option for renaming the M upper or m upper boundary.".
Of course, here is the Java code you requested: ```java public void checkCanSetCreateOption(String option) { if (isOptColor() || isOptNoColor() || isOptR() || isOptA() || isOptVerbose() || isOptMerged() || isOptNoMerged() || (null != getOptContains()) || isOptMLower() || isOptMUpper() || isOptDLow...
Create a Java method that does the following: "Check if the option is allowed to create a branch".
Of course, here is the Java code you requested: ```java public void checkCanSetRenameOption(String option) { if (isOptColor() || isOptNoColor() || isOptR() || isOptA() || isOptVerbose() || isOptMerged() || isOptNoMerged() || (null != getOptContains()) || isOptTrack() || isOptNoTrack() || isOptL() ...
Create a Java method that does the following: "Check if the option is allowed to rename the current branch to newbranch.".
Of course, here is the Java code you requested: ```java private void generateDefinitions() { functionParameterTypes = new ArrayList<Class<?>[]>(); functionMethodNames = new ArrayList<String>(); variableParameterTypes = new ArrayList<Class<?>[]>(); variableMethodNames = new ArrayList<String>(); Lis...
Create a Java method that does the following: "Generate the definitions for the class.".
Of course, here is the Java code you requested: ```java public Integer getFunctionReturnType(Method m) { Class<?> type = m.getReturnType(); if (type == Void.class || type == void.class) { return RETURN_VOID; } if (type == Boolean.class || type == boolean.class) { return RETURN_BOOLEAN; ...
Create a Java method that does the following: "Get the return type of a function.".
Of course, here is the Java code you requested: ```java public Object[] getInjectedValueArray(Method method, Object[] args, ExecutionContext ctx) throws IllegalArgumentException, ServiceException { ParameterMarshaller marshaller = new ParameterMarshaller(method); if ((ctx instanceof Service) == false) ...
Create a Java method that does the following: "Gets the value array for the given method and arguments.".
Of course, here is the Java code you requested: ```java public GitStatusResponse status(File repositoryPath, GitStatusOptions options, File file) throws JavaGitException, IOException { List<File> paths = new ArrayList<File>(); paths.add(file); return status(repositoryPath, options, paths); } ``` Hope ...
Create a Java method that does the following: "Git status method.".
Of course, here is the Java code you requested: ```java public GitBranchResponse branch(File repositoryPath) throws IOException, JavaGitException { CheckUtilities.checkNullArgument(repositoryPath, "repository path"); IClient client = ClientManager.getInstance().getPreferredClient(); IGitBranch gitBranch =...
Create a Java method that does the following: "Get a branch from a repository".
Of course, here is the Java code you requested: ```java public GitBranchResponse deleteBranch(File repositoryPath, boolean forceDelete, boolean remote, List<Ref> branchList) throws IOException, JavaGitException { CheckUtilities.checkNullArgument(repositoryPath, "repository path"); CheckUtilities.checkNu...
Create a Java method that does the following: "Delete a branch from a repository".
Of course, here is the Java code you requested: ```java public GitBranchResponse renameBranch(File repositoryPath, boolean forceRename, Ref newName) throws IOException, JavaGitException { CheckUtilities.checkNullArgument(repositoryPath, "repository path"); CheckUtilities.checkNullArgument(newName, "new ...
Create a Java method that does the following: "Rename a branch.".
Of course, here is the Java code you requested: ```java public GitCommitResponse commit(String comment) throws IOException, JavaGitException { GitCommit gitCommit = new GitCommit(); return gitCommit.commit(path, comment); } ``` Hope this helps!
Create a Java method that does the following: "Commits the file to the server.".
Of course, here is the Java code you requested: ```java public Ref getCurrentBranch() throws IOException, JavaGitException { GitBranch gitBranch = new GitBranch(); GitBranchOptions options = new GitBranchOptions(); GitBranchResponse response = gitBranch.branch(path, options); return response.getCurrent...
Create a Java method that does the following: "Get the current branch of the project".
Of course, here is the Java code you requested: ```java public GitStatusResponse getStatus() throws IOException, JavaGitException { GitStatus gitStatus = new GitStatus(); return gitStatus.status(path); } ``` Hope this helps!
Create a Java method that does the following: "Get status information from a Git repository.".
Of course, here is the Java code you requested: ```java public File getFileFromDeletedFilesToCommit(int index) { CheckUtilities.checkIntIndexInListRange(deletedFilesToCommit, index); return deletedFilesToCommit.get(index); } ``` Hope this helps!
Create a Java method that does the following: "Get the file from deletedFilesToCommit".
Of course, here is the Java code you requested: ```java public File getFileFromModifiedFilesToCommit(int index) { CheckUtilities.checkIntIndexInListRange(modifiedFilesToCommit, index); return modifiedFilesToCommit.get(index); } ``` Hope this helps!
Create a Java method that does the following: "Get the file from the modifiedFilesToCommit list.".
Of course, here is the Java code you requested: ```java public File getFileFromDeletedFilesNotUpdated(int index) { CheckUtilities.checkIntIndexInListRange(deletedFilesNotUpdated, index); return deletedFilesNotUpdated.get(index); } ``` Hope this helps!
Create a Java method that does the following: "Get the file from deletedFilesNotUpdated".
Of course, here is the Java code you requested: ```java public File getFileFromRenamedFiles(int index) { CheckUtilities.checkIntIndexInListRange(renamedFilesToCommit, index); return renamedFilesToCommit.get(index); } ``` Hope this helps!
Create a Java method that does the following: "Get the file from the renamedFilesToCommit list.".
Of course, here is the Java code you requested: ```java public Iterable<File> getNewFilesToCommit() { Iterator<File> fileIterator = new ArrayList<File>(newFilesToCommit).iterator(); return (new IterableIterator<File>(fileIterator)); } ``` Hope this helps!
Create a Java method that does the following: "Returns an iterable of all files that need to be committed.".
Of course, here is the Java code you requested: ```java public Iterable<File> getDeletedFilesToCommit() { Iterator<File> fileIterator = new ArrayList<File>(deletedFilesToCommit).iterator(); return (new IterableIterator<File>(fileIterator)); } ``` Hope this helps!
Create a Java method that does the following: "Get the list of files that have been deleted.".
Of course, here is the Java code you requested: ```java public Iterable<File> getDeletedFilesNotUpdated() { Iterator<File> fileIterator = new ArrayList<File>(deletedFilesNotUpdated).iterator(); return (new IterableIterator<File>(fileIterator)); } ``` Hope this helps!
Create a Java method that does the following: "Get the list of files that have been deleted.".
Of course, here is the Java code you requested: ```java public Iterable<File> getModifiedFilesNotUpdated() { Iterator<File> fileIterator = new ArrayList<File>(modifiedFilesNotUpdated).iterator(); return (new IterableIterator<File>(fileIterator)); } ``` Hope this helps!
Create a Java method that does the following: "Get the files that have been modified since the last update.".
Of course, here is the Java code you requested: ```java public Iterable<File> getRenamedFilesToCommit() { Iterator<File> fileIterator = new ArrayList<File>(renamedFilesToCommit).iterator(); return (new IterableIterator<File>(fileIterator)); } ``` Hope this helps!
Create a Java method that does the following: "Returns an Iterable of all the renamed files to commit.".
Of course, here is the Java code you requested: ```java public static GitResetResponse gitResetHard(File repository, Ref commitName) throws IOException, JavaGitException { CheckUtilities.checkNullArgument(repository, "repository"); CheckUtilities.checkNullArgument(commitName, "commitName"); IClient ...
Create a Java method that does the following: "Reset the repository to a hard commit.".
Of course, here is the Java code you requested: ```java public boolean addAddedFile(File pathToFile, String mode) { if (null == pathToFile) { return false; } return addedFiles.add(new AddedOrDeletedFile(pathToFile, mode)); } ``` Hope this helps!
Create a Java method that does the following: "Add a file to the list of added files.".
Of course, here is the Java code you requested: ```java public boolean addCopiedFile(File sourceFilePath, File destinationFilePath, int percentage) { if (null == sourceFilePath || null == destinationFilePath) { return false; } return copiedFiles.add(new CopiedOrMovedFile(sourceFilePath, destinationFi...
Create a Java method that does the following: "Add a copied file to the list of copied files.".
Of course, here is the Java code you requested: ```java public boolean addDeletedFile(File pathToFile, String mode) { if (null == pathToFile) { return false; } return deletedFiles.add(new AddedOrDeletedFile(pathToFile, mode)); } ``` Hope this helps!
Create a Java method that does the following: "Add a deleted file to the list of deleted files.".
Of course, here is the Java code you requested: ```java public boolean addRenamedFile(File sourceFilePath, File destinationFilePath, int percentage) { if (null == sourceFilePath || null == destinationFilePath) { return false; } return renamedFiles.add(new CopiedOrMovedFile(sourceFilePath, destination...
Create a Java method that does the following: "Add a renamed file to the list of renamed files.".
Of course, here is the Java code you requested: ```java public boolean setFilesChanged(String filesChangedStr) { try { this.filesChanged = Integer.parseInt(filesChangedStr); return true; } catch (NumberFormatException e) { return false; } } ``` Hope this helps!
Create a Java method that does the following: "Sets the filesChanged field from a string.".
Of course, here is the Java code you requested: ```java public boolean setLinesInserted(String linesInsertedStr) { try { this.linesInserted = Integer.parseInt(linesInsertedStr); return true; } catch (NumberFormatException e) { return false; } } ``` Hope this helps!
Create a Java method that does the following: "Sets the lines inserted in the CRS file.".
Of course, here is the Java code you requested: ```java protected List<String> buildCommand(GitMvOptions options, List<File> source, File destination) { List<String> cmd = new ArrayList<String>(); cmd.add(JavaGitConfiguration.getGitCommand()); cmd.add("mv"); if (null != options) { if (options.i...
Create a Java method that does the following: "Build command to execute mv command.".
Of course, here is the Java code you requested: ```java @Override public Object getArgumentValue(Object object, Service service) throws ClassCastException { return getInjectedValue(service); } ``` Hope this helps!
Create a Java method that does the following: "Get the argument value.".
Of course, here is the Java code you requested: ```java public GitMvResponse mv(File repositoryPath, List<File> sources, File destination) throws IOException, JavaGitException { CheckUtilities.checkNullArgument(repositoryPath, "repository path"); CheckUtilities.checkNullListArgument(sources, "sources");...
Create a Java method that does the following: "Mv a list of files to a destination".
Of course, here is the Java code you requested: ```java public static int indexOfLeft(String str, int from, char c) { int pos = -1; int f = from; while( f >= 0 && pos == -1 ) if ( str.charAt(f--) == c ) pos = f+1; return pos; } ``` Hope this helps!
Create a Java method that does the following: "Gets the index of the first occurrence of c in a String.".
Of course, here is the Java code you requested: ```java @Override public Object getBinderValue(Service service) { String providerName = getStringValue(service.getBinder()); Provider provider = Providers.getProvider(providerName); if (this.required && provider == null) { throw new IllegalArgumentEx...
Create a Java method that does the following: "Get the value of the binder.".
Of course, here is the Java code you requested: ```java public E get(final long id) { SQLiteDatabase database = openDB(); try { Cursor cursor = database.query(tableName, null, primaryKey.getName() + " = ?", new String[]{Long.toString(id)}, null, null, null); if (cursor.getCount(...
Create a Java method that does the following: "Gets an entity from the database.".
Of course, here is the Java code you requested: ```java public List<E> find(final String selection, final String[] selectionArgs, final String order) { SQLiteDatabase database = openDB(); try { Cursor cursor = database.query(tableName, null, selection, selectionArgs, null, null, order); ...
Create a Java method that does the following: "Find all records in the table.".
Of course, here is the Java code you requested: ```java public void resolveAssociations(final E data) { SQLiteDatabase database = openDB(); try { new DatabaseResolver(context, database).resolve(data, 0, Integer.MAX_VALUE); } finally { closeDB(database); } } `...
Create a Java method that does the following: "Resolves the associations of the data.".
Of course, here is the Java code you requested: ```java public boolean delete(final E data) { Number id = getFieldValue(data, primaryKey); if (id == null) { throw new IllegalArgumentException("The @PrimaryKey of the given @Entity can not be null"); } return delete(id.longVal...
Create a Java method that does the following: "Delete the record with the given primary key from the given entity.".
Of course, here is the Java code you requested: ```java @Override public void inject(Class<?> klass) throws DataException, ServiceException { // loads function def table from annotated class ScriptExtensions extensions = new ScriptProxy(klass); // load func def table and set parent to the default scrip...
Create a Java method that does the following: "Injects the specified class into the script context.".
Of course, here is the Java code you requested: ```java @Override public Object getBinderValue(Service service) { DataResultSet drs = getResultSet(this.name, service); if (this.required && drs == null) { throw new IllegalArgumentException("ResultSet " + this.name + " is required."); } return ...
Create a Java method that does the following: "Get the value of the resultset in the specified service.".
Of course, here is the Java code you requested: ```java @Override public Object getArgumentValue(Object object, Service service) throws ClassCastException { if (object instanceof String) { DataResultSet drs = getResultSet((String) object, service); if (drs != null) { return drs; } ...
Create a Java method that does the following: "Override the getArgumentValue method to return the value of the result set.".
Of course, here is the Java code you requested: ```java private DataResultSet getResultSet(String name, Service service) { ResultSet rs = service.getBinder().getResultSet(name); DataResultSet drs = new DataResultSet(); if (rs != null) { drs.copy(rs); return drs; } return null; } ``...
Create a Java method that does the following: "Get the result set from the binder".
Of course, here is the Java code you requested: ```java public List<Commit> log(File repositoryPath, GitLogOptions options) throws JavaGitException, IOException { CheckUtilities.checkFileValidity(repositoryPath); GitLogParser parser = new GitLogParser(); List<String> command = buildCommand(repositoryPath, optio...
Create a Java method that does the following: "Logs the contents of a file.".
Of course, here is the Java code you requested: ```java private List<String> buildCommand(File repositoryPath, GitLogOptions options) { List<String> command = new ArrayList<String>(); command.add(JavaGitConfiguration.getGitCommand()); command.add("log"); if(options!=null){ //General Options /** * Bre...
Create a Java method that does the following: "Build command to execute git log.".
Of course, here is the Java code you requested: ```java public GitCheckoutResponse checkout(File repositoryPath, Ref branch) throws JavaGitException, IOException { return checkout(repositoryPath, null, branch); } ``` Hope this helps!
Create a Java method that does the following: "Checkout a repository.".
Of course, here is the Java code you requested: ```java public GitCheckoutResponse checkout(File repositoryPath, List<File> paths) throws JavaGitException, IOException { CheckUtilities.checkFileValidity(repositoryPath); CheckUtilities.checkNullListArgument(paths, "list of file paths"); ...
Create a Java method that does the following: "Checkout a list of files.".
Of course, here is the Java code you requested: ```java public GitCheckoutResponse checkout(File repositoryPath, GitCheckoutOptions options, Ref branch, File path) throws JavaGitException, IOException { CheckUtilities.checkFileValidity(repositoryPath); GitCheckou...
Create a Java method that does the following: "Checkout a file.".
Of course, here is the Java code you requested: ```java private List<String> buildCommand(GitCheckoutOptions options, Ref treeIsh, List<File> paths) throws JavaGitException { List<String> command = new ArrayList<String>(); command.add(JavaGitConfiguration.getGitCommand()); command.a...
Create a Java method that does the following: "Build the command to checkout the user s Cadmium application.".
Of course, here is the Java code you requested: ```java public File getRemovedFile(int index) { CheckUtilities.checkIntIndexInListRange(removedFiles, index); return removedFiles.get(index); } ``` Hope this helps!
Create a Java method that does the following: "Get the file that was removed from the file group.".
Of course, here is the Java code you requested: ```java public void setComment(int lineNumber, String commentString) { ResponseString comment = new ResponseString(lineNumber, commentString); comments.add(comment); } ``` Hope this helps!
Create a Java method that does the following: "Sets the comment of the response.".
Of course, here is the Java code you requested: ```java @Override public void inject(Class<?> klass) throws DataException { Method[] classMethods = klass.getMethods(); for (Method method : classMethods) { ServiceMethod annotation = (ServiceMethod) method.getAnnotation(ServiceMethod.class); if ...
Create a Java method that does the following: "Injects the service methods from the given class.".
Of course, here is the Java code you requested: ```java public GitCloneResponseImpl cloneProcess(File workingDirectoryPath, GitCloneOptions options, URL repository, File directory) throws IOException, JavaGitException { List<String> commandLine = buildCommand(options, repository, directory); GitClonePars...
Create a Java method that does the following: "Clone a directory.".
Of course, here is the Java code you requested: ```java private void setup(ResetType resetType, Ref commitName) { CheckUtilities.checkNullArgument(resetType, "resetType"); CheckUtilities.checkNullArgument(commitName, "commitName"); this.resetType = resetType; this.commitName = commitName; } ``` Hop...
Create a Java method that does the following: "Setup the object.".
Of course, here is the Java code you requested: ```java public void injectClasses(List<Class<?>> classes) { for (Class<?> klass : classes) { try { inject(klass); } catch (Exception e) { String msg = "Failed to inject: " + klass.getName().toString() + " - " + e.getMessage(); Log....
Create a Java method that does the following: "Injects a list of classes into the application.".
Of course, here is the Java code you requested: ```java public void reduceDatabaseConnection() { synchronized (LOCK) { int numberOfOpenConnections = OPEN_CONNECTIONS.decrementAndGet(); if (numberOfOpenConnections == 0 && dbConnection != null) { dbConnection.close(); dbConnection = null; } } } ```...
Create a Java method that does the following: "Decrements the number of open connections and closes the database connection.".
Of course, here is the Java code you requested: ```java public Cursor rawQuery(String sql) { SQLiteDatabase db = getDatabaseConnection(); return new DbClosingCursor(db.rawQuery(sql, null), this); } ``` Hope this helps!
Create a Java method that does the following: "Returns a Cursor object that represents the raw query result.".
Of course, here is the Java code you requested: ```java public GitRmResponse rm(File repository, File path) throws IOException, JavaGitException { return processRm(repository, null, path, null); } ``` Hope this helps!
Create a Java method that does the following: "Git rm command.".
Of course, here is the Java code you requested: ```java private List<String> buildCommandLine(GitRmOptions options, File path, List<File> paths) { List<String> cmdline = new ArrayList<String>(); cmdline.add(JavaGitConfiguration.getGitCommand()); cmdline.add("rm"); if (null != options) { if (opt...
Create a Java method that does the following: "Build command line for rm command".
Of course, here is the Java code you requested: ```java public File getDeletedFile(int index) { CheckUtilities.checkIntIndexInListRange(deletedFiles, index); return deletedFiles.get(index); } ``` Hope this helps!
Create a Java method that does the following: "Get the deleted file from the index.".
Of course, here is the Java code you requested: ```java public File getModifiedFile(int index) { CheckUtilities.checkIntIndexInListRange(modifiedFiles, index); return modifiedFiles.get(index); } ``` Hope this helps!
Create a Java method that does the following: "Get the modified file at the specified index.".
Of course, here is the Java code you requested: ```java public List<Commit> getLog() throws JavaGitException, IOException { GitLog gitLog = new GitLog(); GitLogOptions options = new GitLogOptions(); options.setOptRelative(true,this.relativePath.toString()); return gitLog.log(this.file); } ``` Hope this helps...
Create a Java method that does the following: "Gets the log of the file.".
Of course, here is the Java code you requested: ```java protected static HeadElement getHead() { if (head == null) { final Element element = Document.get().getElementsByTagName("head").getItem(0); assert element != null : "HTML Head element required"; final HeadElement head ...
Create a Java method that does the following: "Gets the head element.".
Of course, here is the Java code you requested: ```java public static void inject(String javascript) { HeadElement head = getHead(); ScriptElement element = createScriptElement(); element.setText(javascript); head.appendChild(element); } ``` Hope this helps!
Create a Java method that does the following: "Inject a javascript into the page.".
Of course, here is the Java code you requested: ```java public void addFile(String fileName, Integer fileSize, String thumbnailUrl) { addFileNative(getElement(), fileName, fileSize, thumbnailUrl); } ``` Hope this helps!
Create a Java method that does the following: "Add a file to the page.".
Of course, here is the Java code you requested: ```java public ArrayList<File> getFiles() { //TODO Why ArrayList, change to list when in a proper IDE final JsArray<FileJS> filesJS = getFilesNative(getElement()); final ArrayList<File> files = new ArrayList<File>(); if (filesJS != null) { for (int i = 0; i ...
Create a Java method that does the following: "Get the files in the HTML.".
Of course, here is the Java code you requested: ```java private void compilePattern() throws ParseException { StringBuilder sb = new StringBuilder(); boolean escaped = false; final List<GlobPattern> patterns = new ArrayList<>(); for (int a = 0; a < _patternSource.length(); a++) { ...
Create a Java method that does the following: "Compile the pattern.".
Of course, here is the Java code you requested: ```java @Nonnull public static <K, V> Map<K, V> putAll(@Nonnull Map<K, V> original, @Nullable Object... a) { if (a != null) { final int length = a.length; if (length % 2 == 1) { throw new IllegalArgumentException("You m...
Create a Java method that does the following: "Put all elements of an array into a map.".
Of course, here is the Java code you requested: ```java @Nonnull public static <K, V> Map<K, V> putAllAndMakeImmutable(@Nonnull Map<K, V> original, @Nullable Object... a) { return asImmutableMap(CollectionUtils.putAll(original, a)); } ``` Hope this helps!
Create a Java method that does the following: "Puts all of the given objects into the given map and returns an immutable map.".
Of course, here is the Java code you requested: ```java @Nonnull public static <K, V> Map<K, V> asImmutableMap(@Nullable Object... a) { return putAllAndMakeImmutable(new LinkedHashMap<K, V>(), a); } ``` Hope this helps!
Create a Java method that does the following: "Returns an immutable map from the passed array.".
Of course, here is the Java code you requested: ```java @Nonnull public static <T> Collection<T> asCollection(@Nullable T... objects) { return asList(objects); } ``` Hope this helps!
Create a Java method that does the following: "Returns a collection of objects.".
Of course, here is the Java code you requested: ```java @Nonnull public static <T> Collection<T> asImmutableCollection(@Nullable T... objects) { return unmodifiableCollection(asCollection(objects)); } ``` Hope this helps!
Create a Java method that does the following: "Returns an immutable collection of the given objects.".
Of course, here is the Java code you requested: ```java @Nonnull public static <T> List<T> asList(@Nullable T... objects) { final List<T> result; if (objects == null) { result = new ArrayList<>(); } else { final int initialCapacity = Math.max(16, ((objects.length + 2...
Create a Java method that does the following: "Gets a list of the specified objects.".
Of course, here is the Java code you requested: ```java @Nonnull public static <T> List<T> asImmutableList(@Nullable T... objects) { return unmodifiableList(asList(objects)); } ``` Hope this helps!
Create a Java method that does the following: "Returns an immutable list of the given objects.".
Of course, here is the Java code you requested: ```java @Nonnull public static <T> Set<T> addAllAndMakeImmutable(@Nonnull Set<T> original, @Nullable T... objects) { return unmodifiableSet(addAll(original, objects)); } ``` Hope this helps!
Create a Java method that does the following: "Adds all objects to the given set and returns an immutable set.".
Of course, here is the Java code you requested: ```java @Nonnull public static List<String> splitToList(@Nonnull String source, @Nonnull String delimiters, boolean returnDelimiters, boolean trim) { final List<String> values = new ArrayList<>(); if (source != null) { final StringTokenize...
Create a Java method that does the following: "Split a string into a list of strings.".
Of course, here is the Java code you requested: ```java @Nonnull public static String[] split(@Nonnull String source, @Nonnull String delimiters, boolean returnDelimiters, boolean trim) { final List<String> values = splitToList(source, delimiters, returnDelimiters, trim); final String[] result = ne...
Create a Java method that does the following: "Split a string into an array of tokens.".
Of course, here is the Java code you requested: ```java public static void addElement(@Nonnull StringBuilder buf, @Nonnull String separator, @Nonnull String element) { if (buf.length() > 0) { buf.append(separator); } buf.append(element); } ``` Hope this helps!
Create a Java method that does the following: "Add an element to a string buffer.".
Of course, here is the Java code you requested: ```java public static void toLowerCase(char[] chars) { for (int a = 0; a < chars.length; a++) { chars[a] = Character.toLowerCase(chars[a]); } } ``` Hope this helps!
Create a Java method that does the following: "Convert a char array to lowercase.".
Of course, here is the Java code you requested: ```java public static boolean startsWith(char[] src, char[] find, int startAt) { int startPos = startAt; boolean result = true; // Check ranges if (src.length < startPos + find.length) { result = false; } else { ...
Create a Java method that does the following: "Check if src starts with find.".
Of course, here is the Java code you requested: ```java @SuppressWarnings({"MethodWithMultipleReturnPoints", "LabeledStatement", "ValueOfIncrementOrDecrementUsed", "ContinueStatement", "ContinueStatementWithLabel"}) public static int indexOf(char[] src, char[] find, int startAt) { int startPos = startAt; ...
Create a Java method that does the following: "Gets the index of the first occurrence of a single entry in a char array.".
Of course, here is the Java code you requested: ```java public static void log(@Nonnull Logger logger, @Nonnull LogLevel level, @Nonnull String format, @Nullable Object arg) { if (logger instanceof LocationAwareLogger) { log((LocationAwareLogger) logger, level, FQCN, null, format, new Object[]{arg}...
Create a Java method that does the following: "Logs a message at a specific level.".
Of course, here is the Java code you requested: ```java public static boolean isEnabled(@Nonnull Logger logger, @Nonnull LogLevel level, @Nonnull Marker marker) { final boolean result; if (trace.equals(level)) { result = logger.isTraceEnabled(marker); } else if (debug.equals(level))...
Create a Java method that does the following: "Check if a Logger is enabled.".
Of course, here is the Java code you requested: ```java @Override public void signRequest(Token accessToken, OAuthRequest request) { request.addHeader("Authorization", "Bearer " + accessToken.getToken()); } ``` Hope this helps!
Create a Java method that does the following: "Add Authorization header to the request".
Of course, here is the Java code you requested: ```java @Override protected void internalInit() { this.service = new GlobusOAuth20ServiceImpl(new GlobusApi(), new OAuthConfig(this.key, this.secret, this.callbackUrl, SignatureType.Header, "user", null), this.proxyHost...
Create a Java method that does the following: "Initialize the authentication service.".
Of course, here is the Java code you requested: ```java @Override protected String sendRequestForData(Token accessToken, String dataUrl) throws HttpException { final ProxyOAuthRequest request = new ProxyOAuthRequest(Verb.GET, dataUrl, this.proxyHost, this.proxyPort); if (this.connectTimeout != 0) {...
Create a Java method that does the following: "Send a request to the server for the data.".
Of course, here is the Java code you requested: ```java @Override protected UserProfile extractUserProfile(final String body) { GlobusProfile profile = new GlobusProfile(); JsonNode json = JsonHelper.getFirstNode(body); if (json != null) { String username = JsonHelper.get(json, ...
Create a Java method that does the following: "Extract user profile from body.".
Of course, here is the Java code you requested: ```java @Override protected UserProfile extractUserProfile(String body) { final GitHubProfile profile = new GitHubProfile(); final JsonNode json = JsonHelper.getFirstNode(body); if (json != null) { profile.setId(JsonHelper.get(json...
Create a Java method that does the following: "Extract user profile from body.".
Of course, here is the Java code you requested: ```java @Override protected UserProfile extractUserProfile(final String body) { final TwitterProfile profile = new TwitterProfile(); final JsonNode json = JsonHelper.getFirstNode(body); if (json != null) { profile.setId(JsonHelper....
Create a Java method that does the following: "Extract user profile from body.".
Of course, here is the Java code you requested: ```java @Override public String getAuthorizationUrl(OAuthConfig config) { Preconditions.checkValidUrl(config.getCallback(), "Must provide a valid url as callback."); return String.format(AUTHORIZE_URL, config.getApiKey(), ...
Create a Java method that does the following: "Get the authorization url.".
Of course, here is the Java code you requested: ```java public BufferedImage drawText(String text, int fontSize, Color color) { Graphics g = image.getGraphics(); g.setColor(color); Font f = new Font("宋体", Font.BOLD, fontSize); g.setFont(f); int len = text.length(); g.dra...
Create a Java method that does the following: "Draw text in image.".
Of course, here is the Java code you requested: ```java public BufferedImage scale(double scaleW, double scaleH) { width = (int) (width * scaleW); height = (int) (height * scaleH); BufferedImage newImage = new BufferedImage(width, height, image.getType()); Graphics g = ...
Create a Java method that does the following: "Scales the image by the given scale.".
Of course, here is the Java code you requested: ```java public void save(File file) { try { ImageIO.write(image, "png", file); } catch (IOException e) { e.printStackTrace(); } } ``` Hope this helps!
Create a Java method that does the following: "Saves the image to a file.".
Of course, here is the Java code you requested: ```java void validate() { if (isVisible()) { String error = validateInput(); setErrorMessage(error); setPageComplete(error == null); } } ``` Hope this helps!
Create a Java method that does the following: "Validate the input.".