id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
sequence
docstring
stringlengths
3
16k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
105
339
162,200
spacecowboy/NoNonsense-FilePicker
sample/src/main/java/com/nononsenseapps/filepicker/sample/multimedia/MultimediaPickerFragment.java
MultimediaPickerFragment.isMultimedia
protected boolean isMultimedia(File file) { //noinspection SimplifiableIfStatement if (isDir(file)) { return false; } String path = file.getPath().toLowerCase(); for (String ext : MULTIMEDIA_EXTENSIONS) { if (path.endsWith(ext)) { return true; } } return false; }
java
protected boolean isMultimedia(File file) { //noinspection SimplifiableIfStatement if (isDir(file)) { return false; } String path = file.getPath().toLowerCase(); for (String ext : MULTIMEDIA_EXTENSIONS) { if (path.endsWith(ext)) { return true; } } return false; }
[ "protected", "boolean", "isMultimedia", "(", "File", "file", ")", "{", "//noinspection SimplifiableIfStatement", "if", "(", "isDir", "(", "file", ")", ")", "{", "return", "false", ";", "}", "String", "path", "=", "file", ".", "getPath", "(", ")", ".", "toLowerCase", "(", ")", ";", "for", "(", "String", "ext", ":", "MULTIMEDIA_EXTENSIONS", ")", "{", "if", "(", "path", ".", "endsWith", "(", "ext", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
An extremely simple method for identifying multimedia. This could be improved, but it's good enough for this example. @param file which could be an image or a video @return true if the file can be previewed, false otherwise
[ "An", "extremely", "simple", "method", "for", "identifying", "multimedia", ".", "This", "could", "be", "improved", "but", "it", "s", "good", "enough", "for", "this", "example", "." ]
396ef7fa5e87791170791f9d94c78f6e42a7679a
https://github.com/spacecowboy/NoNonsense-FilePicker/blob/396ef7fa5e87791170791f9d94c78f6e42a7679a/sample/src/main/java/com/nononsenseapps/filepicker/sample/multimedia/MultimediaPickerFragment.java#L51-L65
162,201
spacecowboy/NoNonsense-FilePicker
sample/src/main/java/com/nononsenseapps/filepicker/sample/ftp/FtpPickerFragment.java
FtpPickerFragment.getLoader
@NonNull @Override public Loader<SortedList<FtpFile>> getLoader() { return new AsyncTaskLoader<SortedList<FtpFile>>(getContext()) { @Override public SortedList<FtpFile> loadInBackground() { SortedList<FtpFile> sortedList = new SortedList<>(FtpFile.class, new SortedListAdapterCallback<FtpFile>(getDummyAdapter()) { @Override public int compare(FtpFile lhs, FtpFile rhs) { if (lhs.isDirectory() && !rhs.isDirectory()) { return -1; } else if (rhs.isDirectory() && !lhs.isDirectory()) { return 1; } else { return lhs.getName().compareToIgnoreCase(rhs.getName()); } } @Override public boolean areContentsTheSame(FtpFile oldItem, FtpFile newItem) { return oldItem.getName().equals(newItem.getName()); } @Override public boolean areItemsTheSame(FtpFile item1, FtpFile item2) { return item1.getName().equals(item2.getName()); } }); if (!ftp.isConnected()) { // Connect try { ftp.connect(server, port); ftp.setFileType(FTP.ASCII_FILE_TYPE); ftp.enterLocalPassiveMode(); ftp.setUseEPSVwithIPv4(false); if (!(loggedIn = ftp.login(username, password))) { ftp.logout(); Log.e(TAG, "Login failed"); } } catch (IOException e) { if (ftp.isConnected()) { try { ftp.disconnect(); } catch (IOException ignored) { } } Log.e(TAG, "Could not connect to server."); } } if (loggedIn) { try { // handle if directory does not exist. Fall back to root. if (mCurrentPath == null || !mCurrentPath.isDirectory()) { mCurrentPath = getRoot(); } sortedList.beginBatchedUpdates(); for (FTPFile f : ftp.listFiles(mCurrentPath.getPath())) { FtpFile file; if (f.isDirectory()) { file = new FtpDir(mCurrentPath, f.getName()); } else { file = new FtpFile(mCurrentPath, f.getName()); } if (isItemVisible(file)) { sortedList.add(file); } } sortedList.endBatchedUpdates(); } catch (IOException e) { Log.e(TAG, "IOException: " + e.getMessage()); } } return sortedList; } /** * Handles a request to start the Loader. */ @Override protected void onStartLoading() { super.onStartLoading(); // handle if directory does not exist. Fall back to root. if (mCurrentPath == null || !mCurrentPath.isDirectory()) { mCurrentPath = getRoot(); } forceLoad(); } }; }
java
@NonNull @Override public Loader<SortedList<FtpFile>> getLoader() { return new AsyncTaskLoader<SortedList<FtpFile>>(getContext()) { @Override public SortedList<FtpFile> loadInBackground() { SortedList<FtpFile> sortedList = new SortedList<>(FtpFile.class, new SortedListAdapterCallback<FtpFile>(getDummyAdapter()) { @Override public int compare(FtpFile lhs, FtpFile rhs) { if (lhs.isDirectory() && !rhs.isDirectory()) { return -1; } else if (rhs.isDirectory() && !lhs.isDirectory()) { return 1; } else { return lhs.getName().compareToIgnoreCase(rhs.getName()); } } @Override public boolean areContentsTheSame(FtpFile oldItem, FtpFile newItem) { return oldItem.getName().equals(newItem.getName()); } @Override public boolean areItemsTheSame(FtpFile item1, FtpFile item2) { return item1.getName().equals(item2.getName()); } }); if (!ftp.isConnected()) { // Connect try { ftp.connect(server, port); ftp.setFileType(FTP.ASCII_FILE_TYPE); ftp.enterLocalPassiveMode(); ftp.setUseEPSVwithIPv4(false); if (!(loggedIn = ftp.login(username, password))) { ftp.logout(); Log.e(TAG, "Login failed"); } } catch (IOException e) { if (ftp.isConnected()) { try { ftp.disconnect(); } catch (IOException ignored) { } } Log.e(TAG, "Could not connect to server."); } } if (loggedIn) { try { // handle if directory does not exist. Fall back to root. if (mCurrentPath == null || !mCurrentPath.isDirectory()) { mCurrentPath = getRoot(); } sortedList.beginBatchedUpdates(); for (FTPFile f : ftp.listFiles(mCurrentPath.getPath())) { FtpFile file; if (f.isDirectory()) { file = new FtpDir(mCurrentPath, f.getName()); } else { file = new FtpFile(mCurrentPath, f.getName()); } if (isItemVisible(file)) { sortedList.add(file); } } sortedList.endBatchedUpdates(); } catch (IOException e) { Log.e(TAG, "IOException: " + e.getMessage()); } } return sortedList; } /** * Handles a request to start the Loader. */ @Override protected void onStartLoading() { super.onStartLoading(); // handle if directory does not exist. Fall back to root. if (mCurrentPath == null || !mCurrentPath.isDirectory()) { mCurrentPath = getRoot(); } forceLoad(); } }; }
[ "@", "NonNull", "@", "Override", "public", "Loader", "<", "SortedList", "<", "FtpFile", ">", ">", "getLoader", "(", ")", "{", "return", "new", "AsyncTaskLoader", "<", "SortedList", "<", "FtpFile", ">", ">", "(", "getContext", "(", ")", ")", "{", "@", "Override", "public", "SortedList", "<", "FtpFile", ">", "loadInBackground", "(", ")", "{", "SortedList", "<", "FtpFile", ">", "sortedList", "=", "new", "SortedList", "<>", "(", "FtpFile", ".", "class", ",", "new", "SortedListAdapterCallback", "<", "FtpFile", ">", "(", "getDummyAdapter", "(", ")", ")", "{", "@", "Override", "public", "int", "compare", "(", "FtpFile", "lhs", ",", "FtpFile", "rhs", ")", "{", "if", "(", "lhs", ".", "isDirectory", "(", ")", "&&", "!", "rhs", ".", "isDirectory", "(", ")", ")", "{", "return", "-", "1", ";", "}", "else", "if", "(", "rhs", ".", "isDirectory", "(", ")", "&&", "!", "lhs", ".", "isDirectory", "(", ")", ")", "{", "return", "1", ";", "}", "else", "{", "return", "lhs", ".", "getName", "(", ")", ".", "compareToIgnoreCase", "(", "rhs", ".", "getName", "(", ")", ")", ";", "}", "}", "@", "Override", "public", "boolean", "areContentsTheSame", "(", "FtpFile", "oldItem", ",", "FtpFile", "newItem", ")", "{", "return", "oldItem", ".", "getName", "(", ")", ".", "equals", "(", "newItem", ".", "getName", "(", ")", ")", ";", "}", "@", "Override", "public", "boolean", "areItemsTheSame", "(", "FtpFile", "item1", ",", "FtpFile", "item2", ")", "{", "return", "item1", ".", "getName", "(", ")", ".", "equals", "(", "item2", ".", "getName", "(", ")", ")", ";", "}", "}", ")", ";", "if", "(", "!", "ftp", ".", "isConnected", "(", ")", ")", "{", "// Connect", "try", "{", "ftp", ".", "connect", "(", "server", ",", "port", ")", ";", "ftp", ".", "setFileType", "(", "FTP", ".", "ASCII_FILE_TYPE", ")", ";", "ftp", ".", "enterLocalPassiveMode", "(", ")", ";", "ftp", ".", "setUseEPSVwithIPv4", "(", "false", ")", ";", "if", "(", "!", "(", "loggedIn", "=", "ftp", ".", "login", "(", "username", ",", "password", ")", ")", ")", "{", "ftp", ".", "logout", "(", ")", ";", "Log", ".", "e", "(", "TAG", ",", "\"Login failed\"", ")", ";", "}", "}", "catch", "(", "IOException", "e", ")", "{", "if", "(", "ftp", ".", "isConnected", "(", ")", ")", "{", "try", "{", "ftp", ".", "disconnect", "(", ")", ";", "}", "catch", "(", "IOException", "ignored", ")", "{", "}", "}", "Log", ".", "e", "(", "TAG", ",", "\"Could not connect to server.\"", ")", ";", "}", "}", "if", "(", "loggedIn", ")", "{", "try", "{", "// handle if directory does not exist. Fall back to root.", "if", "(", "mCurrentPath", "==", "null", "||", "!", "mCurrentPath", ".", "isDirectory", "(", ")", ")", "{", "mCurrentPath", "=", "getRoot", "(", ")", ";", "}", "sortedList", ".", "beginBatchedUpdates", "(", ")", ";", "for", "(", "FTPFile", "f", ":", "ftp", ".", "listFiles", "(", "mCurrentPath", ".", "getPath", "(", ")", ")", ")", "{", "FtpFile", "file", ";", "if", "(", "f", ".", "isDirectory", "(", ")", ")", "{", "file", "=", "new", "FtpDir", "(", "mCurrentPath", ",", "f", ".", "getName", "(", ")", ")", ";", "}", "else", "{", "file", "=", "new", "FtpFile", "(", "mCurrentPath", ",", "f", ".", "getName", "(", ")", ")", ";", "}", "if", "(", "isItemVisible", "(", "file", ")", ")", "{", "sortedList", ".", "add", "(", "file", ")", ";", "}", "}", "sortedList", ".", "endBatchedUpdates", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "Log", ".", "e", "(", "TAG", ",", "\"IOException: \"", "+", "e", ".", "getMessage", "(", ")", ")", ";", "}", "}", "return", "sortedList", ";", "}", "/**\n * Handles a request to start the Loader.\n */", "@", "Override", "protected", "void", "onStartLoading", "(", ")", "{", "super", ".", "onStartLoading", "(", ")", ";", "// handle if directory does not exist. Fall back to root.", "if", "(", "mCurrentPath", "==", "null", "||", "!", "mCurrentPath", ".", "isDirectory", "(", ")", ")", "{", "mCurrentPath", "=", "getRoot", "(", ")", ";", "}", "forceLoad", "(", ")", ";", "}", "}", ";", "}" ]
Get a loader that lists the files in the current path, and monitors changes.
[ "Get", "a", "loader", "that", "lists", "the", "files", "in", "the", "current", "path", "and", "monitors", "changes", "." ]
396ef7fa5e87791170791f9d94c78f6e42a7679a
https://github.com/spacecowboy/NoNonsense-FilePicker/blob/396ef7fa5e87791170791f9d94c78f6e42a7679a/sample/src/main/java/com/nononsenseapps/filepicker/sample/ftp/FtpPickerFragment.java#L203-L300
162,202
line/centraldogma
server/src/main/java/com/linecorp/centraldogma/server/internal/metadata/UserAndTimestamp.java
UserAndTimestamp.timestamp
@JsonProperty public String timestamp() { if (timestampAsText == null) { timestampAsText = DateTimeFormatter.ISO_INSTANT.format(timestamp); } return timestampAsText; }
java
@JsonProperty public String timestamp() { if (timestampAsText == null) { timestampAsText = DateTimeFormatter.ISO_INSTANT.format(timestamp); } return timestampAsText; }
[ "@", "JsonProperty", "public", "String", "timestamp", "(", ")", "{", "if", "(", "timestampAsText", "==", "null", ")", "{", "timestampAsText", "=", "DateTimeFormatter", ".", "ISO_INSTANT", ".", "format", "(", "timestamp", ")", ";", "}", "return", "timestampAsText", ";", "}" ]
Returns a date and time string which is formatted as ISO-8601.
[ "Returns", "a", "date", "and", "time", "string", "which", "is", "formatted", "as", "ISO", "-", "8601", "." ]
b9e46c67fbc26628c2186ce2f46e7fb303c831e9
https://github.com/line/centraldogma/blob/b9e46c67fbc26628c2186ce2f46e7fb303c831e9/server/src/main/java/com/linecorp/centraldogma/server/internal/metadata/UserAndTimestamp.java#L70-L76
162,203
line/centraldogma
server/src/main/java/com/linecorp/centraldogma/server/CentralDogma.java
CentralDogma.forConfig
public static CentralDogma forConfig(File configFile) throws IOException { requireNonNull(configFile, "configFile"); return new CentralDogma(Jackson.readValue(configFile, CentralDogmaConfig.class)); }
java
public static CentralDogma forConfig(File configFile) throws IOException { requireNonNull(configFile, "configFile"); return new CentralDogma(Jackson.readValue(configFile, CentralDogmaConfig.class)); }
[ "public", "static", "CentralDogma", "forConfig", "(", "File", "configFile", ")", "throws", "IOException", "{", "requireNonNull", "(", "configFile", ",", "\"configFile\"", ")", ";", "return", "new", "CentralDogma", "(", "Jackson", ".", "readValue", "(", "configFile", ",", "CentralDogmaConfig", ".", "class", ")", ")", ";", "}" ]
Creates a new instance from the given configuration file. @throws IOException if failed to load the configuration from the specified file
[ "Creates", "a", "new", "instance", "from", "the", "given", "configuration", "file", "." ]
b9e46c67fbc26628c2186ce2f46e7fb303c831e9
https://github.com/line/centraldogma/blob/b9e46c67fbc26628c2186ce2f46e7fb303c831e9/server/src/main/java/com/linecorp/centraldogma/server/CentralDogma.java#L179-L182
162,204
line/centraldogma
server/src/main/java/com/linecorp/centraldogma/server/CentralDogma.java
CentralDogma.activePort
public Optional<ServerPort> activePort() { final Server server = this.server; return server != null ? server.activePort() : Optional.empty(); }
java
public Optional<ServerPort> activePort() { final Server server = this.server; return server != null ? server.activePort() : Optional.empty(); }
[ "public", "Optional", "<", "ServerPort", ">", "activePort", "(", ")", "{", "final", "Server", "server", "=", "this", ".", "server", ";", "return", "server", "!=", "null", "?", "server", ".", "activePort", "(", ")", ":", "Optional", ".", "empty", "(", ")", ";", "}" ]
Returns the primary port of the server. @return the primary {@link ServerPort} if the server is started. {@link Optional#empty()} otherwise.
[ "Returns", "the", "primary", "port", "of", "the", "server", "." ]
b9e46c67fbc26628c2186ce2f46e7fb303c831e9
https://github.com/line/centraldogma/blob/b9e46c67fbc26628c2186ce2f46e7fb303c831e9/server/src/main/java/com/linecorp/centraldogma/server/CentralDogma.java#L230-L233
162,205
line/centraldogma
server/src/main/java/com/linecorp/centraldogma/server/CentralDogma.java
CentralDogma.activePorts
public Map<InetSocketAddress, ServerPort> activePorts() { final Server server = this.server; if (server != null) { return server.activePorts(); } else { return Collections.emptyMap(); } }
java
public Map<InetSocketAddress, ServerPort> activePorts() { final Server server = this.server; if (server != null) { return server.activePorts(); } else { return Collections.emptyMap(); } }
[ "public", "Map", "<", "InetSocketAddress", ",", "ServerPort", ">", "activePorts", "(", ")", "{", "final", "Server", "server", "=", "this", ".", "server", ";", "if", "(", "server", "!=", "null", ")", "{", "return", "server", ".", "activePorts", "(", ")", ";", "}", "else", "{", "return", "Collections", ".", "emptyMap", "(", ")", ";", "}", "}" ]
Returns the ports of the server. @return the {@link Map} which contains the pairs of local {@link InetSocketAddress} and {@link ServerPort} is the server is started. {@link Optional#empty()} otherwise.
[ "Returns", "the", "ports", "of", "the", "server", "." ]
b9e46c67fbc26628c2186ce2f46e7fb303c831e9
https://github.com/line/centraldogma/blob/b9e46c67fbc26628c2186ce2f46e7fb303c831e9/server/src/main/java/com/linecorp/centraldogma/server/CentralDogma.java#L241-L248
162,206
line/centraldogma
server/src/main/java/com/linecorp/centraldogma/server/CentralDogma.java
CentralDogma.stop
public CompletableFuture<Void> stop() { numPendingStopRequests.incrementAndGet(); return startStop.stop().thenRun(numPendingStopRequests::decrementAndGet); }
java
public CompletableFuture<Void> stop() { numPendingStopRequests.incrementAndGet(); return startStop.stop().thenRun(numPendingStopRequests::decrementAndGet); }
[ "public", "CompletableFuture", "<", "Void", ">", "stop", "(", ")", "{", "numPendingStopRequests", ".", "incrementAndGet", "(", ")", ";", "return", "startStop", ".", "stop", "(", ")", ".", "thenRun", "(", "numPendingStopRequests", "::", "decrementAndGet", ")", ";", "}" ]
Stops the server. This method does nothing if the server is stopped already.
[ "Stops", "the", "server", ".", "This", "method", "does", "nothing", "if", "the", "server", "is", "stopped", "already", "." ]
b9e46c67fbc26628c2186ce2f46e7fb303c831e9
https://github.com/line/centraldogma/blob/b9e46c67fbc26628c2186ce2f46e7fb303c831e9/server/src/main/java/com/linecorp/centraldogma/server/CentralDogma.java#L300-L303
162,207
line/centraldogma
server/src/main/java/com/linecorp/centraldogma/server/internal/storage/project/ProjectInitializer.java
ProjectInitializer.initializeInternalProject
public static void initializeInternalProject(CommandExecutor executor) { final long creationTimeMillis = System.currentTimeMillis(); try { executor.execute(createProject(creationTimeMillis, Author.SYSTEM, INTERNAL_PROJ)) .get(); } catch (Throwable cause) { cause = Exceptions.peel(cause); if (!(cause instanceof ProjectExistsException)) { throw new Error("failed to initialize an internal project", cause); } } // These repositories might be created when creating an internal project, but we try to create them // again here in order to make sure them exist because sometimes their names are changed. for (final String repo : ImmutableList.of(Project.REPO_META, Project.REPO_DOGMA)) { try { executor.execute(createRepository(creationTimeMillis, Author.SYSTEM, INTERNAL_PROJ, repo)) .get(); } catch (Throwable cause) { cause = Exceptions.peel(cause); if (!(cause instanceof RepositoryExistsException)) { throw new Error(cause); } } } }
java
public static void initializeInternalProject(CommandExecutor executor) { final long creationTimeMillis = System.currentTimeMillis(); try { executor.execute(createProject(creationTimeMillis, Author.SYSTEM, INTERNAL_PROJ)) .get(); } catch (Throwable cause) { cause = Exceptions.peel(cause); if (!(cause instanceof ProjectExistsException)) { throw new Error("failed to initialize an internal project", cause); } } // These repositories might be created when creating an internal project, but we try to create them // again here in order to make sure them exist because sometimes their names are changed. for (final String repo : ImmutableList.of(Project.REPO_META, Project.REPO_DOGMA)) { try { executor.execute(createRepository(creationTimeMillis, Author.SYSTEM, INTERNAL_PROJ, repo)) .get(); } catch (Throwable cause) { cause = Exceptions.peel(cause); if (!(cause instanceof RepositoryExistsException)) { throw new Error(cause); } } } }
[ "public", "static", "void", "initializeInternalProject", "(", "CommandExecutor", "executor", ")", "{", "final", "long", "creationTimeMillis", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "try", "{", "executor", ".", "execute", "(", "createProject", "(", "creationTimeMillis", ",", "Author", ".", "SYSTEM", ",", "INTERNAL_PROJ", ")", ")", ".", "get", "(", ")", ";", "}", "catch", "(", "Throwable", "cause", ")", "{", "cause", "=", "Exceptions", ".", "peel", "(", "cause", ")", ";", "if", "(", "!", "(", "cause", "instanceof", "ProjectExistsException", ")", ")", "{", "throw", "new", "Error", "(", "\"failed to initialize an internal project\"", ",", "cause", ")", ";", "}", "}", "// These repositories might be created when creating an internal project, but we try to create them", "// again here in order to make sure them exist because sometimes their names are changed.", "for", "(", "final", "String", "repo", ":", "ImmutableList", ".", "of", "(", "Project", ".", "REPO_META", ",", "Project", ".", "REPO_DOGMA", ")", ")", "{", "try", "{", "executor", ".", "execute", "(", "createRepository", "(", "creationTimeMillis", ",", "Author", ".", "SYSTEM", ",", "INTERNAL_PROJ", ",", "repo", ")", ")", ".", "get", "(", ")", ";", "}", "catch", "(", "Throwable", "cause", ")", "{", "cause", "=", "Exceptions", ".", "peel", "(", "cause", ")", ";", "if", "(", "!", "(", "cause", "instanceof", "RepositoryExistsException", ")", ")", "{", "throw", "new", "Error", "(", "cause", ")", ";", "}", "}", "}", "}" ]
Creates an internal project and repositories such as a token storage.
[ "Creates", "an", "internal", "project", "and", "repositories", "such", "as", "a", "token", "storage", "." ]
b9e46c67fbc26628c2186ce2f46e7fb303c831e9
https://github.com/line/centraldogma/blob/b9e46c67fbc26628c2186ce2f46e7fb303c831e9/server/src/main/java/com/linecorp/centraldogma/server/internal/storage/project/ProjectInitializer.java#L38-L62
162,208
line/centraldogma
server/src/main/java/com/linecorp/centraldogma/server/internal/replication/ZooKeeperCommandExecutor.java
ZooKeeperCommandExecutor.doExecute
@Override protected <T> CompletableFuture<T> doExecute(Command<T> command) throws Exception { final CompletableFuture<T> future = new CompletableFuture<>(); executor.execute(() -> { try { future.complete(blockingExecute(command)); } catch (Throwable t) { future.completeExceptionally(t); } }); return future; }
java
@Override protected <T> CompletableFuture<T> doExecute(Command<T> command) throws Exception { final CompletableFuture<T> future = new CompletableFuture<>(); executor.execute(() -> { try { future.complete(blockingExecute(command)); } catch (Throwable t) { future.completeExceptionally(t); } }); return future; }
[ "@", "Override", "protected", "<", "T", ">", "CompletableFuture", "<", "T", ">", "doExecute", "(", "Command", "<", "T", ">", "command", ")", "throws", "Exception", "{", "final", "CompletableFuture", "<", "T", ">", "future", "=", "new", "CompletableFuture", "<>", "(", ")", ";", "executor", ".", "execute", "(", "(", ")", "->", "{", "try", "{", "future", ".", "complete", "(", "blockingExecute", "(", "command", ")", ")", ";", "}", "catch", "(", "Throwable", "t", ")", "{", "future", ".", "completeExceptionally", "(", "t", ")", ";", "}", "}", ")", ";", "return", "future", ";", "}" ]
Ensure that all logs are replayed, any other logs can not be added before end of this function.
[ "Ensure", "that", "all", "logs", "are", "replayed", "any", "other", "logs", "can", "not", "be", "added", "before", "end", "of", "this", "function", "." ]
b9e46c67fbc26628c2186ce2f46e7fb303c831e9
https://github.com/line/centraldogma/blob/b9e46c67fbc26628c2186ce2f46e7fb303c831e9/server/src/main/java/com/linecorp/centraldogma/server/internal/replication/ZooKeeperCommandExecutor.java#L830-L841
162,209
line/centraldogma
common/src/main/java/com/linecorp/centraldogma/internal/api/v1/WatchTimeout.java
WatchTimeout.makeReasonable
public static long makeReasonable(long expectedTimeoutMillis, long bufferMillis) { checkArgument(expectedTimeoutMillis > 0, "expectedTimeoutMillis: %s (expected: > 0)", expectedTimeoutMillis); checkArgument(bufferMillis >= 0, "bufferMillis: %s (expected: > 0)", bufferMillis); final long timeout = Math.min(expectedTimeoutMillis, MAX_MILLIS); if (bufferMillis == 0) { return timeout; } if (timeout > MAX_MILLIS - bufferMillis) { return MAX_MILLIS; } else { return bufferMillis + timeout; } }
java
public static long makeReasonable(long expectedTimeoutMillis, long bufferMillis) { checkArgument(expectedTimeoutMillis > 0, "expectedTimeoutMillis: %s (expected: > 0)", expectedTimeoutMillis); checkArgument(bufferMillis >= 0, "bufferMillis: %s (expected: > 0)", bufferMillis); final long timeout = Math.min(expectedTimeoutMillis, MAX_MILLIS); if (bufferMillis == 0) { return timeout; } if (timeout > MAX_MILLIS - bufferMillis) { return MAX_MILLIS; } else { return bufferMillis + timeout; } }
[ "public", "static", "long", "makeReasonable", "(", "long", "expectedTimeoutMillis", ",", "long", "bufferMillis", ")", "{", "checkArgument", "(", "expectedTimeoutMillis", ">", "0", ",", "\"expectedTimeoutMillis: %s (expected: > 0)\"", ",", "expectedTimeoutMillis", ")", ";", "checkArgument", "(", "bufferMillis", ">=", "0", ",", "\"bufferMillis: %s (expected: > 0)\"", ",", "bufferMillis", ")", ";", "final", "long", "timeout", "=", "Math", ".", "min", "(", "expectedTimeoutMillis", ",", "MAX_MILLIS", ")", ";", "if", "(", "bufferMillis", "==", "0", ")", "{", "return", "timeout", ";", "}", "if", "(", "timeout", ">", "MAX_MILLIS", "-", "bufferMillis", ")", "{", "return", "MAX_MILLIS", ";", "}", "else", "{", "return", "bufferMillis", "+", "timeout", ";", "}", "}" ]
Returns a reasonable timeout duration for a watch request. @param expectedTimeoutMillis timeout duration that a user wants to use, in milliseconds @param bufferMillis buffer duration which needs to be added, in milliseconds @return timeout duration in milliseconds, between the specified {@code bufferMillis} and the {@link #MAX_MILLIS}.
[ "Returns", "a", "reasonable", "timeout", "duration", "for", "a", "watch", "request", "." ]
b9e46c67fbc26628c2186ce2f46e7fb303c831e9
https://github.com/line/centraldogma/blob/b9e46c67fbc26628c2186ce2f46e7fb303c831e9/common/src/main/java/com/linecorp/centraldogma/internal/api/v1/WatchTimeout.java#L49-L65
162,210
line/centraldogma
server/src/main/java/com/linecorp/centraldogma/server/CentralDogmaBuilder.java
CentralDogmaBuilder.port
public CentralDogmaBuilder port(InetSocketAddress localAddress, SessionProtocol protocol) { return port(new ServerPort(localAddress, protocol)); }
java
public CentralDogmaBuilder port(InetSocketAddress localAddress, SessionProtocol protocol) { return port(new ServerPort(localAddress, protocol)); }
[ "public", "CentralDogmaBuilder", "port", "(", "InetSocketAddress", "localAddress", ",", "SessionProtocol", "protocol", ")", "{", "return", "port", "(", "new", "ServerPort", "(", "localAddress", ",", "protocol", ")", ")", ";", "}" ]
Adds a port that serves the HTTP requests. If unspecified, cleartext HTTP on port 36462 is used. @param localAddress the TCP/IP load address to bind @param protocol {@link SessionProtocol#HTTP} or {@link SessionProtocol#HTTPS}
[ "Adds", "a", "port", "that", "serves", "the", "HTTP", "requests", ".", "If", "unspecified", "cleartext", "HTTP", "on", "port", "36462", "is", "used", "." ]
b9e46c67fbc26628c2186ce2f46e7fb303c831e9
https://github.com/line/centraldogma/blob/b9e46c67fbc26628c2186ce2f46e7fb303c831e9/server/src/main/java/com/linecorp/centraldogma/server/CentralDogmaBuilder.java#L142-L144
162,211
line/centraldogma
server/src/main/java/com/linecorp/centraldogma/server/internal/storage/repository/git/GitRepository.java
GitRepository.close
void close(Supplier<CentralDogmaException> failureCauseSupplier) { requireNonNull(failureCauseSupplier, "failureCauseSupplier"); if (closePending.compareAndSet(null, failureCauseSupplier)) { repositoryWorker.execute(() -> { rwLock.writeLock().lock(); try { if (commitIdDatabase != null) { try { commitIdDatabase.close(); } catch (Exception e) { logger.warn("Failed to close a commitId database:", e); } } if (jGitRepository != null) { try { jGitRepository.close(); } catch (Exception e) { logger.warn("Failed to close a Git repository: {}", jGitRepository.getDirectory(), e); } } } finally { rwLock.writeLock().unlock(); commitWatchers.close(failureCauseSupplier); closeFuture.complete(null); } }); } closeFuture.join(); }
java
void close(Supplier<CentralDogmaException> failureCauseSupplier) { requireNonNull(failureCauseSupplier, "failureCauseSupplier"); if (closePending.compareAndSet(null, failureCauseSupplier)) { repositoryWorker.execute(() -> { rwLock.writeLock().lock(); try { if (commitIdDatabase != null) { try { commitIdDatabase.close(); } catch (Exception e) { logger.warn("Failed to close a commitId database:", e); } } if (jGitRepository != null) { try { jGitRepository.close(); } catch (Exception e) { logger.warn("Failed to close a Git repository: {}", jGitRepository.getDirectory(), e); } } } finally { rwLock.writeLock().unlock(); commitWatchers.close(failureCauseSupplier); closeFuture.complete(null); } }); } closeFuture.join(); }
[ "void", "close", "(", "Supplier", "<", "CentralDogmaException", ">", "failureCauseSupplier", ")", "{", "requireNonNull", "(", "failureCauseSupplier", ",", "\"failureCauseSupplier\"", ")", ";", "if", "(", "closePending", ".", "compareAndSet", "(", "null", ",", "failureCauseSupplier", ")", ")", "{", "repositoryWorker", ".", "execute", "(", "(", ")", "->", "{", "rwLock", ".", "writeLock", "(", ")", ".", "lock", "(", ")", ";", "try", "{", "if", "(", "commitIdDatabase", "!=", "null", ")", "{", "try", "{", "commitIdDatabase", ".", "close", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "logger", ".", "warn", "(", "\"Failed to close a commitId database:\"", ",", "e", ")", ";", "}", "}", "if", "(", "jGitRepository", "!=", "null", ")", "{", "try", "{", "jGitRepository", ".", "close", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "logger", ".", "warn", "(", "\"Failed to close a Git repository: {}\"", ",", "jGitRepository", ".", "getDirectory", "(", ")", ",", "e", ")", ";", "}", "}", "}", "finally", "{", "rwLock", ".", "writeLock", "(", ")", ".", "unlock", "(", ")", ";", "commitWatchers", ".", "close", "(", "failureCauseSupplier", ")", ";", "closeFuture", ".", "complete", "(", "null", ")", ";", "}", "}", ")", ";", "}", "closeFuture", ".", "join", "(", ")", ";", "}" ]
Waits until all pending operations are complete and closes this repository. @param failureCauseSupplier the {@link Supplier} that creates a new {@link CentralDogmaException} which will be used to fail the operations issued after this method is called
[ "Waits", "until", "all", "pending", "operations", "are", "complete", "and", "closes", "this", "repository", "." ]
b9e46c67fbc26628c2186ce2f46e7fb303c831e9
https://github.com/line/centraldogma/blob/b9e46c67fbc26628c2186ce2f46e7fb303c831e9/server/src/main/java/com/linecorp/centraldogma/server/internal/storage/repository/git/GitRepository.java#L333-L364
162,212
line/centraldogma
server/src/main/java/com/linecorp/centraldogma/server/internal/storage/repository/git/GitRepository.java
GitRepository.diff
@Override public CompletableFuture<Map<String, Change<?>>> diff(Revision from, Revision to, String pathPattern) { final ServiceRequestContext ctx = context(); return CompletableFuture.supplyAsync(() -> { requireNonNull(from, "from"); requireNonNull(to, "to"); requireNonNull(pathPattern, "pathPattern"); failFastIfTimedOut(this, logger, ctx, "diff", from, to, pathPattern); final RevisionRange range = normalizeNow(from, to).toAscending(); readLock(); try (RevWalk rw = new RevWalk(jGitRepository)) { final RevTree treeA = rw.parseTree(commitIdDatabase.get(range.from())); final RevTree treeB = rw.parseTree(commitIdDatabase.get(range.to())); // Compare the two Git trees. // Note that we do not cache here because CachingRepository caches the final result already. return toChangeMap(blockingCompareTreesUncached(treeA, treeB, pathPatternFilterOrTreeFilter(pathPattern))); } catch (StorageException e) { throw e; } catch (Exception e) { throw new StorageException("failed to parse two trees: range=" + range, e); } finally { readUnlock(); } }, repositoryWorker); }
java
@Override public CompletableFuture<Map<String, Change<?>>> diff(Revision from, Revision to, String pathPattern) { final ServiceRequestContext ctx = context(); return CompletableFuture.supplyAsync(() -> { requireNonNull(from, "from"); requireNonNull(to, "to"); requireNonNull(pathPattern, "pathPattern"); failFastIfTimedOut(this, logger, ctx, "diff", from, to, pathPattern); final RevisionRange range = normalizeNow(from, to).toAscending(); readLock(); try (RevWalk rw = new RevWalk(jGitRepository)) { final RevTree treeA = rw.parseTree(commitIdDatabase.get(range.from())); final RevTree treeB = rw.parseTree(commitIdDatabase.get(range.to())); // Compare the two Git trees. // Note that we do not cache here because CachingRepository caches the final result already. return toChangeMap(blockingCompareTreesUncached(treeA, treeB, pathPatternFilterOrTreeFilter(pathPattern))); } catch (StorageException e) { throw e; } catch (Exception e) { throw new StorageException("failed to parse two trees: range=" + range, e); } finally { readUnlock(); } }, repositoryWorker); }
[ "@", "Override", "public", "CompletableFuture", "<", "Map", "<", "String", ",", "Change", "<", "?", ">", ">", ">", "diff", "(", "Revision", "from", ",", "Revision", "to", ",", "String", "pathPattern", ")", "{", "final", "ServiceRequestContext", "ctx", "=", "context", "(", ")", ";", "return", "CompletableFuture", ".", "supplyAsync", "(", "(", ")", "->", "{", "requireNonNull", "(", "from", ",", "\"from\"", ")", ";", "requireNonNull", "(", "to", ",", "\"to\"", ")", ";", "requireNonNull", "(", "pathPattern", ",", "\"pathPattern\"", ")", ";", "failFastIfTimedOut", "(", "this", ",", "logger", ",", "ctx", ",", "\"diff\"", ",", "from", ",", "to", ",", "pathPattern", ")", ";", "final", "RevisionRange", "range", "=", "normalizeNow", "(", "from", ",", "to", ")", ".", "toAscending", "(", ")", ";", "readLock", "(", ")", ";", "try", "(", "RevWalk", "rw", "=", "new", "RevWalk", "(", "jGitRepository", ")", ")", "{", "final", "RevTree", "treeA", "=", "rw", ".", "parseTree", "(", "commitIdDatabase", ".", "get", "(", "range", ".", "from", "(", ")", ")", ")", ";", "final", "RevTree", "treeB", "=", "rw", ".", "parseTree", "(", "commitIdDatabase", ".", "get", "(", "range", ".", "to", "(", ")", ")", ")", ";", "// Compare the two Git trees.", "// Note that we do not cache here because CachingRepository caches the final result already.", "return", "toChangeMap", "(", "blockingCompareTreesUncached", "(", "treeA", ",", "treeB", ",", "pathPatternFilterOrTreeFilter", "(", "pathPattern", ")", ")", ")", ";", "}", "catch", "(", "StorageException", "e", ")", "{", "throw", "e", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "StorageException", "(", "\"failed to parse two trees: range=\"", "+", "range", ",", "e", ")", ";", "}", "finally", "{", "readUnlock", "(", ")", ";", "}", "}", ",", "repositoryWorker", ")", ";", "}" ]
Get the diff between any two valid revisions. @param from revision from @param to revision to @param pathPattern target path pattern @return the map of changes mapped by path @throws StorageException if {@code from} or {@code to} does not exist.
[ "Get", "the", "diff", "between", "any", "two", "valid", "revisions", "." ]
b9e46c67fbc26628c2186ce2f46e7fb303c831e9
https://github.com/line/centraldogma/blob/b9e46c67fbc26628c2186ce2f46e7fb303c831e9/server/src/main/java/com/linecorp/centraldogma/server/internal/storage/repository/git/GitRepository.java#L655-L683
162,213
line/centraldogma
server/src/main/java/com/linecorp/centraldogma/server/internal/storage/repository/git/GitRepository.java
GitRepository.uncachedHeadRevision
private Revision uncachedHeadRevision() { try (RevWalk revWalk = new RevWalk(jGitRepository)) { final ObjectId headRevisionId = jGitRepository.resolve(R_HEADS_MASTER); if (headRevisionId != null) { final RevCommit revCommit = revWalk.parseCommit(headRevisionId); return CommitUtil.extractRevision(revCommit.getFullMessage()); } } catch (CentralDogmaException e) { throw e; } catch (Exception e) { throw new StorageException("failed to get the current revision", e); } throw new StorageException("failed to determine the HEAD: " + jGitRepository.getDirectory()); }
java
private Revision uncachedHeadRevision() { try (RevWalk revWalk = new RevWalk(jGitRepository)) { final ObjectId headRevisionId = jGitRepository.resolve(R_HEADS_MASTER); if (headRevisionId != null) { final RevCommit revCommit = revWalk.parseCommit(headRevisionId); return CommitUtil.extractRevision(revCommit.getFullMessage()); } } catch (CentralDogmaException e) { throw e; } catch (Exception e) { throw new StorageException("failed to get the current revision", e); } throw new StorageException("failed to determine the HEAD: " + jGitRepository.getDirectory()); }
[ "private", "Revision", "uncachedHeadRevision", "(", ")", "{", "try", "(", "RevWalk", "revWalk", "=", "new", "RevWalk", "(", "jGitRepository", ")", ")", "{", "final", "ObjectId", "headRevisionId", "=", "jGitRepository", ".", "resolve", "(", "R_HEADS_MASTER", ")", ";", "if", "(", "headRevisionId", "!=", "null", ")", "{", "final", "RevCommit", "revCommit", "=", "revWalk", ".", "parseCommit", "(", "headRevisionId", ")", ";", "return", "CommitUtil", ".", "extractRevision", "(", "revCommit", ".", "getFullMessage", "(", ")", ")", ";", "}", "}", "catch", "(", "CentralDogmaException", "e", ")", "{", "throw", "e", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "StorageException", "(", "\"failed to get the current revision\"", ",", "e", ")", ";", "}", "throw", "new", "StorageException", "(", "\"failed to determine the HEAD: \"", "+", "jGitRepository", ".", "getDirectory", "(", ")", ")", ";", "}" ]
Returns the current revision.
[ "Returns", "the", "current", "revision", "." ]
b9e46c67fbc26628c2186ce2f46e7fb303c831e9
https://github.com/line/centraldogma/blob/b9e46c67fbc26628c2186ce2f46e7fb303c831e9/server/src/main/java/com/linecorp/centraldogma/server/internal/storage/repository/git/GitRepository.java#L1443-L1457
162,214
line/centraldogma
common/src/main/java/com/linecorp/centraldogma/internal/Util.java
Util.simpleTypeName
public static String simpleTypeName(Object obj) { if (obj == null) { return "null"; } return simpleTypeName(obj.getClass(), false); }
java
public static String simpleTypeName(Object obj) { if (obj == null) { return "null"; } return simpleTypeName(obj.getClass(), false); }
[ "public", "static", "String", "simpleTypeName", "(", "Object", "obj", ")", "{", "if", "(", "obj", "==", "null", ")", "{", "return", "\"null\"", ";", "}", "return", "simpleTypeName", "(", "obj", ".", "getClass", "(", ")", ",", "false", ")", ";", "}" ]
Returns the simplified name of the type of the specified object.
[ "Returns", "the", "simplified", "name", "of", "the", "type", "of", "the", "specified", "object", "." ]
b9e46c67fbc26628c2186ce2f46e7fb303c831e9
https://github.com/line/centraldogma/blob/b9e46c67fbc26628c2186ce2f46e7fb303c831e9/common/src/main/java/com/linecorp/centraldogma/internal/Util.java#L224-L230
162,215
line/centraldogma
client/java/src/main/java/com/linecorp/centraldogma/client/AbstractCentralDogmaBuilder.java
AbstractCentralDogmaBuilder.accessToken
public final B accessToken(String accessToken) { requireNonNull(accessToken, "accessToken"); checkArgument(!accessToken.isEmpty(), "accessToken is empty."); this.accessToken = accessToken; return self(); }
java
public final B accessToken(String accessToken) { requireNonNull(accessToken, "accessToken"); checkArgument(!accessToken.isEmpty(), "accessToken is empty."); this.accessToken = accessToken; return self(); }
[ "public", "final", "B", "accessToken", "(", "String", "accessToken", ")", "{", "requireNonNull", "(", "accessToken", ",", "\"accessToken\"", ")", ";", "checkArgument", "(", "!", "accessToken", ".", "isEmpty", "(", ")", ",", "\"accessToken is empty.\"", ")", ";", "this", ".", "accessToken", "=", "accessToken", ";", "return", "self", "(", ")", ";", "}" ]
Sets the access token to use when authenticating a client.
[ "Sets", "the", "access", "token", "to", "use", "when", "authenticating", "a", "client", "." ]
b9e46c67fbc26628c2186ce2f46e7fb303c831e9
https://github.com/line/centraldogma/blob/b9e46c67fbc26628c2186ce2f46e7fb303c831e9/client/java/src/main/java/com/linecorp/centraldogma/client/AbstractCentralDogmaBuilder.java#L335-L340
162,216
line/centraldogma
common/src/main/java/com/linecorp/centraldogma/internal/jsonpatch/JsonPatch.java
JsonPatch.fromJson
public static JsonPatch fromJson(final JsonNode node) throws IOException { requireNonNull(node, "node"); try { return Jackson.treeToValue(node, JsonPatch.class); } catch (JsonMappingException e) { throw new JsonPatchException("invalid JSON patch", e); } }
java
public static JsonPatch fromJson(final JsonNode node) throws IOException { requireNonNull(node, "node"); try { return Jackson.treeToValue(node, JsonPatch.class); } catch (JsonMappingException e) { throw new JsonPatchException("invalid JSON patch", e); } }
[ "public", "static", "JsonPatch", "fromJson", "(", "final", "JsonNode", "node", ")", "throws", "IOException", "{", "requireNonNull", "(", "node", ",", "\"node\"", ")", ";", "try", "{", "return", "Jackson", ".", "treeToValue", "(", "node", ",", "JsonPatch", ".", "class", ")", ";", "}", "catch", "(", "JsonMappingException", "e", ")", "{", "throw", "new", "JsonPatchException", "(", "\"invalid JSON patch\"", ",", "e", ")", ";", "}", "}" ]
Static factory method to build a JSON Patch out of a JSON representation. @param node the JSON representation of the generated JSON Patch @return a JSON Patch @throws IOException input is not a valid JSON patch @throws NullPointerException input is null
[ "Static", "factory", "method", "to", "build", "a", "JSON", "Patch", "out", "of", "a", "JSON", "representation", "." ]
b9e46c67fbc26628c2186ce2f46e7fb303c831e9
https://github.com/line/centraldogma/blob/b9e46c67fbc26628c2186ce2f46e7fb303c831e9/common/src/main/java/com/linecorp/centraldogma/internal/jsonpatch/JsonPatch.java#L137-L144
162,217
line/centraldogma
common/src/main/java/com/linecorp/centraldogma/internal/jsonpatch/JsonPatch.java
JsonPatch.generate
public static JsonPatch generate(final JsonNode source, final JsonNode target, ReplaceMode replaceMode) { requireNonNull(source, "source"); requireNonNull(target, "target"); final DiffProcessor processor = new DiffProcessor(replaceMode, () -> unchangedValues(source, target)); generateDiffs(processor, EMPTY_JSON_POINTER, source, target); return processor.getPatch(); }
java
public static JsonPatch generate(final JsonNode source, final JsonNode target, ReplaceMode replaceMode) { requireNonNull(source, "source"); requireNonNull(target, "target"); final DiffProcessor processor = new DiffProcessor(replaceMode, () -> unchangedValues(source, target)); generateDiffs(processor, EMPTY_JSON_POINTER, source, target); return processor.getPatch(); }
[ "public", "static", "JsonPatch", "generate", "(", "final", "JsonNode", "source", ",", "final", "JsonNode", "target", ",", "ReplaceMode", "replaceMode", ")", "{", "requireNonNull", "(", "source", ",", "\"source\"", ")", ";", "requireNonNull", "(", "target", ",", "\"target\"", ")", ";", "final", "DiffProcessor", "processor", "=", "new", "DiffProcessor", "(", "replaceMode", ",", "(", ")", "->", "unchangedValues", "(", "source", ",", "target", ")", ")", ";", "generateDiffs", "(", "processor", ",", "EMPTY_JSON_POINTER", ",", "source", ",", "target", ")", ";", "return", "processor", ".", "getPatch", "(", ")", ";", "}" ]
Generates a JSON patch for transforming the source node into the target node. @param source the node to be patched @param target the expected result after applying the patch @param replaceMode the replace mode to be used @return the patch as a {@link JsonPatch}
[ "Generates", "a", "JSON", "patch", "for", "transforming", "the", "source", "node", "into", "the", "target", "node", "." ]
b9e46c67fbc26628c2186ce2f46e7fb303c831e9
https://github.com/line/centraldogma/blob/b9e46c67fbc26628c2186ce2f46e7fb303c831e9/common/src/main/java/com/linecorp/centraldogma/internal/jsonpatch/JsonPatch.java#L154-L160
162,218
line/centraldogma
common/src/main/java/com/linecorp/centraldogma/internal/jsonpatch/JsonPatch.java
JsonPatch.apply
public JsonNode apply(final JsonNode node) { requireNonNull(node, "node"); JsonNode ret = node.deepCopy(); for (final JsonPatchOperation operation : operations) { ret = operation.apply(ret); } return ret; }
java
public JsonNode apply(final JsonNode node) { requireNonNull(node, "node"); JsonNode ret = node.deepCopy(); for (final JsonPatchOperation operation : operations) { ret = operation.apply(ret); } return ret; }
[ "public", "JsonNode", "apply", "(", "final", "JsonNode", "node", ")", "{", "requireNonNull", "(", "node", ",", "\"node\"", ")", ";", "JsonNode", "ret", "=", "node", ".", "deepCopy", "(", ")", ";", "for", "(", "final", "JsonPatchOperation", "operation", ":", "operations", ")", "{", "ret", "=", "operation", ".", "apply", "(", "ret", ")", ";", "}", "return", "ret", ";", "}" ]
Applies this patch to a JSON value. @param node the value to apply the patch to @return the patched JSON value @throws JsonPatchException failed to apply patch @throws NullPointerException input is null
[ "Applies", "this", "patch", "to", "a", "JSON", "value", "." ]
b9e46c67fbc26628c2186ce2f46e7fb303c831e9
https://github.com/line/centraldogma/blob/b9e46c67fbc26628c2186ce2f46e7fb303c831e9/common/src/main/java/com/linecorp/centraldogma/internal/jsonpatch/JsonPatch.java#L345-L353
162,219
line/centraldogma
server/src/main/java/com/linecorp/centraldogma/server/internal/thrift/Converter.java
Converter.convert
static Project convert( String name, com.linecorp.centraldogma.server.storage.project.Project project) { return new Project(name); }
java
static Project convert( String name, com.linecorp.centraldogma.server.storage.project.Project project) { return new Project(name); }
[ "static", "Project", "convert", "(", "String", "name", ",", "com", ".", "linecorp", ".", "centraldogma", ".", "server", ".", "storage", ".", "project", ".", "Project", "project", ")", "{", "return", "new", "Project", "(", "name", ")", ";", "}" ]
The parameter 'project' is not used at the moment, but will be used once schema and plugin support lands.
[ "The", "parameter", "project", "is", "not", "used", "at", "the", "moment", "but", "will", "be", "used", "once", "schema", "and", "plugin", "support", "lands", "." ]
b9e46c67fbc26628c2186ce2f46e7fb303c831e9
https://github.com/line/centraldogma/blob/b9e46c67fbc26628c2186ce2f46e7fb303c831e9/server/src/main/java/com/linecorp/centraldogma/server/internal/thrift/Converter.java#L159-L162
162,220
indeedeng/proctor
proctor-store/src/main/java/com/indeed/proctor/store/cache/CachingProctorStore.java
CachingProctorStore.getMatrixHistory
@Override public List<Revision> getMatrixHistory(final int start, final int limit) throws StoreException { return delegate.getMatrixHistory(start, limit); }
java
@Override public List<Revision> getMatrixHistory(final int start, final int limit) throws StoreException { return delegate.getMatrixHistory(start, limit); }
[ "@", "Override", "public", "List", "<", "Revision", ">", "getMatrixHistory", "(", "final", "int", "start", ",", "final", "int", "limit", ")", "throws", "StoreException", "{", "return", "delegate", ".", "getMatrixHistory", "(", "start", ",", "limit", ")", ";", "}" ]
caching is not supported for this method
[ "caching", "is", "not", "supported", "for", "this", "method" ]
b7795acfc26a30d013655d0e0fa1d3f8d0576571
https://github.com/indeedeng/proctor/blob/b7795acfc26a30d013655d0e0fa1d3f8d0576571/proctor-store/src/main/java/com/indeed/proctor/store/cache/CachingProctorStore.java#L113-L116
162,221
indeedeng/proctor
proctor-store-svn/src/main/java/com/indeed/proctor/store/SvnWorkspaceProviderImpl.java
SvnWorkspaceProviderImpl.getUserDirectory
private static File getUserDirectory(final String prefix, final String suffix, final File parent) { final String dirname = formatDirName(prefix, suffix); return new File(parent, dirname); }
java
private static File getUserDirectory(final String prefix, final String suffix, final File parent) { final String dirname = formatDirName(prefix, suffix); return new File(parent, dirname); }
[ "private", "static", "File", "getUserDirectory", "(", "final", "String", "prefix", ",", "final", "String", "suffix", ",", "final", "File", "parent", ")", "{", "final", "String", "dirname", "=", "formatDirName", "(", "prefix", ",", "suffix", ")", ";", "return", "new", "File", "(", "parent", ",", "dirname", ")", ";", "}" ]
Returns a File object whose path is the expected user directory. Does not create or check for existence. @param prefix @param suffix @param parent @return
[ "Returns", "a", "File", "object", "whose", "path", "is", "the", "expected", "user", "directory", ".", "Does", "not", "create", "or", "check", "for", "existence", "." ]
b7795acfc26a30d013655d0e0fa1d3f8d0576571
https://github.com/indeedeng/proctor/blob/b7795acfc26a30d013655d0e0fa1d3f8d0576571/proctor-store-svn/src/main/java/com/indeed/proctor/store/SvnWorkspaceProviderImpl.java#L169-L172
162,222
indeedeng/proctor
proctor-store-svn/src/main/java/com/indeed/proctor/store/SvnWorkspaceProviderImpl.java
SvnWorkspaceProviderImpl.formatDirName
private static String formatDirName(final String prefix, final String suffix) { // Replace all invalid characters with '-' final CharMatcher invalidCharacters = VALID_SUFFIX_CHARS.negate(); return String.format("%s-%s", prefix, invalidCharacters.trimAndCollapseFrom(suffix.toLowerCase(), '-')); }
java
private static String formatDirName(final String prefix, final String suffix) { // Replace all invalid characters with '-' final CharMatcher invalidCharacters = VALID_SUFFIX_CHARS.negate(); return String.format("%s-%s", prefix, invalidCharacters.trimAndCollapseFrom(suffix.toLowerCase(), '-')); }
[ "private", "static", "String", "formatDirName", "(", "final", "String", "prefix", ",", "final", "String", "suffix", ")", "{", "// Replace all invalid characters with '-'", "final", "CharMatcher", "invalidCharacters", "=", "VALID_SUFFIX_CHARS", ".", "negate", "(", ")", ";", "return", "String", ".", "format", "(", "\"%s-%s\"", ",", "prefix", ",", "invalidCharacters", ".", "trimAndCollapseFrom", "(", "suffix", ".", "toLowerCase", "(", ")", ",", "'", "'", ")", ")", ";", "}" ]
Returns the expected name of a workspace for a given suffix @param suffix @return
[ "Returns", "the", "expected", "name", "of", "a", "workspace", "for", "a", "given", "suffix" ]
b7795acfc26a30d013655d0e0fa1d3f8d0576571
https://github.com/indeedeng/proctor/blob/b7795acfc26a30d013655d0e0fa1d3f8d0576571/proctor-store-svn/src/main/java/com/indeed/proctor/store/SvnWorkspaceProviderImpl.java#L180-L184
162,223
indeedeng/proctor
proctor-store-svn/src/main/java/com/indeed/proctor/store/SvnWorkspaceProviderImpl.java
SvnWorkspaceProviderImpl.deleteUserDirectories
private static void deleteUserDirectories(final File root, final FileFilter filter) { final File[] dirs = root.listFiles(filter); LOGGER.info("Identified (" + dirs.length + ") directories to delete"); for (final File dir : dirs) { LOGGER.info("Deleting " + dir); if (!FileUtils.deleteQuietly(dir)) { LOGGER.info("Failed to delete directory " + dir); } } }
java
private static void deleteUserDirectories(final File root, final FileFilter filter) { final File[] dirs = root.listFiles(filter); LOGGER.info("Identified (" + dirs.length + ") directories to delete"); for (final File dir : dirs) { LOGGER.info("Deleting " + dir); if (!FileUtils.deleteQuietly(dir)) { LOGGER.info("Failed to delete directory " + dir); } } }
[ "private", "static", "void", "deleteUserDirectories", "(", "final", "File", "root", ",", "final", "FileFilter", "filter", ")", "{", "final", "File", "[", "]", "dirs", "=", "root", ".", "listFiles", "(", "filter", ")", ";", "LOGGER", ".", "info", "(", "\"Identified (\"", "+", "dirs", ".", "length", "+", "\") directories to delete\"", ")", ";", "for", "(", "final", "File", "dir", ":", "dirs", ")", "{", "LOGGER", ".", "info", "(", "\"Deleting \"", "+", "dir", ")", ";", "if", "(", "!", "FileUtils", ".", "deleteQuietly", "(", "dir", ")", ")", "{", "LOGGER", ".", "info", "(", "\"Failed to delete directory \"", "+", "dir", ")", ";", "}", "}", "}" ]
Deletes all of the Directories in root that match the FileFilter @param root @param filter
[ "Deletes", "all", "of", "the", "Directories", "in", "root", "that", "match", "the", "FileFilter" ]
b7795acfc26a30d013655d0e0fa1d3f8d0576571
https://github.com/indeedeng/proctor/blob/b7795acfc26a30d013655d0e0fa1d3f8d0576571/proctor-store-svn/src/main/java/com/indeed/proctor/store/SvnWorkspaceProviderImpl.java#L201-L211
162,224
indeedeng/proctor
proctor-common/src/main/java/com/indeed/proctor/common/Proctor.java
Proctor.construct
@Nonnull public static Proctor construct(@Nonnull final TestMatrixArtifact matrix, ProctorLoadResult loadResult, FunctionMapper functionMapper) { final ExpressionFactory expressionFactory = RuleEvaluator.EXPRESSION_FACTORY; final Map<String, TestChooser<?>> testChoosers = Maps.newLinkedHashMap(); final Map<String, String> versions = Maps.newLinkedHashMap(); for (final Entry<String, ConsumableTestDefinition> entry : matrix.getTests().entrySet()) { final String testName = entry.getKey(); final ConsumableTestDefinition testDefinition = entry.getValue(); final TestType testType = testDefinition.getTestType(); final TestChooser<?> testChooser; if (TestType.RANDOM.equals(testType)) { testChooser = new RandomTestChooser(expressionFactory, functionMapper, testName, testDefinition); } else { testChooser = new StandardTestChooser(expressionFactory, functionMapper, testName, testDefinition); } testChoosers.put(testName, testChooser); versions.put(testName, testDefinition.getVersion()); } return new Proctor(matrix, loadResult, testChoosers); }
java
@Nonnull public static Proctor construct(@Nonnull final TestMatrixArtifact matrix, ProctorLoadResult loadResult, FunctionMapper functionMapper) { final ExpressionFactory expressionFactory = RuleEvaluator.EXPRESSION_FACTORY; final Map<String, TestChooser<?>> testChoosers = Maps.newLinkedHashMap(); final Map<String, String> versions = Maps.newLinkedHashMap(); for (final Entry<String, ConsumableTestDefinition> entry : matrix.getTests().entrySet()) { final String testName = entry.getKey(); final ConsumableTestDefinition testDefinition = entry.getValue(); final TestType testType = testDefinition.getTestType(); final TestChooser<?> testChooser; if (TestType.RANDOM.equals(testType)) { testChooser = new RandomTestChooser(expressionFactory, functionMapper, testName, testDefinition); } else { testChooser = new StandardTestChooser(expressionFactory, functionMapper, testName, testDefinition); } testChoosers.put(testName, testChooser); versions.put(testName, testDefinition.getVersion()); } return new Proctor(matrix, loadResult, testChoosers); }
[ "@", "Nonnull", "public", "static", "Proctor", "construct", "(", "@", "Nonnull", "final", "TestMatrixArtifact", "matrix", ",", "ProctorLoadResult", "loadResult", ",", "FunctionMapper", "functionMapper", ")", "{", "final", "ExpressionFactory", "expressionFactory", "=", "RuleEvaluator", ".", "EXPRESSION_FACTORY", ";", "final", "Map", "<", "String", ",", "TestChooser", "<", "?", ">", ">", "testChoosers", "=", "Maps", ".", "newLinkedHashMap", "(", ")", ";", "final", "Map", "<", "String", ",", "String", ">", "versions", "=", "Maps", ".", "newLinkedHashMap", "(", ")", ";", "for", "(", "final", "Entry", "<", "String", ",", "ConsumableTestDefinition", ">", "entry", ":", "matrix", ".", "getTests", "(", ")", ".", "entrySet", "(", ")", ")", "{", "final", "String", "testName", "=", "entry", ".", "getKey", "(", ")", ";", "final", "ConsumableTestDefinition", "testDefinition", "=", "entry", ".", "getValue", "(", ")", ";", "final", "TestType", "testType", "=", "testDefinition", ".", "getTestType", "(", ")", ";", "final", "TestChooser", "<", "?", ">", "testChooser", ";", "if", "(", "TestType", ".", "RANDOM", ".", "equals", "(", "testType", ")", ")", "{", "testChooser", "=", "new", "RandomTestChooser", "(", "expressionFactory", ",", "functionMapper", ",", "testName", ",", "testDefinition", ")", ";", "}", "else", "{", "testChooser", "=", "new", "StandardTestChooser", "(", "expressionFactory", ",", "functionMapper", ",", "testName", ",", "testDefinition", ")", ";", "}", "testChoosers", ".", "put", "(", "testName", ",", "testChooser", ")", ";", "versions", ".", "put", "(", "testName", ",", "testDefinition", ".", "getVersion", "(", ")", ")", ";", "}", "return", "new", "Proctor", "(", "matrix", ",", "loadResult", ",", "testChoosers", ")", ";", "}" ]
Factory method to do the setup and transformation of inputs @param matrix a {@link TestMatrixArtifact} loaded by ProctorLoader @param loadResult a {@link ProctorLoadResult} which contains result of validation of test definition @param functionMapper a given el {@link FunctionMapper} @return constructed Proctor object
[ "Factory", "method", "to", "do", "the", "setup", "and", "transformation", "of", "inputs" ]
b7795acfc26a30d013655d0e0fa1d3f8d0576571
https://github.com/indeedeng/proctor/blob/b7795acfc26a30d013655d0e0fa1d3f8d0576571/proctor-common/src/main/java/com/indeed/proctor/common/Proctor.java#L45-L67
162,225
indeedeng/proctor
proctor-common/src/main/java/com/indeed/proctor/common/ProctorUtils.java
ProctorUtils.verifyWithoutSpecification
public static ProctorLoadResult verifyWithoutSpecification(@Nonnull final TestMatrixArtifact testMatrix, final String matrixSource) { final ProctorLoadResult.Builder resultBuilder = ProctorLoadResult.newBuilder(); for (final Entry<String, ConsumableTestDefinition> entry : testMatrix.getTests().entrySet()) { final String testName = entry.getKey(); final ConsumableTestDefinition testDefinition = entry.getValue(); try { verifyInternallyConsistentDefinition(testName, matrixSource, testDefinition); } catch (IncompatibleTestMatrixException e) { LOGGER.info(String.format("Unable to load test matrix for %s", testName), e); resultBuilder.recordError(testName, e); } } return resultBuilder.build(); }
java
public static ProctorLoadResult verifyWithoutSpecification(@Nonnull final TestMatrixArtifact testMatrix, final String matrixSource) { final ProctorLoadResult.Builder resultBuilder = ProctorLoadResult.newBuilder(); for (final Entry<String, ConsumableTestDefinition> entry : testMatrix.getTests().entrySet()) { final String testName = entry.getKey(); final ConsumableTestDefinition testDefinition = entry.getValue(); try { verifyInternallyConsistentDefinition(testName, matrixSource, testDefinition); } catch (IncompatibleTestMatrixException e) { LOGGER.info(String.format("Unable to load test matrix for %s", testName), e); resultBuilder.recordError(testName, e); } } return resultBuilder.build(); }
[ "public", "static", "ProctorLoadResult", "verifyWithoutSpecification", "(", "@", "Nonnull", "final", "TestMatrixArtifact", "testMatrix", ",", "final", "String", "matrixSource", ")", "{", "final", "ProctorLoadResult", ".", "Builder", "resultBuilder", "=", "ProctorLoadResult", ".", "newBuilder", "(", ")", ";", "for", "(", "final", "Entry", "<", "String", ",", "ConsumableTestDefinition", ">", "entry", ":", "testMatrix", ".", "getTests", "(", ")", ".", "entrySet", "(", ")", ")", "{", "final", "String", "testName", "=", "entry", ".", "getKey", "(", ")", ";", "final", "ConsumableTestDefinition", "testDefinition", "=", "entry", ".", "getValue", "(", ")", ";", "try", "{", "verifyInternallyConsistentDefinition", "(", "testName", ",", "matrixSource", ",", "testDefinition", ")", ";", "}", "catch", "(", "IncompatibleTestMatrixException", "e", ")", "{", "LOGGER", ".", "info", "(", "String", ".", "format", "(", "\"Unable to load test matrix for %s\"", ",", "testName", ")", ",", "e", ")", ";", "resultBuilder", ".", "recordError", "(", "testName", ",", "e", ")", ";", "}", "}", "return", "resultBuilder", ".", "build", "(", ")", ";", "}" ]
Verifies that the TestMatrix is correct and sane without using a specification. The Proctor API doesn't use a test specification so that it can serve all tests in the matrix without restriction. Does a limited set of sanity checks that are applicable when there is no specification, and thus no required tests or provided context. @param testMatrix the {@link TestMatrixArtifact} to be verified. @param matrixSource a {@link String} of the source of proctor artifact. For example a path of proctor artifact file. @return a {@link ProctorLoadResult} to describe the result of verification. It contains errors of verification and a list of missing test.
[ "Verifies", "that", "the", "TestMatrix", "is", "correct", "and", "sane", "without", "using", "a", "specification", ".", "The", "Proctor", "API", "doesn", "t", "use", "a", "test", "specification", "so", "that", "it", "can", "serve", "all", "tests", "in", "the", "matrix", "without", "restriction", ".", "Does", "a", "limited", "set", "of", "sanity", "checks", "that", "are", "applicable", "when", "there", "is", "no", "specification", "and", "thus", "no", "required", "tests", "or", "provided", "context", "." ]
b7795acfc26a30d013655d0e0fa1d3f8d0576571
https://github.com/indeedeng/proctor/blob/b7795acfc26a30d013655d0e0fa1d3f8d0576571/proctor-common/src/main/java/com/indeed/proctor/common/ProctorUtils.java#L321-L337
162,226
indeedeng/proctor
proctor-common/src/main/java/com/indeed/proctor/common/ProctorUtils.java
ProctorUtils.verify
public static ProctorLoadResult verify( @Nonnull final TestMatrixArtifact testMatrix, final String matrixSource, @Nonnull final Map<String, TestSpecification> requiredTests, @Nonnull final FunctionMapper functionMapper, final ProvidedContext providedContext, @Nonnull final Set<String> dynamicTests ) { final ProctorLoadResult.Builder resultBuilder = ProctorLoadResult.newBuilder(); final Map<String, Map<Integer, String>> allTestsKnownBuckets = Maps.newHashMapWithExpectedSize(requiredTests.size()); for (final Entry<String, TestSpecification> entry : requiredTests.entrySet()) { final Map<Integer, String> bucketValueToName = Maps.newHashMap(); for (final Entry<String, Integer> bucket : entry.getValue().getBuckets().entrySet()) { bucketValueToName.put(bucket.getValue(), bucket.getKey()); } allTestsKnownBuckets.put(entry.getKey(), bucketValueToName); } final Map<String, ConsumableTestDefinition> definedTests = testMatrix.getTests(); final SetView<String> missingTests = Sets.difference(requiredTests.keySet(), definedTests.keySet()); resultBuilder.recordAllMissing(missingTests); for (final Entry<String, ConsumableTestDefinition> entry : definedTests.entrySet()) { final String testName = entry.getKey(); final Map<Integer, String> knownBuckets; final TestSpecification specification; final boolean isRequired; if (allTestsKnownBuckets.containsKey(testName)) { // required in specification isRequired = true; knownBuckets = allTestsKnownBuckets.remove(testName); specification = requiredTests.get(testName); } else if (dynamicTests.contains(testName)) { // resolved by dynamic filter isRequired = false; knownBuckets = Collections.emptyMap(); specification = new TestSpecification(); } else { // we don't care about this test continue; } final ConsumableTestDefinition testDefinition = entry.getValue(); try { verifyTest(testName, testDefinition, specification, knownBuckets, matrixSource, functionMapper, providedContext); } catch (IncompatibleTestMatrixException e) { if (isRequired) { LOGGER.error(String.format("Unable to load test matrix for a required test %s", testName), e); resultBuilder.recordError(testName, e); } else { LOGGER.info(String.format("Unable to load test matrix for a dynamic test %s", testName), e); resultBuilder.recordIncompatibleDynamicTest(testName, e); } } } // TODO mjs - is this check additive? resultBuilder.recordAllMissing(allTestsKnownBuckets.keySet()); resultBuilder.recordVerifiedRules(providedContext.shouldEvaluate()); final ProctorLoadResult loadResult = resultBuilder.build(); return loadResult; }
java
public static ProctorLoadResult verify( @Nonnull final TestMatrixArtifact testMatrix, final String matrixSource, @Nonnull final Map<String, TestSpecification> requiredTests, @Nonnull final FunctionMapper functionMapper, final ProvidedContext providedContext, @Nonnull final Set<String> dynamicTests ) { final ProctorLoadResult.Builder resultBuilder = ProctorLoadResult.newBuilder(); final Map<String, Map<Integer, String>> allTestsKnownBuckets = Maps.newHashMapWithExpectedSize(requiredTests.size()); for (final Entry<String, TestSpecification> entry : requiredTests.entrySet()) { final Map<Integer, String> bucketValueToName = Maps.newHashMap(); for (final Entry<String, Integer> bucket : entry.getValue().getBuckets().entrySet()) { bucketValueToName.put(bucket.getValue(), bucket.getKey()); } allTestsKnownBuckets.put(entry.getKey(), bucketValueToName); } final Map<String, ConsumableTestDefinition> definedTests = testMatrix.getTests(); final SetView<String> missingTests = Sets.difference(requiredTests.keySet(), definedTests.keySet()); resultBuilder.recordAllMissing(missingTests); for (final Entry<String, ConsumableTestDefinition> entry : definedTests.entrySet()) { final String testName = entry.getKey(); final Map<Integer, String> knownBuckets; final TestSpecification specification; final boolean isRequired; if (allTestsKnownBuckets.containsKey(testName)) { // required in specification isRequired = true; knownBuckets = allTestsKnownBuckets.remove(testName); specification = requiredTests.get(testName); } else if (dynamicTests.contains(testName)) { // resolved by dynamic filter isRequired = false; knownBuckets = Collections.emptyMap(); specification = new TestSpecification(); } else { // we don't care about this test continue; } final ConsumableTestDefinition testDefinition = entry.getValue(); try { verifyTest(testName, testDefinition, specification, knownBuckets, matrixSource, functionMapper, providedContext); } catch (IncompatibleTestMatrixException e) { if (isRequired) { LOGGER.error(String.format("Unable to load test matrix for a required test %s", testName), e); resultBuilder.recordError(testName, e); } else { LOGGER.info(String.format("Unable to load test matrix for a dynamic test %s", testName), e); resultBuilder.recordIncompatibleDynamicTest(testName, e); } } } // TODO mjs - is this check additive? resultBuilder.recordAllMissing(allTestsKnownBuckets.keySet()); resultBuilder.recordVerifiedRules(providedContext.shouldEvaluate()); final ProctorLoadResult loadResult = resultBuilder.build(); return loadResult; }
[ "public", "static", "ProctorLoadResult", "verify", "(", "@", "Nonnull", "final", "TestMatrixArtifact", "testMatrix", ",", "final", "String", "matrixSource", ",", "@", "Nonnull", "final", "Map", "<", "String", ",", "TestSpecification", ">", "requiredTests", ",", "@", "Nonnull", "final", "FunctionMapper", "functionMapper", ",", "final", "ProvidedContext", "providedContext", ",", "@", "Nonnull", "final", "Set", "<", "String", ">", "dynamicTests", ")", "{", "final", "ProctorLoadResult", ".", "Builder", "resultBuilder", "=", "ProctorLoadResult", ".", "newBuilder", "(", ")", ";", "final", "Map", "<", "String", ",", "Map", "<", "Integer", ",", "String", ">", ">", "allTestsKnownBuckets", "=", "Maps", ".", "newHashMapWithExpectedSize", "(", "requiredTests", ".", "size", "(", ")", ")", ";", "for", "(", "final", "Entry", "<", "String", ",", "TestSpecification", ">", "entry", ":", "requiredTests", ".", "entrySet", "(", ")", ")", "{", "final", "Map", "<", "Integer", ",", "String", ">", "bucketValueToName", "=", "Maps", ".", "newHashMap", "(", ")", ";", "for", "(", "final", "Entry", "<", "String", ",", "Integer", ">", "bucket", ":", "entry", ".", "getValue", "(", ")", ".", "getBuckets", "(", ")", ".", "entrySet", "(", ")", ")", "{", "bucketValueToName", ".", "put", "(", "bucket", ".", "getValue", "(", ")", ",", "bucket", ".", "getKey", "(", ")", ")", ";", "}", "allTestsKnownBuckets", ".", "put", "(", "entry", ".", "getKey", "(", ")", ",", "bucketValueToName", ")", ";", "}", "final", "Map", "<", "String", ",", "ConsumableTestDefinition", ">", "definedTests", "=", "testMatrix", ".", "getTests", "(", ")", ";", "final", "SetView", "<", "String", ">", "missingTests", "=", "Sets", ".", "difference", "(", "requiredTests", ".", "keySet", "(", ")", ",", "definedTests", ".", "keySet", "(", ")", ")", ";", "resultBuilder", ".", "recordAllMissing", "(", "missingTests", ")", ";", "for", "(", "final", "Entry", "<", "String", ",", "ConsumableTestDefinition", ">", "entry", ":", "definedTests", ".", "entrySet", "(", ")", ")", "{", "final", "String", "testName", "=", "entry", ".", "getKey", "(", ")", ";", "final", "Map", "<", "Integer", ",", "String", ">", "knownBuckets", ";", "final", "TestSpecification", "specification", ";", "final", "boolean", "isRequired", ";", "if", "(", "allTestsKnownBuckets", ".", "containsKey", "(", "testName", ")", ")", "{", "// required in specification", "isRequired", "=", "true", ";", "knownBuckets", "=", "allTestsKnownBuckets", ".", "remove", "(", "testName", ")", ";", "specification", "=", "requiredTests", ".", "get", "(", "testName", ")", ";", "}", "else", "if", "(", "dynamicTests", ".", "contains", "(", "testName", ")", ")", "{", "// resolved by dynamic filter", "isRequired", "=", "false", ";", "knownBuckets", "=", "Collections", ".", "emptyMap", "(", ")", ";", "specification", "=", "new", "TestSpecification", "(", ")", ";", "}", "else", "{", "// we don't care about this test", "continue", ";", "}", "final", "ConsumableTestDefinition", "testDefinition", "=", "entry", ".", "getValue", "(", ")", ";", "try", "{", "verifyTest", "(", "testName", ",", "testDefinition", ",", "specification", ",", "knownBuckets", ",", "matrixSource", ",", "functionMapper", ",", "providedContext", ")", ";", "}", "catch", "(", "IncompatibleTestMatrixException", "e", ")", "{", "if", "(", "isRequired", ")", "{", "LOGGER", ".", "error", "(", "String", ".", "format", "(", "\"Unable to load test matrix for a required test %s\"", ",", "testName", ")", ",", "e", ")", ";", "resultBuilder", ".", "recordError", "(", "testName", ",", "e", ")", ";", "}", "else", "{", "LOGGER", ".", "info", "(", "String", ".", "format", "(", "\"Unable to load test matrix for a dynamic test %s\"", ",", "testName", ")", ",", "e", ")", ";", "resultBuilder", ".", "recordIncompatibleDynamicTest", "(", "testName", ",", "e", ")", ";", "}", "}", "}", "// TODO mjs - is this check additive?", "resultBuilder", ".", "recordAllMissing", "(", "allTestsKnownBuckets", ".", "keySet", "(", ")", ")", ";", "resultBuilder", ".", "recordVerifiedRules", "(", "providedContext", ".", "shouldEvaluate", "(", ")", ")", ";", "final", "ProctorLoadResult", "loadResult", "=", "resultBuilder", ".", "build", "(", ")", ";", "return", "loadResult", ";", "}" ]
Does not mutate the TestMatrix. Verifies that the test matrix contains all the required tests and that each required test is valid. @param testMatrix the {@link TestMatrixArtifact} to be verified. @param matrixSource a {@link String} of the source of proctor artifact. For example a path of proctor artifact file. @param requiredTests a {@link Map} of required test. The {@link TestSpecification} would be verified @param functionMapper a given el {@link FunctionMapper} @param providedContext a {@link Map} containing variables describing the context in which the request is executing. These will be supplied to verifying all rules. @param dynamicTests a {@link Set} of dynamic tests determined by filters. @return a {@link ProctorLoadResult} to describe the result of verification. It contains errors of verification and a list of missing test.
[ "Does", "not", "mutate", "the", "TestMatrix", ".", "Verifies", "that", "the", "test", "matrix", "contains", "all", "the", "required", "tests", "and", "that", "each", "required", "test", "is", "valid", "." ]
b7795acfc26a30d013655d0e0fa1d3f8d0576571
https://github.com/indeedeng/proctor/blob/b7795acfc26a30d013655d0e0fa1d3f8d0576571/proctor-common/src/main/java/com/indeed/proctor/common/ProctorUtils.java#L401-L468
162,227
indeedeng/proctor
proctor-common/src/main/java/com/indeed/proctor/common/ProctorUtils.java
ProctorUtils.isEmptyWhitespace
static boolean isEmptyWhitespace(@Nullable final String s) { if (s == null) { return true; } return CharMatcher.WHITESPACE.matchesAllOf(s); }
java
static boolean isEmptyWhitespace(@Nullable final String s) { if (s == null) { return true; } return CharMatcher.WHITESPACE.matchesAllOf(s); }
[ "static", "boolean", "isEmptyWhitespace", "(", "@", "Nullable", "final", "String", "s", ")", "{", "if", "(", "s", "==", "null", ")", "{", "return", "true", ";", "}", "return", "CharMatcher", ".", "WHITESPACE", ".", "matchesAllOf", "(", "s", ")", ";", "}" ]
Returns flag whose value indicates if the string is null, empty or only contains whitespace characters @param s a string @return true if the string is null, empty or only contains whitespace characters
[ "Returns", "flag", "whose", "value", "indicates", "if", "the", "string", "is", "null", "empty", "or", "only", "contains", "whitespace", "characters" ]
b7795acfc26a30d013655d0e0fa1d3f8d0576571
https://github.com/indeedeng/proctor/blob/b7795acfc26a30d013655d0e0fa1d3f8d0576571/proctor-common/src/main/java/com/indeed/proctor/common/ProctorUtils.java#L910-L915
162,228
indeedeng/proctor
proctor-common/src/main/java/com/indeed/proctor/common/ProctorUtils.java
ProctorUtils.generateSpecification
public static TestSpecification generateSpecification(@Nonnull final TestDefinition testDefinition) { final TestSpecification testSpecification = new TestSpecification(); // Sort buckets by value ascending final Map<String,Integer> buckets = Maps.newLinkedHashMap(); final List<TestBucket> testDefinitionBuckets = Ordering.from(new Comparator<TestBucket>() { @Override public int compare(final TestBucket lhs, final TestBucket rhs) { return Ints.compare(lhs.getValue(), rhs.getValue()); } }).immutableSortedCopy(testDefinition.getBuckets()); int fallbackValue = -1; if(testDefinitionBuckets.size() > 0) { final TestBucket firstBucket = testDefinitionBuckets.get(0); fallbackValue = firstBucket.getValue(); // buckets are sorted, choose smallest value as the fallback value final PayloadSpecification payloadSpecification = new PayloadSpecification(); if(firstBucket.getPayload() != null && !firstBucket.getPayload().equals(Payload.EMPTY_PAYLOAD)) { final PayloadType payloadType = PayloadType.payloadTypeForName(firstBucket.getPayload().fetchType()); payloadSpecification.setType(payloadType.payloadTypeName); if (payloadType == PayloadType.MAP) { final Map<String, String> payloadSpecificationSchema = new HashMap<String, String>(); for (Map.Entry<String, Object> entry : firstBucket.getPayload().getMap().entrySet()) { payloadSpecificationSchema.put(entry.getKey(), PayloadType.payloadTypeForValue(entry.getValue()).payloadTypeName); } payloadSpecification.setSchema(payloadSpecificationSchema); } testSpecification.setPayload(payloadSpecification); } for (int i = 0; i < testDefinitionBuckets.size(); i++) { final TestBucket bucket = testDefinitionBuckets.get(i); buckets.put(bucket.getName(), bucket.getValue()); } } testSpecification.setBuckets(buckets); testSpecification.setDescription(testDefinition.getDescription()); testSpecification.setFallbackValue(fallbackValue); return testSpecification; }
java
public static TestSpecification generateSpecification(@Nonnull final TestDefinition testDefinition) { final TestSpecification testSpecification = new TestSpecification(); // Sort buckets by value ascending final Map<String,Integer> buckets = Maps.newLinkedHashMap(); final List<TestBucket> testDefinitionBuckets = Ordering.from(new Comparator<TestBucket>() { @Override public int compare(final TestBucket lhs, final TestBucket rhs) { return Ints.compare(lhs.getValue(), rhs.getValue()); } }).immutableSortedCopy(testDefinition.getBuckets()); int fallbackValue = -1; if(testDefinitionBuckets.size() > 0) { final TestBucket firstBucket = testDefinitionBuckets.get(0); fallbackValue = firstBucket.getValue(); // buckets are sorted, choose smallest value as the fallback value final PayloadSpecification payloadSpecification = new PayloadSpecification(); if(firstBucket.getPayload() != null && !firstBucket.getPayload().equals(Payload.EMPTY_PAYLOAD)) { final PayloadType payloadType = PayloadType.payloadTypeForName(firstBucket.getPayload().fetchType()); payloadSpecification.setType(payloadType.payloadTypeName); if (payloadType == PayloadType.MAP) { final Map<String, String> payloadSpecificationSchema = new HashMap<String, String>(); for (Map.Entry<String, Object> entry : firstBucket.getPayload().getMap().entrySet()) { payloadSpecificationSchema.put(entry.getKey(), PayloadType.payloadTypeForValue(entry.getValue()).payloadTypeName); } payloadSpecification.setSchema(payloadSpecificationSchema); } testSpecification.setPayload(payloadSpecification); } for (int i = 0; i < testDefinitionBuckets.size(); i++) { final TestBucket bucket = testDefinitionBuckets.get(i); buckets.put(bucket.getName(), bucket.getValue()); } } testSpecification.setBuckets(buckets); testSpecification.setDescription(testDefinition.getDescription()); testSpecification.setFallbackValue(fallbackValue); return testSpecification; }
[ "public", "static", "TestSpecification", "generateSpecification", "(", "@", "Nonnull", "final", "TestDefinition", "testDefinition", ")", "{", "final", "TestSpecification", "testSpecification", "=", "new", "TestSpecification", "(", ")", ";", "// Sort buckets by value ascending", "final", "Map", "<", "String", ",", "Integer", ">", "buckets", "=", "Maps", ".", "newLinkedHashMap", "(", ")", ";", "final", "List", "<", "TestBucket", ">", "testDefinitionBuckets", "=", "Ordering", ".", "from", "(", "new", "Comparator", "<", "TestBucket", ">", "(", ")", "{", "@", "Override", "public", "int", "compare", "(", "final", "TestBucket", "lhs", ",", "final", "TestBucket", "rhs", ")", "{", "return", "Ints", ".", "compare", "(", "lhs", ".", "getValue", "(", ")", ",", "rhs", ".", "getValue", "(", ")", ")", ";", "}", "}", ")", ".", "immutableSortedCopy", "(", "testDefinition", ".", "getBuckets", "(", ")", ")", ";", "int", "fallbackValue", "=", "-", "1", ";", "if", "(", "testDefinitionBuckets", ".", "size", "(", ")", ">", "0", ")", "{", "final", "TestBucket", "firstBucket", "=", "testDefinitionBuckets", ".", "get", "(", "0", ")", ";", "fallbackValue", "=", "firstBucket", ".", "getValue", "(", ")", ";", "// buckets are sorted, choose smallest value as the fallback value", "final", "PayloadSpecification", "payloadSpecification", "=", "new", "PayloadSpecification", "(", ")", ";", "if", "(", "firstBucket", ".", "getPayload", "(", ")", "!=", "null", "&&", "!", "firstBucket", ".", "getPayload", "(", ")", ".", "equals", "(", "Payload", ".", "EMPTY_PAYLOAD", ")", ")", "{", "final", "PayloadType", "payloadType", "=", "PayloadType", ".", "payloadTypeForName", "(", "firstBucket", ".", "getPayload", "(", ")", ".", "fetchType", "(", ")", ")", ";", "payloadSpecification", ".", "setType", "(", "payloadType", ".", "payloadTypeName", ")", ";", "if", "(", "payloadType", "==", "PayloadType", ".", "MAP", ")", "{", "final", "Map", "<", "String", ",", "String", ">", "payloadSpecificationSchema", "=", "new", "HashMap", "<", "String", ",", "String", ">", "(", ")", ";", "for", "(", "Map", ".", "Entry", "<", "String", ",", "Object", ">", "entry", ":", "firstBucket", ".", "getPayload", "(", ")", ".", "getMap", "(", ")", ".", "entrySet", "(", ")", ")", "{", "payloadSpecificationSchema", ".", "put", "(", "entry", ".", "getKey", "(", ")", ",", "PayloadType", ".", "payloadTypeForValue", "(", "entry", ".", "getValue", "(", ")", ")", ".", "payloadTypeName", ")", ";", "}", "payloadSpecification", ".", "setSchema", "(", "payloadSpecificationSchema", ")", ";", "}", "testSpecification", ".", "setPayload", "(", "payloadSpecification", ")", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "testDefinitionBuckets", ".", "size", "(", ")", ";", "i", "++", ")", "{", "final", "TestBucket", "bucket", "=", "testDefinitionBuckets", ".", "get", "(", "i", ")", ";", "buckets", ".", "put", "(", "bucket", ".", "getName", "(", ")", ",", "bucket", ".", "getValue", "(", ")", ")", ";", "}", "}", "testSpecification", ".", "setBuckets", "(", "buckets", ")", ";", "testSpecification", ".", "setDescription", "(", "testDefinition", ".", "getDescription", "(", ")", ")", ";", "testSpecification", ".", "setFallbackValue", "(", "fallbackValue", ")", ";", "return", "testSpecification", ";", "}" ]
Generates a usable test specification for a given test definition Uses the first bucket as the fallback value @param testDefinition a {@link TestDefinition} @return a {@link TestSpecification} which corresponding to given test definition.
[ "Generates", "a", "usable", "test", "specification", "for", "a", "given", "test", "definition", "Uses", "the", "first", "bucket", "as", "the", "fallback", "value" ]
b7795acfc26a30d013655d0e0fa1d3f8d0576571
https://github.com/indeedeng/proctor/blob/b7795acfc26a30d013655d0e0fa1d3f8d0576571/proctor-common/src/main/java/com/indeed/proctor/common/ProctorUtils.java#L924-L962
162,229
indeedeng/proctor
proctor-consumer/src/main/java/com/indeed/proctor/consumer/AbstractGroups.java
AbstractGroups.getPayload
@Nonnull protected Payload getPayload(final String testName) { // Get the current bucket. final TestBucket testBucket = buckets.get(testName); // Lookup Payloads for this test if (testBucket != null) { final Payload payload = testBucket.getPayload(); if (null != payload) { return payload; } } return Payload.EMPTY_PAYLOAD; }
java
@Nonnull protected Payload getPayload(final String testName) { // Get the current bucket. final TestBucket testBucket = buckets.get(testName); // Lookup Payloads for this test if (testBucket != null) { final Payload payload = testBucket.getPayload(); if (null != payload) { return payload; } } return Payload.EMPTY_PAYLOAD; }
[ "@", "Nonnull", "protected", "Payload", "getPayload", "(", "final", "String", "testName", ")", "{", "// Get the current bucket.", "final", "TestBucket", "testBucket", "=", "buckets", ".", "get", "(", "testName", ")", ";", "// Lookup Payloads for this test", "if", "(", "testBucket", "!=", "null", ")", "{", "final", "Payload", "payload", "=", "testBucket", ".", "getPayload", "(", ")", ";", "if", "(", "null", "!=", "payload", ")", "{", "return", "payload", ";", "}", "}", "return", "Payload", ".", "EMPTY_PAYLOAD", ";", "}" ]
Return the Payload attached to the current active bucket for |test|. Always returns a payload so the client doesn't crash on a malformed test definition. @param testName test name @return pay load attached to the current active bucket @deprecated Use {@link #getPayload(String, Bucket)} instead
[ "Return", "the", "Payload", "attached", "to", "the", "current", "active", "bucket", "for", "|test|", ".", "Always", "returns", "a", "payload", "so", "the", "client", "doesn", "t", "crash", "on", "a", "malformed", "test", "definition", "." ]
b7795acfc26a30d013655d0e0fa1d3f8d0576571
https://github.com/indeedeng/proctor/blob/b7795acfc26a30d013655d0e0fa1d3f8d0576571/proctor-consumer/src/main/java/com/indeed/proctor/consumer/AbstractGroups.java#L92-L106
162,230
indeedeng/proctor
proctor-consumer/src/main/java/com/indeed/proctor/consumer/ProctorConsumerUtils.java
ProctorConsumerUtils.parseForcedGroups
@Nonnull public static Map<String, Integer> parseForcedGroups(@Nonnull final HttpServletRequest request) { final String forceGroupsList = getForceGroupsStringFromRequest(request); return parseForceGroupsList(forceGroupsList); }
java
@Nonnull public static Map<String, Integer> parseForcedGroups(@Nonnull final HttpServletRequest request) { final String forceGroupsList = getForceGroupsStringFromRequest(request); return parseForceGroupsList(forceGroupsList); }
[ "@", "Nonnull", "public", "static", "Map", "<", "String", ",", "Integer", ">", "parseForcedGroups", "(", "@", "Nonnull", "final", "HttpServletRequest", "request", ")", "{", "final", "String", "forceGroupsList", "=", "getForceGroupsStringFromRequest", "(", "request", ")", ";", "return", "parseForceGroupsList", "(", "forceGroupsList", ")", ";", "}" ]
Consumer is required to do any privilege checks before getting here @param request a {@link HttpServletRequest} which may contain forced groups parameters from URL, Header or Cookie. @return a map of test names to bucket values specified by the request. Returns an empty {@link Map} if nothing was specified
[ "Consumer", "is", "required", "to", "do", "any", "privilege", "checks", "before", "getting", "here" ]
b7795acfc26a30d013655d0e0fa1d3f8d0576571
https://github.com/indeedeng/proctor/blob/b7795acfc26a30d013655d0e0fa1d3f8d0576571/proctor-consumer/src/main/java/com/indeed/proctor/consumer/ProctorConsumerUtils.java#L56-L60
162,231
indeedeng/proctor
proctor-common/src/main/java/com/indeed/proctor/common/model/Payload.java
Payload.precheckStateAllNull
private void precheckStateAllNull() throws IllegalStateException { if ((doubleValue != null) || (doubleArray != null) || (longValue != null) || (longArray != null) || (stringValue != null) || (stringArray != null) || (map != null)) { throw new IllegalStateException("Expected all properties to be empty: " + this); } }
java
private void precheckStateAllNull() throws IllegalStateException { if ((doubleValue != null) || (doubleArray != null) || (longValue != null) || (longArray != null) || (stringValue != null) || (stringArray != null) || (map != null)) { throw new IllegalStateException("Expected all properties to be empty: " + this); } }
[ "private", "void", "precheckStateAllNull", "(", ")", "throws", "IllegalStateException", "{", "if", "(", "(", "doubleValue", "!=", "null", ")", "||", "(", "doubleArray", "!=", "null", ")", "||", "(", "longValue", "!=", "null", ")", "||", "(", "longArray", "!=", "null", ")", "||", "(", "stringValue", "!=", "null", ")", "||", "(", "stringArray", "!=", "null", ")", "||", "(", "map", "!=", "null", ")", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Expected all properties to be empty: \"", "+", "this", ")", ";", "}", "}" ]
Sanity check precondition for above setters
[ "Sanity", "check", "precondition", "for", "above", "setters" ]
b7795acfc26a30d013655d0e0fa1d3f8d0576571
https://github.com/indeedeng/proctor/blob/b7795acfc26a30d013655d0e0fa1d3f8d0576571/proctor-common/src/main/java/com/indeed/proctor/common/model/Payload.java#L123-L130
162,232
indeedeng/proctor
proctor-consumer/src/main/java/com/indeed/proctor/consumer/spring/SampleRandomGroupsHttpHandler.java
SampleRandomGroupsHttpHandler.runSampling
private Map<String, Integer> runSampling( final ProctorContext proctorContext, final Set<String> targetTestNames, final TestType testType, final int determinationsToRun ) { final Set<String> targetTestGroups = getTargetTestGroups(targetTestNames); final Map<String, Integer> testGroupToOccurrences = Maps.newTreeMap(); for (final String testGroup : targetTestGroups) { testGroupToOccurrences.put(testGroup, 0); } for (int i = 0; i < determinationsToRun; ++i) { final Identifiers identifiers = TestType.RANDOM.equals(testType) ? new Identifiers(Collections.<TestType, String>emptyMap(), /* randomEnabled */ true) : Identifiers.of(testType, Long.toString(random.nextLong())); final AbstractGroups groups = supplier.getRandomGroups(proctorContext, identifiers); for (final Entry<String, TestBucket> e : groups.getProctorResult().getBuckets().entrySet()) { final String testName = e.getKey(); if (targetTestNames.contains(testName)) { final int group = e.getValue().getValue(); final String testGroup = testName + group; testGroupToOccurrences.put(testGroup, testGroupToOccurrences.get(testGroup) + 1); } } } return testGroupToOccurrences; }
java
private Map<String, Integer> runSampling( final ProctorContext proctorContext, final Set<String> targetTestNames, final TestType testType, final int determinationsToRun ) { final Set<String> targetTestGroups = getTargetTestGroups(targetTestNames); final Map<String, Integer> testGroupToOccurrences = Maps.newTreeMap(); for (final String testGroup : targetTestGroups) { testGroupToOccurrences.put(testGroup, 0); } for (int i = 0; i < determinationsToRun; ++i) { final Identifiers identifiers = TestType.RANDOM.equals(testType) ? new Identifiers(Collections.<TestType, String>emptyMap(), /* randomEnabled */ true) : Identifiers.of(testType, Long.toString(random.nextLong())); final AbstractGroups groups = supplier.getRandomGroups(proctorContext, identifiers); for (final Entry<String, TestBucket> e : groups.getProctorResult().getBuckets().entrySet()) { final String testName = e.getKey(); if (targetTestNames.contains(testName)) { final int group = e.getValue().getValue(); final String testGroup = testName + group; testGroupToOccurrences.put(testGroup, testGroupToOccurrences.get(testGroup) + 1); } } } return testGroupToOccurrences; }
[ "private", "Map", "<", "String", ",", "Integer", ">", "runSampling", "(", "final", "ProctorContext", "proctorContext", ",", "final", "Set", "<", "String", ">", "targetTestNames", ",", "final", "TestType", "testType", ",", "final", "int", "determinationsToRun", ")", "{", "final", "Set", "<", "String", ">", "targetTestGroups", "=", "getTargetTestGroups", "(", "targetTestNames", ")", ";", "final", "Map", "<", "String", ",", "Integer", ">", "testGroupToOccurrences", "=", "Maps", ".", "newTreeMap", "(", ")", ";", "for", "(", "final", "String", "testGroup", ":", "targetTestGroups", ")", "{", "testGroupToOccurrences", ".", "put", "(", "testGroup", ",", "0", ")", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "determinationsToRun", ";", "++", "i", ")", "{", "final", "Identifiers", "identifiers", "=", "TestType", ".", "RANDOM", ".", "equals", "(", "testType", ")", "?", "new", "Identifiers", "(", "Collections", ".", "<", "TestType", ",", "String", ">", "emptyMap", "(", ")", ",", "/* randomEnabled */", "true", ")", ":", "Identifiers", ".", "of", "(", "testType", ",", "Long", ".", "toString", "(", "random", ".", "nextLong", "(", ")", ")", ")", ";", "final", "AbstractGroups", "groups", "=", "supplier", ".", "getRandomGroups", "(", "proctorContext", ",", "identifiers", ")", ";", "for", "(", "final", "Entry", "<", "String", ",", "TestBucket", ">", "e", ":", "groups", ".", "getProctorResult", "(", ")", ".", "getBuckets", "(", ")", ".", "entrySet", "(", ")", ")", "{", "final", "String", "testName", "=", "e", ".", "getKey", "(", ")", ";", "if", "(", "targetTestNames", ".", "contains", "(", "testName", ")", ")", "{", "final", "int", "group", "=", "e", ".", "getValue", "(", ")", ".", "getValue", "(", ")", ";", "final", "String", "testGroup", "=", "testName", "+", "group", ";", "testGroupToOccurrences", ".", "put", "(", "testGroup", ",", "testGroupToOccurrences", ".", "get", "(", "testGroup", ")", "+", "1", ")", ";", "}", "}", "}", "return", "testGroupToOccurrences", ";", "}" ]
test, how many times the group was present in the list of groups.
[ "test", "how", "many", "times", "the", "group", "was", "present", "in", "the", "list", "of", "groups", "." ]
b7795acfc26a30d013655d0e0fa1d3f8d0576571
https://github.com/indeedeng/proctor/blob/b7795acfc26a30d013655d0e0fa1d3f8d0576571/proctor-consumer/src/main/java/com/indeed/proctor/consumer/spring/SampleRandomGroupsHttpHandler.java#L143-L171
162,233
indeedeng/proctor
proctor-consumer/src/main/java/com/indeed/proctor/consumer/spring/SampleRandomGroupsHttpHandler.java
SampleRandomGroupsHttpHandler.getProctorNotNull
private Proctor getProctorNotNull() { final Proctor proctor = proctorLoader.get(); if (proctor == null) { throw new IllegalStateException("Proctor specification and/or text matrix has not been loaded"); } return proctor; }
java
private Proctor getProctorNotNull() { final Proctor proctor = proctorLoader.get(); if (proctor == null) { throw new IllegalStateException("Proctor specification and/or text matrix has not been loaded"); } return proctor; }
[ "private", "Proctor", "getProctorNotNull", "(", ")", "{", "final", "Proctor", "proctor", "=", "proctorLoader", ".", "get", "(", ")", ";", "if", "(", "proctor", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Proctor specification and/or text matrix has not been loaded\"", ")", ";", "}", "return", "proctor", ";", "}" ]
return currently-loaded Proctor instance, throwing IllegalStateException if not loaded
[ "return", "currently", "-", "loaded", "Proctor", "instance", "throwing", "IllegalStateException", "if", "not", "loaded" ]
b7795acfc26a30d013655d0e0fa1d3f8d0576571
https://github.com/indeedeng/proctor/blob/b7795acfc26a30d013655d0e0fa1d3f8d0576571/proctor-consumer/src/main/java/com/indeed/proctor/consumer/spring/SampleRandomGroupsHttpHandler.java#L211-L217
162,234
indeedeng/proctor
proctor-common/src/main/java/com/indeed/proctor/common/dynamic/DynamicFilters.java
DynamicFilters.registerFilterTypes
@SafeVarargs public static void registerFilterTypes(final Class<? extends DynamicFilter>... types) { FILTER_TYPES.addAll(Arrays.asList(types)); }
java
@SafeVarargs public static void registerFilterTypes(final Class<? extends DynamicFilter>... types) { FILTER_TYPES.addAll(Arrays.asList(types)); }
[ "@", "SafeVarargs", "public", "static", "void", "registerFilterTypes", "(", "final", "Class", "<", "?", "extends", "DynamicFilter", ">", "...", "types", ")", "{", "FILTER_TYPES", ".", "addAll", "(", "Arrays", ".", "asList", "(", "types", ")", ")", ";", "}" ]
Register custom filter types especially for serializer of specification json file
[ "Register", "custom", "filter", "types", "especially", "for", "serializer", "of", "specification", "json", "file" ]
b7795acfc26a30d013655d0e0fa1d3f8d0576571
https://github.com/indeedeng/proctor/blob/b7795acfc26a30d013655d0e0fa1d3f8d0576571/proctor-common/src/main/java/com/indeed/proctor/common/dynamic/DynamicFilters.java#L48-L51
162,235
indeedeng/proctor
proctor-consumer/src/main/java/com/indeed/proctor/consumer/spring/AbstractSampleRandomGroupsController.java
AbstractSampleRandomGroupsController.getProctorContext
private ProctorContext getProctorContext(final HttpServletRequest request) throws IllegalAccessException, InstantiationException { final ProctorContext proctorContext = contextClass.newInstance(); final BeanWrapper beanWrapper = new BeanWrapperImpl(proctorContext); for (final PropertyDescriptor descriptor : beanWrapper.getPropertyDescriptors()) { final String propertyName = descriptor.getName(); if (!"class".equals(propertyName)) { // ignore class property which every object has final String parameterValue = request.getParameter(propertyName); if (parameterValue != null) { beanWrapper.setPropertyValue(propertyName, parameterValue); } } } return proctorContext; }
java
private ProctorContext getProctorContext(final HttpServletRequest request) throws IllegalAccessException, InstantiationException { final ProctorContext proctorContext = contextClass.newInstance(); final BeanWrapper beanWrapper = new BeanWrapperImpl(proctorContext); for (final PropertyDescriptor descriptor : beanWrapper.getPropertyDescriptors()) { final String propertyName = descriptor.getName(); if (!"class".equals(propertyName)) { // ignore class property which every object has final String parameterValue = request.getParameter(propertyName); if (parameterValue != null) { beanWrapper.setPropertyValue(propertyName, parameterValue); } } } return proctorContext; }
[ "private", "ProctorContext", "getProctorContext", "(", "final", "HttpServletRequest", "request", ")", "throws", "IllegalAccessException", ",", "InstantiationException", "{", "final", "ProctorContext", "proctorContext", "=", "contextClass", ".", "newInstance", "(", ")", ";", "final", "BeanWrapper", "beanWrapper", "=", "new", "BeanWrapperImpl", "(", "proctorContext", ")", ";", "for", "(", "final", "PropertyDescriptor", "descriptor", ":", "beanWrapper", ".", "getPropertyDescriptors", "(", ")", ")", "{", "final", "String", "propertyName", "=", "descriptor", ".", "getName", "(", ")", ";", "if", "(", "!", "\"class\"", ".", "equals", "(", "propertyName", ")", ")", "{", "// ignore class property which every object has", "final", "String", "parameterValue", "=", "request", ".", "getParameter", "(", "propertyName", ")", ";", "if", "(", "parameterValue", "!=", "null", ")", "{", "beanWrapper", ".", "setPropertyValue", "(", "propertyName", ",", "parameterValue", ")", ";", "}", "}", "}", "return", "proctorContext", ";", "}" ]
Do some magic to turn request parameters into a context object
[ "Do", "some", "magic", "to", "turn", "request", "parameters", "into", "a", "context", "object" ]
b7795acfc26a30d013655d0e0fa1d3f8d0576571
https://github.com/indeedeng/proctor/blob/b7795acfc26a30d013655d0e0fa1d3f8d0576571/proctor-consumer/src/main/java/com/indeed/proctor/consumer/spring/AbstractSampleRandomGroupsController.java#L63-L76
162,236
indeedeng/proctor
proctor-store-git/src/main/java/com/indeed/proctor/store/GitProctorUtils.java
GitProctorUtils.resolveSvnMigratedRevision
public static String resolveSvnMigratedRevision(final Revision revision, final String branch) { if (revision == null) { return null; } final Pattern pattern = Pattern.compile("^git-svn-id: .*" + branch + "@([0-9]+) ", Pattern.MULTILINE); final Matcher matcher = pattern.matcher(revision.getMessage()); if (matcher.find()) { return matcher.group(1); } else { return revision.getRevision(); } }
java
public static String resolveSvnMigratedRevision(final Revision revision, final String branch) { if (revision == null) { return null; } final Pattern pattern = Pattern.compile("^git-svn-id: .*" + branch + "@([0-9]+) ", Pattern.MULTILINE); final Matcher matcher = pattern.matcher(revision.getMessage()); if (matcher.find()) { return matcher.group(1); } else { return revision.getRevision(); } }
[ "public", "static", "String", "resolveSvnMigratedRevision", "(", "final", "Revision", "revision", ",", "final", "String", "branch", ")", "{", "if", "(", "revision", "==", "null", ")", "{", "return", "null", ";", "}", "final", "Pattern", "pattern", "=", "Pattern", ".", "compile", "(", "\"^git-svn-id: .*\"", "+", "branch", "+", "\"@([0-9]+) \"", ",", "Pattern", ".", "MULTILINE", ")", ";", "final", "Matcher", "matcher", "=", "pattern", ".", "matcher", "(", "revision", ".", "getMessage", "(", ")", ")", ";", "if", "(", "matcher", ".", "find", "(", ")", ")", "{", "return", "matcher", ".", "group", "(", "1", ")", ";", "}", "else", "{", "return", "revision", ".", "getRevision", "(", ")", ";", "}", "}" ]
Helper method to retrieve a canonical revision for git commits migrated from SVN. Migrated commits are detected by the presence of 'git-svn-id' in the commit message. @param revision the commit/revision to inspect @param branch the name of the branch it came from @return the original SVN revision if it was a migrated commit from the branch specified, otherwise the git revision
[ "Helper", "method", "to", "retrieve", "a", "canonical", "revision", "for", "git", "commits", "migrated", "from", "SVN", ".", "Migrated", "commits", "are", "detected", "by", "the", "presence", "of", "git", "-", "svn", "-", "id", "in", "the", "commit", "message", "." ]
b7795acfc26a30d013655d0e0fa1d3f8d0576571
https://github.com/indeedeng/proctor/blob/b7795acfc26a30d013655d0e0fa1d3f8d0576571/proctor-store-git/src/main/java/com/indeed/proctor/store/GitProctorUtils.java#L26-L37
162,237
HubSpot/Rosetta
RosettaCore/src/main/java/com/hubspot/rosetta/RosettaMapper.java
RosettaMapper.mapRow
public T mapRow(ResultSet rs) throws SQLException { Map<String, Object> map = new HashMap<String, Object>(); ResultSetMetaData metadata = rs.getMetaData(); for (int i = 1; i <= metadata.getColumnCount(); ++i) { String label = metadata.getColumnLabel(i); final Object value; // calling getObject on a BLOB/CLOB produces weird results switch (metadata.getColumnType(i)) { case Types.BLOB: value = rs.getBytes(i); break; case Types.CLOB: value = rs.getString(i); break; default: value = rs.getObject(i); } // don't use table name extractor because we don't want aliased table name boolean overwrite = this.tableName != null && this.tableName.equals(metadata.getTableName(i)); String tableName = TABLE_NAME_EXTRACTOR.getTableName(metadata, i); if (tableName != null && !tableName.isEmpty()) { String qualifiedName = tableName + "." + metadata.getColumnName(i); add(map, qualifiedName, value, overwrite); } add(map, label, value, overwrite); } return objectMapper.convertValue(map, type); }
java
public T mapRow(ResultSet rs) throws SQLException { Map<String, Object> map = new HashMap<String, Object>(); ResultSetMetaData metadata = rs.getMetaData(); for (int i = 1; i <= metadata.getColumnCount(); ++i) { String label = metadata.getColumnLabel(i); final Object value; // calling getObject on a BLOB/CLOB produces weird results switch (metadata.getColumnType(i)) { case Types.BLOB: value = rs.getBytes(i); break; case Types.CLOB: value = rs.getString(i); break; default: value = rs.getObject(i); } // don't use table name extractor because we don't want aliased table name boolean overwrite = this.tableName != null && this.tableName.equals(metadata.getTableName(i)); String tableName = TABLE_NAME_EXTRACTOR.getTableName(metadata, i); if (tableName != null && !tableName.isEmpty()) { String qualifiedName = tableName + "." + metadata.getColumnName(i); add(map, qualifiedName, value, overwrite); } add(map, label, value, overwrite); } return objectMapper.convertValue(map, type); }
[ "public", "T", "mapRow", "(", "ResultSet", "rs", ")", "throws", "SQLException", "{", "Map", "<", "String", ",", "Object", ">", "map", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "ResultSetMetaData", "metadata", "=", "rs", ".", "getMetaData", "(", ")", ";", "for", "(", "int", "i", "=", "1", ";", "i", "<=", "metadata", ".", "getColumnCount", "(", ")", ";", "++", "i", ")", "{", "String", "label", "=", "metadata", ".", "getColumnLabel", "(", "i", ")", ";", "final", "Object", "value", ";", "// calling getObject on a BLOB/CLOB produces weird results", "switch", "(", "metadata", ".", "getColumnType", "(", "i", ")", ")", "{", "case", "Types", ".", "BLOB", ":", "value", "=", "rs", ".", "getBytes", "(", "i", ")", ";", "break", ";", "case", "Types", ".", "CLOB", ":", "value", "=", "rs", ".", "getString", "(", "i", ")", ";", "break", ";", "default", ":", "value", "=", "rs", ".", "getObject", "(", "i", ")", ";", "}", "// don't use table name extractor because we don't want aliased table name", "boolean", "overwrite", "=", "this", ".", "tableName", "!=", "null", "&&", "this", ".", "tableName", ".", "equals", "(", "metadata", ".", "getTableName", "(", "i", ")", ")", ";", "String", "tableName", "=", "TABLE_NAME_EXTRACTOR", ".", "getTableName", "(", "metadata", ",", "i", ")", ";", "if", "(", "tableName", "!=", "null", "&&", "!", "tableName", ".", "isEmpty", "(", ")", ")", "{", "String", "qualifiedName", "=", "tableName", "+", "\".\"", "+", "metadata", ".", "getColumnName", "(", "i", ")", ";", "add", "(", "map", ",", "qualifiedName", ",", "value", ",", "overwrite", ")", ";", "}", "add", "(", "map", ",", "label", ",", "value", ",", "overwrite", ")", ";", "}", "return", "objectMapper", ".", "convertValue", "(", "map", ",", "type", ")", ";", "}" ]
Map a single ResultSet row to a T instance. @throws SQLException
[ "Map", "a", "single", "ResultSet", "row", "to", "a", "T", "instance", "." ]
6b45a88d0e604a41c4825b131a4804cfe33e3b3c
https://github.com/HubSpot/Rosetta/blob/6b45a88d0e604a41c4825b131a4804cfe33e3b3c/RosettaCore/src/main/java/com/hubspot/rosetta/RosettaMapper.java#L55-L87
162,238
LarsWerkman/HoloColorPicker
library/src/main/java/com/larswerkman/holocolorpicker/OpacityBar.java
OpacityBar.getOpacity
public int getOpacity() { int opacity = Math .round((mPosToOpacFactor * (mBarPointerPosition - mBarPointerHaloRadius))); if (opacity < 5) { return 0x00; } else if (opacity > 250) { return 0xFF; } else { return opacity; } }
java
public int getOpacity() { int opacity = Math .round((mPosToOpacFactor * (mBarPointerPosition - mBarPointerHaloRadius))); if (opacity < 5) { return 0x00; } else if (opacity > 250) { return 0xFF; } else { return opacity; } }
[ "public", "int", "getOpacity", "(", ")", "{", "int", "opacity", "=", "Math", ".", "round", "(", "(", "mPosToOpacFactor", "*", "(", "mBarPointerPosition", "-", "mBarPointerHaloRadius", ")", ")", ")", ";", "if", "(", "opacity", "<", "5", ")", "{", "return", "0x00", ";", "}", "else", "if", "(", "opacity", ">", "250", ")", "{", "return", "0xFF", ";", "}", "else", "{", "return", "opacity", ";", "}", "}" ]
Get the currently selected opacity. @return The int value of the currently selected opacity.
[ "Get", "the", "currently", "selected", "opacity", "." ]
8ba5971f8d25f80c22d9711713a51c7a7c4ac4aa
https://github.com/LarsWerkman/HoloColorPicker/blob/8ba5971f8d25f80c22d9711713a51c7a7c4ac4aa/library/src/main/java/com/larswerkman/holocolorpicker/OpacityBar.java#L458-L468
162,239
LarsWerkman/HoloColorPicker
library/src/main/java/com/larswerkman/holocolorpicker/ColorPicker.java
ColorPicker.calculateColor
private int calculateColor(float angle) { float unit = (float) (angle / (2 * Math.PI)); if (unit < 0) { unit += 1; } if (unit <= 0) { mColor = COLORS[0]; return COLORS[0]; } if (unit >= 1) { mColor = COLORS[COLORS.length - 1]; return COLORS[COLORS.length - 1]; } float p = unit * (COLORS.length - 1); int i = (int) p; p -= i; int c0 = COLORS[i]; int c1 = COLORS[i + 1]; int a = ave(Color.alpha(c0), Color.alpha(c1), p); int r = ave(Color.red(c0), Color.red(c1), p); int g = ave(Color.green(c0), Color.green(c1), p); int b = ave(Color.blue(c0), Color.blue(c1), p); mColor = Color.argb(a, r, g, b); return Color.argb(a, r, g, b); }
java
private int calculateColor(float angle) { float unit = (float) (angle / (2 * Math.PI)); if (unit < 0) { unit += 1; } if (unit <= 0) { mColor = COLORS[0]; return COLORS[0]; } if (unit >= 1) { mColor = COLORS[COLORS.length - 1]; return COLORS[COLORS.length - 1]; } float p = unit * (COLORS.length - 1); int i = (int) p; p -= i; int c0 = COLORS[i]; int c1 = COLORS[i + 1]; int a = ave(Color.alpha(c0), Color.alpha(c1), p); int r = ave(Color.red(c0), Color.red(c1), p); int g = ave(Color.green(c0), Color.green(c1), p); int b = ave(Color.blue(c0), Color.blue(c1), p); mColor = Color.argb(a, r, g, b); return Color.argb(a, r, g, b); }
[ "private", "int", "calculateColor", "(", "float", "angle", ")", "{", "float", "unit", "=", "(", "float", ")", "(", "angle", "/", "(", "2", "*", "Math", ".", "PI", ")", ")", ";", "if", "(", "unit", "<", "0", ")", "{", "unit", "+=", "1", ";", "}", "if", "(", "unit", "<=", "0", ")", "{", "mColor", "=", "COLORS", "[", "0", "]", ";", "return", "COLORS", "[", "0", "]", ";", "}", "if", "(", "unit", ">=", "1", ")", "{", "mColor", "=", "COLORS", "[", "COLORS", ".", "length", "-", "1", "]", ";", "return", "COLORS", "[", "COLORS", ".", "length", "-", "1", "]", ";", "}", "float", "p", "=", "unit", "*", "(", "COLORS", ".", "length", "-", "1", ")", ";", "int", "i", "=", "(", "int", ")", "p", ";", "p", "-=", "i", ";", "int", "c0", "=", "COLORS", "[", "i", "]", ";", "int", "c1", "=", "COLORS", "[", "i", "+", "1", "]", ";", "int", "a", "=", "ave", "(", "Color", ".", "alpha", "(", "c0", ")", ",", "Color", ".", "alpha", "(", "c1", ")", ",", "p", ")", ";", "int", "r", "=", "ave", "(", "Color", ".", "red", "(", "c0", ")", ",", "Color", ".", "red", "(", "c1", ")", ",", "p", ")", ";", "int", "g", "=", "ave", "(", "Color", ".", "green", "(", "c0", ")", ",", "Color", ".", "green", "(", "c1", ")", ",", "p", ")", ";", "int", "b", "=", "ave", "(", "Color", ".", "blue", "(", "c0", ")", ",", "Color", ".", "blue", "(", "c1", ")", ",", "p", ")", ";", "mColor", "=", "Color", ".", "argb", "(", "a", ",", "r", ",", "g", ",", "b", ")", ";", "return", "Color", ".", "argb", "(", "a", ",", "r", ",", "g", ",", "b", ")", ";", "}" ]
Calculate the color using the supplied angle. @param angle The selected color's position expressed as angle (in rad). @return The ARGB value of the color on the color wheel at the specified angle.
[ "Calculate", "the", "color", "using", "the", "supplied", "angle", "." ]
8ba5971f8d25f80c22d9711713a51c7a7c4ac4aa
https://github.com/LarsWerkman/HoloColorPicker/blob/8ba5971f8d25f80c22d9711713a51c7a7c4ac4aa/library/src/main/java/com/larswerkman/holocolorpicker/ColorPicker.java#L475-L503
162,240
LarsWerkman/HoloColorPicker
library/src/main/java/com/larswerkman/holocolorpicker/ColorPicker.java
ColorPicker.colorToAngle
private float colorToAngle(int color) { float[] colors = new float[3]; Color.colorToHSV(color, colors); return (float) Math.toRadians(-colors[0]); }
java
private float colorToAngle(int color) { float[] colors = new float[3]; Color.colorToHSV(color, colors); return (float) Math.toRadians(-colors[0]); }
[ "private", "float", "colorToAngle", "(", "int", "color", ")", "{", "float", "[", "]", "colors", "=", "new", "float", "[", "3", "]", ";", "Color", ".", "colorToHSV", "(", "color", ",", "colors", ")", ";", "return", "(", "float", ")", "Math", ".", "toRadians", "(", "-", "colors", "[", "0", "]", ")", ";", "}" ]
Convert a color to an angle. @param color The RGB value of the color to "find" on the color wheel. @return The angle (in rad) the "normalized" color is displayed on the color wheel.
[ "Convert", "a", "color", "to", "an", "angle", "." ]
8ba5971f8d25f80c22d9711713a51c7a7c4ac4aa
https://github.com/LarsWerkman/HoloColorPicker/blob/8ba5971f8d25f80c22d9711713a51c7a7c4ac4aa/library/src/main/java/com/larswerkman/holocolorpicker/ColorPicker.java#L577-L582
162,241
LarsWerkman/HoloColorPicker
library/src/main/java/com/larswerkman/holocolorpicker/ColorPicker.java
ColorPicker.calculatePointerPosition
private float[] calculatePointerPosition(float angle) { float x = (float) (mColorWheelRadius * Math.cos(angle)); float y = (float) (mColorWheelRadius * Math.sin(angle)); return new float[] { x, y }; }
java
private float[] calculatePointerPosition(float angle) { float x = (float) (mColorWheelRadius * Math.cos(angle)); float y = (float) (mColorWheelRadius * Math.sin(angle)); return new float[] { x, y }; }
[ "private", "float", "[", "]", "calculatePointerPosition", "(", "float", "angle", ")", "{", "float", "x", "=", "(", "float", ")", "(", "mColorWheelRadius", "*", "Math", ".", "cos", "(", "angle", ")", ")", ";", "float", "y", "=", "(", "float", ")", "(", "mColorWheelRadius", "*", "Math", ".", "sin", "(", "angle", ")", ")", ";", "return", "new", "float", "[", "]", "{", "x", ",", "y", "}", ";", "}" ]
Calculate the pointer's coordinates on the color wheel using the supplied angle. @param angle The position of the pointer expressed as angle (in rad). @return The coordinates of the pointer's center in our internal coordinate system.
[ "Calculate", "the", "pointer", "s", "coordinates", "on", "the", "color", "wheel", "using", "the", "supplied", "angle", "." ]
8ba5971f8d25f80c22d9711713a51c7a7c4ac4aa
https://github.com/LarsWerkman/HoloColorPicker/blob/8ba5971f8d25f80c22d9711713a51c7a7c4ac4aa/library/src/main/java/com/larswerkman/holocolorpicker/ColorPicker.java#L687-L692
162,242
LarsWerkman/HoloColorPicker
library/src/main/java/com/larswerkman/holocolorpicker/ColorPicker.java
ColorPicker.addOpacityBar
public void addOpacityBar(OpacityBar bar) { mOpacityBar = bar; // Give an instance of the color picker to the Opacity bar. mOpacityBar.setColorPicker(this); mOpacityBar.setColor(mColor); }
java
public void addOpacityBar(OpacityBar bar) { mOpacityBar = bar; // Give an instance of the color picker to the Opacity bar. mOpacityBar.setColorPicker(this); mOpacityBar.setColor(mColor); }
[ "public", "void", "addOpacityBar", "(", "OpacityBar", "bar", ")", "{", "mOpacityBar", "=", "bar", ";", "// Give an instance of the color picker to the Opacity bar.", "mOpacityBar", ".", "setColorPicker", "(", "this", ")", ";", "mOpacityBar", ".", "setColor", "(", "mColor", ")", ";", "}" ]
Add a Opacity bar to the color wheel. @param bar The instance of the Opacity bar.
[ "Add", "a", "Opacity", "bar", "to", "the", "color", "wheel", "." ]
8ba5971f8d25f80c22d9711713a51c7a7c4ac4aa
https://github.com/LarsWerkman/HoloColorPicker/blob/8ba5971f8d25f80c22d9711713a51c7a7c4ac4aa/library/src/main/java/com/larswerkman/holocolorpicker/ColorPicker.java#L711-L716
162,243
LarsWerkman/HoloColorPicker
library/src/main/java/com/larswerkman/holocolorpicker/ColorPicker.java
ColorPicker.setNewCenterColor
public void setNewCenterColor(int color) { mCenterNewColor = color; mCenterNewPaint.setColor(color); if (mCenterOldColor == 0) { mCenterOldColor = color; mCenterOldPaint.setColor(color); } if (onColorChangedListener != null && color != oldChangedListenerColor ) { onColorChangedListener.onColorChanged(color); oldChangedListenerColor = color; } invalidate(); }
java
public void setNewCenterColor(int color) { mCenterNewColor = color; mCenterNewPaint.setColor(color); if (mCenterOldColor == 0) { mCenterOldColor = color; mCenterOldPaint.setColor(color); } if (onColorChangedListener != null && color != oldChangedListenerColor ) { onColorChangedListener.onColorChanged(color); oldChangedListenerColor = color; } invalidate(); }
[ "public", "void", "setNewCenterColor", "(", "int", "color", ")", "{", "mCenterNewColor", "=", "color", ";", "mCenterNewPaint", ".", "setColor", "(", "color", ")", ";", "if", "(", "mCenterOldColor", "==", "0", ")", "{", "mCenterOldColor", "=", "color", ";", "mCenterOldPaint", ".", "setColor", "(", "color", ")", ";", "}", "if", "(", "onColorChangedListener", "!=", "null", "&&", "color", "!=", "oldChangedListenerColor", ")", "{", "onColorChangedListener", ".", "onColorChanged", "(", "color", ")", ";", "oldChangedListenerColor", "=", "color", ";", "}", "invalidate", "(", ")", ";", "}" ]
Change the color of the center which indicates the new color. @param color int of the color.
[ "Change", "the", "color", "of", "the", "center", "which", "indicates", "the", "new", "color", "." ]
8ba5971f8d25f80c22d9711713a51c7a7c4ac4aa
https://github.com/LarsWerkman/HoloColorPicker/blob/8ba5971f8d25f80c22d9711713a51c7a7c4ac4aa/library/src/main/java/com/larswerkman/holocolorpicker/ColorPicker.java#L735-L747
162,244
LarsWerkman/HoloColorPicker
library/src/main/java/com/larswerkman/holocolorpicker/SVBar.java
SVBar.setValue
public void setValue(float value) { mBarPointerPosition = Math.round((mSVToPosFactor * (1 - value)) + mBarPointerHaloRadius + (mBarLength / 2)); calculateColor(mBarPointerPosition); mBarPointerPaint.setColor(mColor); // Check whether the Saturation/Value bar is added to the ColorPicker // wheel if (mPicker != null) { mPicker.setNewCenterColor(mColor); mPicker.changeOpacityBarColor(mColor); } invalidate(); }
java
public void setValue(float value) { mBarPointerPosition = Math.round((mSVToPosFactor * (1 - value)) + mBarPointerHaloRadius + (mBarLength / 2)); calculateColor(mBarPointerPosition); mBarPointerPaint.setColor(mColor); // Check whether the Saturation/Value bar is added to the ColorPicker // wheel if (mPicker != null) { mPicker.setNewCenterColor(mColor); mPicker.changeOpacityBarColor(mColor); } invalidate(); }
[ "public", "void", "setValue", "(", "float", "value", ")", "{", "mBarPointerPosition", "=", "Math", ".", "round", "(", "(", "mSVToPosFactor", "*", "(", "1", "-", "value", ")", ")", "+", "mBarPointerHaloRadius", "+", "(", "mBarLength", "/", "2", ")", ")", ";", "calculateColor", "(", "mBarPointerPosition", ")", ";", "mBarPointerPaint", ".", "setColor", "(", "mColor", ")", ";", "// Check whether the Saturation/Value bar is added to the ColorPicker", "// wheel", "if", "(", "mPicker", "!=", "null", ")", "{", "mPicker", ".", "setNewCenterColor", "(", "mColor", ")", ";", "mPicker", ".", "changeOpacityBarColor", "(", "mColor", ")", ";", "}", "invalidate", "(", ")", ";", "}" ]
Set the pointer on the bar. With the Value value. @param value float between 0 and 1
[ "Set", "the", "pointer", "on", "the", "bar", ".", "With", "the", "Value", "value", "." ]
8ba5971f8d25f80c22d9711713a51c7a7c4ac4aa
https://github.com/LarsWerkman/HoloColorPicker/blob/8ba5971f8d25f80c22d9711713a51c7a7c4ac4aa/library/src/main/java/com/larswerkman/holocolorpicker/SVBar.java#L409-L421
162,245
mikepenz/Materialize
library/src/main/java/com/mikepenz/materialize/util/UIUtils.java
UIUtils.getNavigationBarHeight
public static int getNavigationBarHeight(Context context) { Resources resources = context.getResources(); int id = resources.getIdentifier(context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT ? "navigation_bar_height" : "navigation_bar_height_landscape", "dimen", "android"); if (id > 0) { return resources.getDimensionPixelSize(id); } return 0; }
java
public static int getNavigationBarHeight(Context context) { Resources resources = context.getResources(); int id = resources.getIdentifier(context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT ? "navigation_bar_height" : "navigation_bar_height_landscape", "dimen", "android"); if (id > 0) { return resources.getDimensionPixelSize(id); } return 0; }
[ "public", "static", "int", "getNavigationBarHeight", "(", "Context", "context", ")", "{", "Resources", "resources", "=", "context", ".", "getResources", "(", ")", ";", "int", "id", "=", "resources", ".", "getIdentifier", "(", "context", ".", "getResources", "(", ")", ".", "getConfiguration", "(", ")", ".", "orientation", "==", "Configuration", ".", "ORIENTATION_PORTRAIT", "?", "\"navigation_bar_height\"", ":", "\"navigation_bar_height_landscape\"", ",", "\"dimen\"", ",", "\"android\"", ")", ";", "if", "(", "id", ">", "0", ")", "{", "return", "resources", ".", "getDimensionPixelSize", "(", "id", ")", ";", "}", "return", "0", ";", "}" ]
helper to calculate the navigationBar height @param context @return
[ "helper", "to", "calculate", "the", "navigationBar", "height" ]
2612c10c7570191a78d57f23620e945d61370e3d
https://github.com/mikepenz/Materialize/blob/2612c10c7570191a78d57f23620e945d61370e3d/library/src/main/java/com/mikepenz/materialize/util/UIUtils.java#L110-L117
162,246
mikepenz/Materialize
library/src/main/java/com/mikepenz/materialize/util/UIUtils.java
UIUtils.getActionBarHeight
public static int getActionBarHeight(Context context) { int actionBarHeight = UIUtils.getThemeAttributeDimensionSize(context, R.attr.actionBarSize); if (actionBarHeight == 0) { actionBarHeight = context.getResources().getDimensionPixelSize(R.dimen.abc_action_bar_default_height_material); } return actionBarHeight; }
java
public static int getActionBarHeight(Context context) { int actionBarHeight = UIUtils.getThemeAttributeDimensionSize(context, R.attr.actionBarSize); if (actionBarHeight == 0) { actionBarHeight = context.getResources().getDimensionPixelSize(R.dimen.abc_action_bar_default_height_material); } return actionBarHeight; }
[ "public", "static", "int", "getActionBarHeight", "(", "Context", "context", ")", "{", "int", "actionBarHeight", "=", "UIUtils", ".", "getThemeAttributeDimensionSize", "(", "context", ",", "R", ".", "attr", ".", "actionBarSize", ")", ";", "if", "(", "actionBarHeight", "==", "0", ")", "{", "actionBarHeight", "=", "context", ".", "getResources", "(", ")", ".", "getDimensionPixelSize", "(", "R", ".", "dimen", ".", "abc_action_bar_default_height_material", ")", ";", "}", "return", "actionBarHeight", ";", "}" ]
helper to calculate the actionBar height @param context @return
[ "helper", "to", "calculate", "the", "actionBar", "height" ]
2612c10c7570191a78d57f23620e945d61370e3d
https://github.com/mikepenz/Materialize/blob/2612c10c7570191a78d57f23620e945d61370e3d/library/src/main/java/com/mikepenz/materialize/util/UIUtils.java#L125-L131
162,247
mikepenz/Materialize
library/src/main/java/com/mikepenz/materialize/util/UIUtils.java
UIUtils.getStatusBarHeight
public static int getStatusBarHeight(Context context, boolean force) { int result = 0; int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android"); if (resourceId > 0) { result = context.getResources().getDimensionPixelSize(resourceId); } int dimenResult = context.getResources().getDimensionPixelSize(R.dimen.tool_bar_top_padding); //if our dimension is 0 return 0 because on those devices we don't need the height if (dimenResult == 0 && !force) { return 0; } else { //if our dimens is > 0 && the result == 0 use the dimenResult else the result; return result == 0 ? dimenResult : result; } }
java
public static int getStatusBarHeight(Context context, boolean force) { int result = 0; int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android"); if (resourceId > 0) { result = context.getResources().getDimensionPixelSize(resourceId); } int dimenResult = context.getResources().getDimensionPixelSize(R.dimen.tool_bar_top_padding); //if our dimension is 0 return 0 because on those devices we don't need the height if (dimenResult == 0 && !force) { return 0; } else { //if our dimens is > 0 && the result == 0 use the dimenResult else the result; return result == 0 ? dimenResult : result; } }
[ "public", "static", "int", "getStatusBarHeight", "(", "Context", "context", ",", "boolean", "force", ")", "{", "int", "result", "=", "0", ";", "int", "resourceId", "=", "context", ".", "getResources", "(", ")", ".", "getIdentifier", "(", "\"status_bar_height\"", ",", "\"dimen\"", ",", "\"android\"", ")", ";", "if", "(", "resourceId", ">", "0", ")", "{", "result", "=", "context", ".", "getResources", "(", ")", ".", "getDimensionPixelSize", "(", "resourceId", ")", ";", "}", "int", "dimenResult", "=", "context", ".", "getResources", "(", ")", ".", "getDimensionPixelSize", "(", "R", ".", "dimen", ".", "tool_bar_top_padding", ")", ";", "//if our dimension is 0 return 0 because on those devices we don't need the height", "if", "(", "dimenResult", "==", "0", "&&", "!", "force", ")", "{", "return", "0", ";", "}", "else", "{", "//if our dimens is > 0 && the result == 0 use the dimenResult else the result;", "return", "result", "==", "0", "?", "dimenResult", ":", "result", ";", "}", "}" ]
helper to calculate the statusBar height @param context @param force pass true to get the height even if the device has no translucent statusBar @return
[ "helper", "to", "calculate", "the", "statusBar", "height" ]
2612c10c7570191a78d57f23620e945d61370e3d
https://github.com/mikepenz/Materialize/blob/2612c10c7570191a78d57f23620e945d61370e3d/library/src/main/java/com/mikepenz/materialize/util/UIUtils.java#L150-L165
162,248
mikepenz/Materialize
library/src/main/java/com/mikepenz/materialize/util/UIUtils.java
UIUtils.setTranslucentStatusFlag
public static void setTranslucentStatusFlag(Activity activity, boolean on) { if (Build.VERSION.SDK_INT >= 19) { setFlag(activity, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, on); } }
java
public static void setTranslucentStatusFlag(Activity activity, boolean on) { if (Build.VERSION.SDK_INT >= 19) { setFlag(activity, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, on); } }
[ "public", "static", "void", "setTranslucentStatusFlag", "(", "Activity", "activity", ",", "boolean", "on", ")", "{", "if", "(", "Build", ".", "VERSION", ".", "SDK_INT", ">=", "19", ")", "{", "setFlag", "(", "activity", ",", "WindowManager", ".", "LayoutParams", ".", "FLAG_TRANSLUCENT_STATUS", ",", "on", ")", ";", "}", "}" ]
helper method to set the TranslucentStatusFlag @param on
[ "helper", "method", "to", "set", "the", "TranslucentStatusFlag" ]
2612c10c7570191a78d57f23620e945d61370e3d
https://github.com/mikepenz/Materialize/blob/2612c10c7570191a78d57f23620e945d61370e3d/library/src/main/java/com/mikepenz/materialize/util/UIUtils.java#L200-L204
162,249
mikepenz/Materialize
library/src/main/java/com/mikepenz/materialize/util/UIUtils.java
UIUtils.setTranslucentNavigationFlag
public static void setTranslucentNavigationFlag(Activity activity, boolean on) { if (Build.VERSION.SDK_INT >= 19) { setFlag(activity, WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, on); } }
java
public static void setTranslucentNavigationFlag(Activity activity, boolean on) { if (Build.VERSION.SDK_INT >= 19) { setFlag(activity, WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, on); } }
[ "public", "static", "void", "setTranslucentNavigationFlag", "(", "Activity", "activity", ",", "boolean", "on", ")", "{", "if", "(", "Build", ".", "VERSION", ".", "SDK_INT", ">=", "19", ")", "{", "setFlag", "(", "activity", ",", "WindowManager", ".", "LayoutParams", ".", "FLAG_TRANSLUCENT_NAVIGATION", ",", "on", ")", ";", "}", "}" ]
helper method to set the TranslucentNavigationFlag @param on
[ "helper", "method", "to", "set", "the", "TranslucentNavigationFlag" ]
2612c10c7570191a78d57f23620e945d61370e3d
https://github.com/mikepenz/Materialize/blob/2612c10c7570191a78d57f23620e945d61370e3d/library/src/main/java/com/mikepenz/materialize/util/UIUtils.java#L211-L215
162,250
mikepenz/Materialize
library/src/main/java/com/mikepenz/materialize/util/UIUtils.java
UIUtils.setFlag
public static void setFlag(Activity activity, final int bits, boolean on) { Window win = activity.getWindow(); WindowManager.LayoutParams winParams = win.getAttributes(); if (on) { winParams.flags |= bits; } else { winParams.flags &= ~bits; } win.setAttributes(winParams); }
java
public static void setFlag(Activity activity, final int bits, boolean on) { Window win = activity.getWindow(); WindowManager.LayoutParams winParams = win.getAttributes(); if (on) { winParams.flags |= bits; } else { winParams.flags &= ~bits; } win.setAttributes(winParams); }
[ "public", "static", "void", "setFlag", "(", "Activity", "activity", ",", "final", "int", "bits", ",", "boolean", "on", ")", "{", "Window", "win", "=", "activity", ".", "getWindow", "(", ")", ";", "WindowManager", ".", "LayoutParams", "winParams", "=", "win", ".", "getAttributes", "(", ")", ";", "if", "(", "on", ")", "{", "winParams", ".", "flags", "|=", "bits", ";", "}", "else", "{", "winParams", ".", "flags", "&=", "~", "bits", ";", "}", "win", ".", "setAttributes", "(", "winParams", ")", ";", "}" ]
helper method to activate or deactivate a specific flag @param bits @param on
[ "helper", "method", "to", "activate", "or", "deactivate", "a", "specific", "flag" ]
2612c10c7570191a78d57f23620e945d61370e3d
https://github.com/mikepenz/Materialize/blob/2612c10c7570191a78d57f23620e945d61370e3d/library/src/main/java/com/mikepenz/materialize/util/UIUtils.java#L223-L232
162,251
mikepenz/Materialize
library/src/main/java/com/mikepenz/materialize/util/UIUtils.java
UIUtils.getScreenWidth
public static int getScreenWidth(Context context) { DisplayMetrics metrics = context.getResources().getDisplayMetrics(); return metrics.widthPixels; }
java
public static int getScreenWidth(Context context) { DisplayMetrics metrics = context.getResources().getDisplayMetrics(); return metrics.widthPixels; }
[ "public", "static", "int", "getScreenWidth", "(", "Context", "context", ")", "{", "DisplayMetrics", "metrics", "=", "context", ".", "getResources", "(", ")", ".", "getDisplayMetrics", "(", ")", ";", "return", "metrics", ".", "widthPixels", ";", "}" ]
Returns the screen width in pixels @param context is the context to get the resources @return the screen width in pixels
[ "Returns", "the", "screen", "width", "in", "pixels" ]
2612c10c7570191a78d57f23620e945d61370e3d
https://github.com/mikepenz/Materialize/blob/2612c10c7570191a78d57f23620e945d61370e3d/library/src/main/java/com/mikepenz/materialize/util/UIUtils.java#L334-L337
162,252
mikepenz/Materialize
library/src/main/java/com/mikepenz/materialize/util/UIUtils.java
UIUtils.getScreenHeight
public static int getScreenHeight(Context context) { DisplayMetrics metrics = context.getResources().getDisplayMetrics(); return metrics.heightPixels; }
java
public static int getScreenHeight(Context context) { DisplayMetrics metrics = context.getResources().getDisplayMetrics(); return metrics.heightPixels; }
[ "public", "static", "int", "getScreenHeight", "(", "Context", "context", ")", "{", "DisplayMetrics", "metrics", "=", "context", ".", "getResources", "(", ")", ".", "getDisplayMetrics", "(", ")", ";", "return", "metrics", ".", "heightPixels", ";", "}" ]
Returns the screen height in pixels @param context is the context to get the resources @return the screen height in pixels
[ "Returns", "the", "screen", "height", "in", "pixels" ]
2612c10c7570191a78d57f23620e945d61370e3d
https://github.com/mikepenz/Materialize/blob/2612c10c7570191a78d57f23620e945d61370e3d/library/src/main/java/com/mikepenz/materialize/util/UIUtils.java#L346-L349
162,253
mikepenz/Materialize
library/src/main/java/com/mikepenz/materialize/MaterializeBuilder.java
MaterializeBuilder.withActivity
public MaterializeBuilder withActivity(Activity activity) { this.mRootView = (ViewGroup) activity.findViewById(android.R.id.content); this.mActivity = activity; return this; }
java
public MaterializeBuilder withActivity(Activity activity) { this.mRootView = (ViewGroup) activity.findViewById(android.R.id.content); this.mActivity = activity; return this; }
[ "public", "MaterializeBuilder", "withActivity", "(", "Activity", "activity", ")", "{", "this", ".", "mRootView", "=", "(", "ViewGroup", ")", "activity", ".", "findViewById", "(", "android", ".", "R", ".", "id", ".", "content", ")", ";", "this", ".", "mActivity", "=", "activity", ";", "return", "this", ";", "}" ]
Pass the activity you use the drawer in ;) This is required if you want to set any values by resource @param activity @return
[ "Pass", "the", "activity", "you", "use", "the", "drawer", "in", ";", ")", "This", "is", "required", "if", "you", "want", "to", "set", "any", "values", "by", "resource" ]
2612c10c7570191a78d57f23620e945d61370e3d
https://github.com/mikepenz/Materialize/blob/2612c10c7570191a78d57f23620e945d61370e3d/library/src/main/java/com/mikepenz/materialize/MaterializeBuilder.java#L53-L57
162,254
mikepenz/Materialize
library/src/main/java/com/mikepenz/materialize/MaterializeBuilder.java
MaterializeBuilder.withContainer
public MaterializeBuilder withContainer(ViewGroup container, ViewGroup.LayoutParams layoutParams) { this.mContainer = container; this.mContainerLayoutParams = layoutParams; return this; }
java
public MaterializeBuilder withContainer(ViewGroup container, ViewGroup.LayoutParams layoutParams) { this.mContainer = container; this.mContainerLayoutParams = layoutParams; return this; }
[ "public", "MaterializeBuilder", "withContainer", "(", "ViewGroup", "container", ",", "ViewGroup", ".", "LayoutParams", "layoutParams", ")", "{", "this", ".", "mContainer", "=", "container", ";", "this", ".", "mContainerLayoutParams", "=", "layoutParams", ";", "return", "this", ";", "}" ]
set the layout which will host the ScrimInsetsFrameLayout and its layoutParams @param container @param layoutParams @return
[ "set", "the", "layout", "which", "will", "host", "the", "ScrimInsetsFrameLayout", "and", "its", "layoutParams" ]
2612c10c7570191a78d57f23620e945d61370e3d
https://github.com/mikepenz/Materialize/blob/2612c10c7570191a78d57f23620e945d61370e3d/library/src/main/java/com/mikepenz/materialize/MaterializeBuilder.java#L314-L318
162,255
mikepenz/Materialize
library/src/main/java/com/mikepenz/materialize/Materialize.java
Materialize.setFullscreen
public void setFullscreen(boolean fullscreen) { if (mBuilder.mScrimInsetsLayout != null) { mBuilder.mScrimInsetsLayout.setTintStatusBar(!fullscreen); mBuilder.mScrimInsetsLayout.setTintNavigationBar(!fullscreen); } }
java
public void setFullscreen(boolean fullscreen) { if (mBuilder.mScrimInsetsLayout != null) { mBuilder.mScrimInsetsLayout.setTintStatusBar(!fullscreen); mBuilder.mScrimInsetsLayout.setTintNavigationBar(!fullscreen); } }
[ "public", "void", "setFullscreen", "(", "boolean", "fullscreen", ")", "{", "if", "(", "mBuilder", ".", "mScrimInsetsLayout", "!=", "null", ")", "{", "mBuilder", ".", "mScrimInsetsLayout", ".", "setTintStatusBar", "(", "!", "fullscreen", ")", ";", "mBuilder", ".", "mScrimInsetsLayout", ".", "setTintNavigationBar", "(", "!", "fullscreen", ")", ";", "}", "}" ]
set the insetsFrameLayout to display the content in fullscreen under the statusBar and navigationBar @param fullscreen
[ "set", "the", "insetsFrameLayout", "to", "display", "the", "content", "in", "fullscreen", "under", "the", "statusBar", "and", "navigationBar" ]
2612c10c7570191a78d57f23620e945d61370e3d
https://github.com/mikepenz/Materialize/blob/2612c10c7570191a78d57f23620e945d61370e3d/library/src/main/java/com/mikepenz/materialize/Materialize.java#L31-L36
162,256
mikepenz/Materialize
library/src/main/java/com/mikepenz/materialize/Materialize.java
Materialize.setStatusBarColor
public void setStatusBarColor(int statusBarColor) { if (mBuilder.mScrimInsetsLayout != null) { mBuilder.mScrimInsetsLayout.setInsetForeground(statusBarColor); mBuilder.mScrimInsetsLayout.getView().invalidate(); } }
java
public void setStatusBarColor(int statusBarColor) { if (mBuilder.mScrimInsetsLayout != null) { mBuilder.mScrimInsetsLayout.setInsetForeground(statusBarColor); mBuilder.mScrimInsetsLayout.getView().invalidate(); } }
[ "public", "void", "setStatusBarColor", "(", "int", "statusBarColor", ")", "{", "if", "(", "mBuilder", ".", "mScrimInsetsLayout", "!=", "null", ")", "{", "mBuilder", ".", "mScrimInsetsLayout", ".", "setInsetForeground", "(", "statusBarColor", ")", ";", "mBuilder", ".", "mScrimInsetsLayout", ".", "getView", "(", ")", ".", "invalidate", "(", ")", ";", "}", "}" ]
Set the color for the statusBar @param statusBarColor
[ "Set", "the", "color", "for", "the", "statusBar" ]
2612c10c7570191a78d57f23620e945d61370e3d
https://github.com/mikepenz/Materialize/blob/2612c10c7570191a78d57f23620e945d61370e3d/library/src/main/java/com/mikepenz/materialize/Materialize.java#L65-L70
162,257
mikepenz/Materialize
library/src/main/java/com/mikepenz/materialize/Materialize.java
Materialize.keyboardSupportEnabled
public void keyboardSupportEnabled(Activity activity, boolean enable) { if (getContent() != null && getContent().getChildCount() > 0) { if (mKeyboardUtil == null) { mKeyboardUtil = new KeyboardUtil(activity, getContent().getChildAt(0)); mKeyboardUtil.disable(); } if (enable) { mKeyboardUtil.enable(); } else { mKeyboardUtil.disable(); } } }
java
public void keyboardSupportEnabled(Activity activity, boolean enable) { if (getContent() != null && getContent().getChildCount() > 0) { if (mKeyboardUtil == null) { mKeyboardUtil = new KeyboardUtil(activity, getContent().getChildAt(0)); mKeyboardUtil.disable(); } if (enable) { mKeyboardUtil.enable(); } else { mKeyboardUtil.disable(); } } }
[ "public", "void", "keyboardSupportEnabled", "(", "Activity", "activity", ",", "boolean", "enable", ")", "{", "if", "(", "getContent", "(", ")", "!=", "null", "&&", "getContent", "(", ")", ".", "getChildCount", "(", ")", ">", "0", ")", "{", "if", "(", "mKeyboardUtil", "==", "null", ")", "{", "mKeyboardUtil", "=", "new", "KeyboardUtil", "(", "activity", ",", "getContent", "(", ")", ".", "getChildAt", "(", "0", ")", ")", ";", "mKeyboardUtil", ".", "disable", "(", ")", ";", "}", "if", "(", "enable", ")", "{", "mKeyboardUtil", ".", "enable", "(", ")", ";", "}", "else", "{", "mKeyboardUtil", ".", "disable", "(", ")", ";", "}", "}", "}" ]
a helper method to enable the keyboardUtil for a specific activity or disable it. note this will cause some frame drops because of the listener. @param activity @param enable
[ "a", "helper", "method", "to", "enable", "the", "keyboardUtil", "for", "a", "specific", "activity", "or", "disable", "it", ".", "note", "this", "will", "cause", "some", "frame", "drops", "because", "of", "the", "listener", "." ]
2612c10c7570191a78d57f23620e945d61370e3d
https://github.com/mikepenz/Materialize/blob/2612c10c7570191a78d57f23620e945d61370e3d/library/src/main/java/com/mikepenz/materialize/Materialize.java#L99-L112
162,258
mikepenz/Materialize
library/src/main/java/com/mikepenz/materialize/holder/ColorHolder.java
ColorHolder.applyTo
public void applyTo(Context ctx, GradientDrawable drawable) { if (mColorInt != 0) { drawable.setColor(mColorInt); } else if (mColorRes != -1) { drawable.setColor(ContextCompat.getColor(ctx, mColorRes)); } }
java
public void applyTo(Context ctx, GradientDrawable drawable) { if (mColorInt != 0) { drawable.setColor(mColorInt); } else if (mColorRes != -1) { drawable.setColor(ContextCompat.getColor(ctx, mColorRes)); } }
[ "public", "void", "applyTo", "(", "Context", "ctx", ",", "GradientDrawable", "drawable", ")", "{", "if", "(", "mColorInt", "!=", "0", ")", "{", "drawable", ".", "setColor", "(", "mColorInt", ")", ";", "}", "else", "if", "(", "mColorRes", "!=", "-", "1", ")", "{", "drawable", ".", "setColor", "(", "ContextCompat", ".", "getColor", "(", "ctx", ",", "mColorRes", ")", ")", ";", "}", "}" ]
set the textColor of the ColorHolder to an drawable @param ctx @param drawable
[ "set", "the", "textColor", "of", "the", "ColorHolder", "to", "an", "drawable" ]
2612c10c7570191a78d57f23620e945d61370e3d
https://github.com/mikepenz/Materialize/blob/2612c10c7570191a78d57f23620e945d61370e3d/library/src/main/java/com/mikepenz/materialize/holder/ColorHolder.java#L61-L67
162,259
mikepenz/Materialize
library/src/main/java/com/mikepenz/materialize/holder/ColorHolder.java
ColorHolder.applyToBackground
public void applyToBackground(View view) { if (mColorInt != 0) { view.setBackgroundColor(mColorInt); } else if (mColorRes != -1) { view.setBackgroundResource(mColorRes); } }
java
public void applyToBackground(View view) { if (mColorInt != 0) { view.setBackgroundColor(mColorInt); } else if (mColorRes != -1) { view.setBackgroundResource(mColorRes); } }
[ "public", "void", "applyToBackground", "(", "View", "view", ")", "{", "if", "(", "mColorInt", "!=", "0", ")", "{", "view", ".", "setBackgroundColor", "(", "mColorInt", ")", ";", "}", "else", "if", "(", "mColorRes", "!=", "-", "1", ")", "{", "view", ".", "setBackgroundResource", "(", "mColorRes", ")", ";", "}", "}" ]
set the textColor of the ColorHolder to a view @param view
[ "set", "the", "textColor", "of", "the", "ColorHolder", "to", "a", "view" ]
2612c10c7570191a78d57f23620e945d61370e3d
https://github.com/mikepenz/Materialize/blob/2612c10c7570191a78d57f23620e945d61370e3d/library/src/main/java/com/mikepenz/materialize/holder/ColorHolder.java#L75-L81
162,260
mikepenz/Materialize
library/src/main/java/com/mikepenz/materialize/holder/ColorHolder.java
ColorHolder.applyToOr
public void applyToOr(TextView textView, ColorStateList colorDefault) { if (mColorInt != 0) { textView.setTextColor(mColorInt); } else if (mColorRes != -1) { textView.setTextColor(ContextCompat.getColor(textView.getContext(), mColorRes)); } else if (colorDefault != null) { textView.setTextColor(colorDefault); } }
java
public void applyToOr(TextView textView, ColorStateList colorDefault) { if (mColorInt != 0) { textView.setTextColor(mColorInt); } else if (mColorRes != -1) { textView.setTextColor(ContextCompat.getColor(textView.getContext(), mColorRes)); } else if (colorDefault != null) { textView.setTextColor(colorDefault); } }
[ "public", "void", "applyToOr", "(", "TextView", "textView", ",", "ColorStateList", "colorDefault", ")", "{", "if", "(", "mColorInt", "!=", "0", ")", "{", "textView", ".", "setTextColor", "(", "mColorInt", ")", ";", "}", "else", "if", "(", "mColorRes", "!=", "-", "1", ")", "{", "textView", ".", "setTextColor", "(", "ContextCompat", ".", "getColor", "(", "textView", ".", "getContext", "(", ")", ",", "mColorRes", ")", ")", ";", "}", "else", "if", "(", "colorDefault", "!=", "null", ")", "{", "textView", ".", "setTextColor", "(", "colorDefault", ")", ";", "}", "}" ]
a small helper to set the text color to a textView null save @param textView @param colorDefault
[ "a", "small", "helper", "to", "set", "the", "text", "color", "to", "a", "textView", "null", "save" ]
2612c10c7570191a78d57f23620e945d61370e3d
https://github.com/mikepenz/Materialize/blob/2612c10c7570191a78d57f23620e945d61370e3d/library/src/main/java/com/mikepenz/materialize/holder/ColorHolder.java#L89-L97
162,261
mikepenz/Materialize
library/src/main/java/com/mikepenz/materialize/holder/ColorHolder.java
ColorHolder.color
public int color(Context ctx) { if (mColorInt == 0 && mColorRes != -1) { mColorInt = ContextCompat.getColor(ctx, mColorRes); } return mColorInt; }
java
public int color(Context ctx) { if (mColorInt == 0 && mColorRes != -1) { mColorInt = ContextCompat.getColor(ctx, mColorRes); } return mColorInt; }
[ "public", "int", "color", "(", "Context", "ctx", ")", "{", "if", "(", "mColorInt", "==", "0", "&&", "mColorRes", "!=", "-", "1", ")", "{", "mColorInt", "=", "ContextCompat", ".", "getColor", "(", "ctx", ",", "mColorRes", ")", ";", "}", "return", "mColorInt", ";", "}" ]
a small helper to get the color from the colorHolder @param ctx @return
[ "a", "small", "helper", "to", "get", "the", "color", "from", "the", "colorHolder" ]
2612c10c7570191a78d57f23620e945d61370e3d
https://github.com/mikepenz/Materialize/blob/2612c10c7570191a78d57f23620e945d61370e3d/library/src/main/java/com/mikepenz/materialize/holder/ColorHolder.java#L123-L128
162,262
mikepenz/Materialize
library/src/main/java/com/mikepenz/materialize/holder/ColorHolder.java
ColorHolder.color
public static int color(ColorHolder colorHolder, Context ctx) { if (colorHolder == null) { return 0; } else { return colorHolder.color(ctx); } }
java
public static int color(ColorHolder colorHolder, Context ctx) { if (colorHolder == null) { return 0; } else { return colorHolder.color(ctx); } }
[ "public", "static", "int", "color", "(", "ColorHolder", "colorHolder", ",", "Context", "ctx", ")", "{", "if", "(", "colorHolder", "==", "null", ")", "{", "return", "0", ";", "}", "else", "{", "return", "colorHolder", ".", "color", "(", "ctx", ")", ";", "}", "}" ]
a small static helper class to get the color from the colorHolder @param colorHolder @param ctx @return
[ "a", "small", "static", "helper", "class", "to", "get", "the", "color", "from", "the", "colorHolder" ]
2612c10c7570191a78d57f23620e945d61370e3d
https://github.com/mikepenz/Materialize/blob/2612c10c7570191a78d57f23620e945d61370e3d/library/src/main/java/com/mikepenz/materialize/holder/ColorHolder.java#L154-L160
162,263
mikepenz/Materialize
library/src/main/java/com/mikepenz/materialize/holder/ColorHolder.java
ColorHolder.applyToOr
public static void applyToOr(ColorHolder colorHolder, TextView textView, ColorStateList colorDefault) { if (colorHolder != null && textView != null) { colorHolder.applyToOr(textView, colorDefault); } else if (textView != null) { textView.setTextColor(colorDefault); } }
java
public static void applyToOr(ColorHolder colorHolder, TextView textView, ColorStateList colorDefault) { if (colorHolder != null && textView != null) { colorHolder.applyToOr(textView, colorDefault); } else if (textView != null) { textView.setTextColor(colorDefault); } }
[ "public", "static", "void", "applyToOr", "(", "ColorHolder", "colorHolder", ",", "TextView", "textView", ",", "ColorStateList", "colorDefault", ")", "{", "if", "(", "colorHolder", "!=", "null", "&&", "textView", "!=", "null", ")", "{", "colorHolder", ".", "applyToOr", "(", "textView", ",", "colorDefault", ")", ";", "}", "else", "if", "(", "textView", "!=", "null", ")", "{", "textView", ".", "setTextColor", "(", "colorDefault", ")", ";", "}", "}" ]
a small static helper to set the text color to a textView null save @param colorHolder @param textView @param colorDefault
[ "a", "small", "static", "helper", "to", "set", "the", "text", "color", "to", "a", "textView", "null", "save" ]
2612c10c7570191a78d57f23620e945d61370e3d
https://github.com/mikepenz/Materialize/blob/2612c10c7570191a78d57f23620e945d61370e3d/library/src/main/java/com/mikepenz/materialize/holder/ColorHolder.java#L169-L175
162,264
mikepenz/Materialize
library/src/main/java/com/mikepenz/materialize/holder/ColorHolder.java
ColorHolder.applyToOrTransparent
public static void applyToOrTransparent(ColorHolder colorHolder, Context ctx, GradientDrawable gradientDrawable) { if (colorHolder != null && gradientDrawable != null) { colorHolder.applyTo(ctx, gradientDrawable); } else if (gradientDrawable != null) { gradientDrawable.setColor(Color.TRANSPARENT); } }
java
public static void applyToOrTransparent(ColorHolder colorHolder, Context ctx, GradientDrawable gradientDrawable) { if (colorHolder != null && gradientDrawable != null) { colorHolder.applyTo(ctx, gradientDrawable); } else if (gradientDrawable != null) { gradientDrawable.setColor(Color.TRANSPARENT); } }
[ "public", "static", "void", "applyToOrTransparent", "(", "ColorHolder", "colorHolder", ",", "Context", "ctx", ",", "GradientDrawable", "gradientDrawable", ")", "{", "if", "(", "colorHolder", "!=", "null", "&&", "gradientDrawable", "!=", "null", ")", "{", "colorHolder", ".", "applyTo", "(", "ctx", ",", "gradientDrawable", ")", ";", "}", "else", "if", "(", "gradientDrawable", "!=", "null", ")", "{", "gradientDrawable", ".", "setColor", "(", "Color", ".", "TRANSPARENT", ")", ";", "}", "}" ]
a small static helper to set the color to a GradientDrawable null save @param colorHolder @param ctx @param gradientDrawable
[ "a", "small", "static", "helper", "to", "set", "the", "color", "to", "a", "GradientDrawable", "null", "save" ]
2612c10c7570191a78d57f23620e945d61370e3d
https://github.com/mikepenz/Materialize/blob/2612c10c7570191a78d57f23620e945d61370e3d/library/src/main/java/com/mikepenz/materialize/holder/ColorHolder.java#L184-L190
162,265
mikepenz/Materialize
library/src/main/java/com/mikepenz/materialize/holder/ImageHolder.java
ImageHolder.applyTo
public static boolean applyTo(ImageHolder imageHolder, ImageView imageView, String tag) { if (imageHolder != null && imageView != null) { return imageHolder.applyTo(imageView, tag); } return false; }
java
public static boolean applyTo(ImageHolder imageHolder, ImageView imageView, String tag) { if (imageHolder != null && imageView != null) { return imageHolder.applyTo(imageView, tag); } return false; }
[ "public", "static", "boolean", "applyTo", "(", "ImageHolder", "imageHolder", ",", "ImageView", "imageView", ",", "String", "tag", ")", "{", "if", "(", "imageHolder", "!=", "null", "&&", "imageView", "!=", "null", ")", "{", "return", "imageHolder", ".", "applyTo", "(", "imageView", ",", "tag", ")", ";", "}", "return", "false", ";", "}" ]
a small static helper to set the image from the imageHolder nullSave to the imageView @param imageHolder @param imageView @param tag used to identify imageViews and define different placeholders @return true if an image was set
[ "a", "small", "static", "helper", "to", "set", "the", "image", "from", "the", "imageHolder", "nullSave", "to", "the", "imageView" ]
2612c10c7570191a78d57f23620e945d61370e3d
https://github.com/mikepenz/Materialize/blob/2612c10c7570191a78d57f23620e945d61370e3d/library/src/main/java/com/mikepenz/materialize/holder/ImageHolder.java#L170-L175
162,266
mikepenz/Materialize
library/src/main/java/com/mikepenz/materialize/holder/ImageHolder.java
ImageHolder.decideIcon
public static Drawable decideIcon(ImageHolder imageHolder, Context ctx, int iconColor, boolean tint) { if (imageHolder == null) { return null; } else { return imageHolder.decideIcon(ctx, iconColor, tint); } }
java
public static Drawable decideIcon(ImageHolder imageHolder, Context ctx, int iconColor, boolean tint) { if (imageHolder == null) { return null; } else { return imageHolder.decideIcon(ctx, iconColor, tint); } }
[ "public", "static", "Drawable", "decideIcon", "(", "ImageHolder", "imageHolder", ",", "Context", "ctx", ",", "int", "iconColor", ",", "boolean", "tint", ")", "{", "if", "(", "imageHolder", "==", "null", ")", "{", "return", "null", ";", "}", "else", "{", "return", "imageHolder", ".", "decideIcon", "(", "ctx", ",", "iconColor", ",", "tint", ")", ";", "}", "}" ]
a small static helper which catches nulls for us @param imageHolder @param ctx @param iconColor @param tint @return
[ "a", "small", "static", "helper", "which", "catches", "nulls", "for", "us" ]
2612c10c7570191a78d57f23620e945d61370e3d
https://github.com/mikepenz/Materialize/blob/2612c10c7570191a78d57f23620e945d61370e3d/library/src/main/java/com/mikepenz/materialize/holder/ImageHolder.java#L243-L249
162,267
mikepenz/Materialize
library/src/main/java/com/mikepenz/materialize/holder/ImageHolder.java
ImageHolder.applyDecidedIconOrSetGone
public static void applyDecidedIconOrSetGone(ImageHolder imageHolder, ImageView imageView, int iconColor, boolean tint) { if (imageHolder != null && imageView != null) { Drawable drawable = ImageHolder.decideIcon(imageHolder, imageView.getContext(), iconColor, tint); if (drawable != null) { imageView.setImageDrawable(drawable); imageView.setVisibility(View.VISIBLE); } else if (imageHolder.getBitmap() != null) { imageView.setImageBitmap(imageHolder.getBitmap()); imageView.setVisibility(View.VISIBLE); } else { imageView.setVisibility(View.GONE); } } else if (imageView != null) { imageView.setVisibility(View.GONE); } }
java
public static void applyDecidedIconOrSetGone(ImageHolder imageHolder, ImageView imageView, int iconColor, boolean tint) { if (imageHolder != null && imageView != null) { Drawable drawable = ImageHolder.decideIcon(imageHolder, imageView.getContext(), iconColor, tint); if (drawable != null) { imageView.setImageDrawable(drawable); imageView.setVisibility(View.VISIBLE); } else if (imageHolder.getBitmap() != null) { imageView.setImageBitmap(imageHolder.getBitmap()); imageView.setVisibility(View.VISIBLE); } else { imageView.setVisibility(View.GONE); } } else if (imageView != null) { imageView.setVisibility(View.GONE); } }
[ "public", "static", "void", "applyDecidedIconOrSetGone", "(", "ImageHolder", "imageHolder", ",", "ImageView", "imageView", ",", "int", "iconColor", ",", "boolean", "tint", ")", "{", "if", "(", "imageHolder", "!=", "null", "&&", "imageView", "!=", "null", ")", "{", "Drawable", "drawable", "=", "ImageHolder", ".", "decideIcon", "(", "imageHolder", ",", "imageView", ".", "getContext", "(", ")", ",", "iconColor", ",", "tint", ")", ";", "if", "(", "drawable", "!=", "null", ")", "{", "imageView", ".", "setImageDrawable", "(", "drawable", ")", ";", "imageView", ".", "setVisibility", "(", "View", ".", "VISIBLE", ")", ";", "}", "else", "if", "(", "imageHolder", ".", "getBitmap", "(", ")", "!=", "null", ")", "{", "imageView", ".", "setImageBitmap", "(", "imageHolder", ".", "getBitmap", "(", ")", ")", ";", "imageView", ".", "setVisibility", "(", "View", ".", "VISIBLE", ")", ";", "}", "else", "{", "imageView", ".", "setVisibility", "(", "View", ".", "GONE", ")", ";", "}", "}", "else", "if", "(", "imageView", "!=", "null", ")", "{", "imageView", ".", "setVisibility", "(", "View", ".", "GONE", ")", ";", "}", "}" ]
decides which icon to apply or hide this view @param imageHolder @param imageView @param iconColor @param tint
[ "decides", "which", "icon", "to", "apply", "or", "hide", "this", "view" ]
2612c10c7570191a78d57f23620e945d61370e3d
https://github.com/mikepenz/Materialize/blob/2612c10c7570191a78d57f23620e945d61370e3d/library/src/main/java/com/mikepenz/materialize/holder/ImageHolder.java#L259-L274
162,268
mikepenz/Materialize
library/src/main/java/com/mikepenz/materialize/holder/ImageHolder.java
ImageHolder.applyMultiIconTo
public static void applyMultiIconTo(Drawable icon, int iconColor, Drawable selectedIcon, int selectedIconColor, boolean tinted, ImageView imageView) { //if we have an icon then we want to set it if (icon != null) { //if we got a different color for the selectedIcon we need a StateList if (selectedIcon != null) { if (tinted) { imageView.setImageDrawable(new PressedEffectStateListDrawable(icon, selectedIcon, iconColor, selectedIconColor)); } else { imageView.setImageDrawable(UIUtils.getIconStateList(icon, selectedIcon)); } } else if (tinted) { imageView.setImageDrawable(new PressedEffectStateListDrawable(icon, iconColor, selectedIconColor)); } else { imageView.setImageDrawable(icon); } //make sure we display the icon imageView.setVisibility(View.VISIBLE); } else { //hide the icon imageView.setVisibility(View.GONE); } }
java
public static void applyMultiIconTo(Drawable icon, int iconColor, Drawable selectedIcon, int selectedIconColor, boolean tinted, ImageView imageView) { //if we have an icon then we want to set it if (icon != null) { //if we got a different color for the selectedIcon we need a StateList if (selectedIcon != null) { if (tinted) { imageView.setImageDrawable(new PressedEffectStateListDrawable(icon, selectedIcon, iconColor, selectedIconColor)); } else { imageView.setImageDrawable(UIUtils.getIconStateList(icon, selectedIcon)); } } else if (tinted) { imageView.setImageDrawable(new PressedEffectStateListDrawable(icon, iconColor, selectedIconColor)); } else { imageView.setImageDrawable(icon); } //make sure we display the icon imageView.setVisibility(View.VISIBLE); } else { //hide the icon imageView.setVisibility(View.GONE); } }
[ "public", "static", "void", "applyMultiIconTo", "(", "Drawable", "icon", ",", "int", "iconColor", ",", "Drawable", "selectedIcon", ",", "int", "selectedIconColor", ",", "boolean", "tinted", ",", "ImageView", "imageView", ")", "{", "//if we have an icon then we want to set it", "if", "(", "icon", "!=", "null", ")", "{", "//if we got a different color for the selectedIcon we need a StateList", "if", "(", "selectedIcon", "!=", "null", ")", "{", "if", "(", "tinted", ")", "{", "imageView", ".", "setImageDrawable", "(", "new", "PressedEffectStateListDrawable", "(", "icon", ",", "selectedIcon", ",", "iconColor", ",", "selectedIconColor", ")", ")", ";", "}", "else", "{", "imageView", ".", "setImageDrawable", "(", "UIUtils", ".", "getIconStateList", "(", "icon", ",", "selectedIcon", ")", ")", ";", "}", "}", "else", "if", "(", "tinted", ")", "{", "imageView", ".", "setImageDrawable", "(", "new", "PressedEffectStateListDrawable", "(", "icon", ",", "iconColor", ",", "selectedIconColor", ")", ")", ";", "}", "else", "{", "imageView", ".", "setImageDrawable", "(", "icon", ")", ";", "}", "//make sure we display the icon", "imageView", ".", "setVisibility", "(", "View", ".", "VISIBLE", ")", ";", "}", "else", "{", "//hide the icon", "imageView", ".", "setVisibility", "(", "View", ".", "GONE", ")", ";", "}", "}" ]
a small static helper to set a multi state drawable on a view @param icon @param iconColor @param selectedIcon @param selectedIconColor @param tinted @param imageView
[ "a", "small", "static", "helper", "to", "set", "a", "multi", "state", "drawable", "on", "a", "view" ]
2612c10c7570191a78d57f23620e945d61370e3d
https://github.com/mikepenz/Materialize/blob/2612c10c7570191a78d57f23620e945d61370e3d/library/src/main/java/com/mikepenz/materialize/holder/ImageHolder.java#L286-L307
162,269
blackfizz/EazeGraph
EazeGraphLibrary/src/main/java/org/eazegraph/lib/charts/PieChart.java
PieChart.setHighlightStrength
public void setHighlightStrength(float _highlightStrength) { mHighlightStrength = _highlightStrength; for (PieModel model : mPieData) { highlightSlice(model); } invalidateGlobal(); }
java
public void setHighlightStrength(float _highlightStrength) { mHighlightStrength = _highlightStrength; for (PieModel model : mPieData) { highlightSlice(model); } invalidateGlobal(); }
[ "public", "void", "setHighlightStrength", "(", "float", "_highlightStrength", ")", "{", "mHighlightStrength", "=", "_highlightStrength", ";", "for", "(", "PieModel", "model", ":", "mPieData", ")", "{", "highlightSlice", "(", "model", ")", ";", "}", "invalidateGlobal", "(", ")", ";", "}" ]
Sets the highlight strength for the InnerPaddingOutline. @param _highlightStrength The highlighting value for the outline.
[ "Sets", "the", "highlight", "strength", "for", "the", "InnerPaddingOutline", "." ]
ce5e68ecc70e154f83bbb2fcce1a970db125c1e6
https://github.com/blackfizz/EazeGraph/blob/ce5e68ecc70e154f83bbb2fcce1a970db125c1e6/EazeGraphLibrary/src/main/java/org/eazegraph/lib/charts/PieChart.java#L256-L262
162,270
blackfizz/EazeGraph
EazeGraphLibrary/src/main/java/org/eazegraph/lib/charts/PieChart.java
PieChart.addPieSlice
public void addPieSlice(PieModel _Slice) { highlightSlice(_Slice); mPieData.add(_Slice); mTotalValue += _Slice.getValue(); onDataChanged(); }
java
public void addPieSlice(PieModel _Slice) { highlightSlice(_Slice); mPieData.add(_Slice); mTotalValue += _Slice.getValue(); onDataChanged(); }
[ "public", "void", "addPieSlice", "(", "PieModel", "_Slice", ")", "{", "highlightSlice", "(", "_Slice", ")", ";", "mPieData", ".", "add", "(", "_Slice", ")", ";", "mTotalValue", "+=", "_Slice", ".", "getValue", "(", ")", ";", "onDataChanged", "(", ")", ";", "}" ]
Adds a new Pie Slice to the PieChart. After inserting and calculation of the highlighting color a complete recalculation is initiated. @param _Slice The newly added PieSlice.
[ "Adds", "a", "new", "Pie", "Slice", "to", "the", "PieChart", ".", "After", "inserting", "and", "calculation", "of", "the", "highlighting", "color", "a", "complete", "recalculation", "is", "initiated", "." ]
ce5e68ecc70e154f83bbb2fcce1a970db125c1e6
https://github.com/blackfizz/EazeGraph/blob/ce5e68ecc70e154f83bbb2fcce1a970db125c1e6/EazeGraphLibrary/src/main/java/org/eazegraph/lib/charts/PieChart.java#L499-L504
162,271
blackfizz/EazeGraph
EazeGraphLibrary/src/main/java/org/eazegraph/lib/charts/PieChart.java
PieChart.onDraw
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); // If the API level is less than 11, we can't rely on the view animation system to // do the scrolling animation. Need to tick it here and call postInvalidate() until the scrolling is done. if (Build.VERSION.SDK_INT < 11) { tickScrollAnimation(); if (!mScroller.isFinished()) { mGraph.postInvalidate(); } } }
java
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); // If the API level is less than 11, we can't rely on the view animation system to // do the scrolling animation. Need to tick it here and call postInvalidate() until the scrolling is done. if (Build.VERSION.SDK_INT < 11) { tickScrollAnimation(); if (!mScroller.isFinished()) { mGraph.postInvalidate(); } } }
[ "@", "Override", "protected", "void", "onDraw", "(", "Canvas", "canvas", ")", "{", "super", ".", "onDraw", "(", "canvas", ")", ";", "// If the API level is less than 11, we can't rely on the view animation system to", "// do the scrolling animation. Need to tick it here and call postInvalidate() until the scrolling is done.", "if", "(", "Build", ".", "VERSION", ".", "SDK_INT", "<", "11", ")", "{", "tickScrollAnimation", "(", ")", ";", "if", "(", "!", "mScroller", ".", "isFinished", "(", ")", ")", "{", "mGraph", ".", "postInvalidate", "(", ")", ";", "}", "}", "}" ]
Implement this to do your drawing. @param canvas the canvas on which the background will be drawn
[ "Implement", "this", "to", "do", "your", "drawing", "." ]
ce5e68ecc70e154f83bbb2fcce1a970db125c1e6
https://github.com/blackfizz/EazeGraph/blob/ce5e68ecc70e154f83bbb2fcce1a970db125c1e6/EazeGraphLibrary/src/main/java/org/eazegraph/lib/charts/PieChart.java#L559-L571
162,272
blackfizz/EazeGraph
EazeGraphLibrary/src/main/java/org/eazegraph/lib/charts/PieChart.java
PieChart.onDataChanged
@Override protected void onDataChanged() { super.onDataChanged(); int currentAngle = 0; int index = 0; int size = mPieData.size(); for (PieModel model : mPieData) { int endAngle = (int) (currentAngle + model.getValue() * 360.f / mTotalValue); if(index == size-1) { endAngle = 360; } model.setStartAngle(currentAngle); model.setEndAngle(endAngle); currentAngle = model.getEndAngle(); index++; } calcCurrentItem(); onScrollFinished(); }
java
@Override protected void onDataChanged() { super.onDataChanged(); int currentAngle = 0; int index = 0; int size = mPieData.size(); for (PieModel model : mPieData) { int endAngle = (int) (currentAngle + model.getValue() * 360.f / mTotalValue); if(index == size-1) { endAngle = 360; } model.setStartAngle(currentAngle); model.setEndAngle(endAngle); currentAngle = model.getEndAngle(); index++; } calcCurrentItem(); onScrollFinished(); }
[ "@", "Override", "protected", "void", "onDataChanged", "(", ")", "{", "super", ".", "onDataChanged", "(", ")", ";", "int", "currentAngle", "=", "0", ";", "int", "index", "=", "0", ";", "int", "size", "=", "mPieData", ".", "size", "(", ")", ";", "for", "(", "PieModel", "model", ":", "mPieData", ")", "{", "int", "endAngle", "=", "(", "int", ")", "(", "currentAngle", "+", "model", ".", "getValue", "(", ")", "*", "360.f", "/", "mTotalValue", ")", ";", "if", "(", "index", "==", "size", "-", "1", ")", "{", "endAngle", "=", "360", ";", "}", "model", ".", "setStartAngle", "(", "currentAngle", ")", ";", "model", ".", "setEndAngle", "(", "endAngle", ")", ";", "currentAngle", "=", "model", ".", "getEndAngle", "(", ")", ";", "index", "++", ";", "}", "calcCurrentItem", "(", ")", ";", "onScrollFinished", "(", ")", ";", "}" ]
Should be called after new data is inserted. Will be automatically called, when the view dimensions has changed. Calculates the start- and end-angles for every PieSlice.
[ "Should", "be", "called", "after", "new", "data", "is", "inserted", ".", "Will", "be", "automatically", "called", "when", "the", "view", "dimensions", "has", "changed", "." ]
ce5e68ecc70e154f83bbb2fcce1a970db125c1e6
https://github.com/blackfizz/EazeGraph/blob/ce5e68ecc70e154f83bbb2fcce1a970db125c1e6/EazeGraphLibrary/src/main/java/org/eazegraph/lib/charts/PieChart.java#L717-L738
162,273
blackfizz/EazeGraph
EazeGraphLibrary/src/main/java/org/eazegraph/lib/charts/PieChart.java
PieChart.highlightSlice
private void highlightSlice(PieModel _Slice) { int color = _Slice.getColor(); _Slice.setHighlightedColor(Color.argb( 0xff, Math.min((int) (mHighlightStrength * (float) Color.red(color)), 0xff), Math.min((int) (mHighlightStrength * (float) Color.green(color)), 0xff), Math.min((int) (mHighlightStrength * (float) Color.blue(color)), 0xff) )); }
java
private void highlightSlice(PieModel _Slice) { int color = _Slice.getColor(); _Slice.setHighlightedColor(Color.argb( 0xff, Math.min((int) (mHighlightStrength * (float) Color.red(color)), 0xff), Math.min((int) (mHighlightStrength * (float) Color.green(color)), 0xff), Math.min((int) (mHighlightStrength * (float) Color.blue(color)), 0xff) )); }
[ "private", "void", "highlightSlice", "(", "PieModel", "_Slice", ")", "{", "int", "color", "=", "_Slice", ".", "getColor", "(", ")", ";", "_Slice", ".", "setHighlightedColor", "(", "Color", ".", "argb", "(", "0xff", ",", "Math", ".", "min", "(", "(", "int", ")", "(", "mHighlightStrength", "*", "(", "float", ")", "Color", ".", "red", "(", "color", ")", ")", ",", "0xff", ")", ",", "Math", ".", "min", "(", "(", "int", ")", "(", "mHighlightStrength", "*", "(", "float", ")", "Color", ".", "green", "(", "color", ")", ")", ",", "0xff", ")", ",", "Math", ".", "min", "(", "(", "int", ")", "(", "mHighlightStrength", "*", "(", "float", ")", "Color", ".", "blue", "(", "color", ")", ")", ",", "0xff", ")", ")", ")", ";", "}" ]
Calculate the highlight color. Saturate at 0xff to make sure that high values don't result in aliasing. @param _Slice The Slice which will be highlighted.
[ "Calculate", "the", "highlight", "color", ".", "Saturate", "at", "0xff", "to", "make", "sure", "that", "high", "values", "don", "t", "result", "in", "aliasing", "." ]
ce5e68ecc70e154f83bbb2fcce1a970db125c1e6
https://github.com/blackfizz/EazeGraph/blob/ce5e68ecc70e154f83bbb2fcce1a970db125c1e6/EazeGraphLibrary/src/main/java/org/eazegraph/lib/charts/PieChart.java#L746-L755
162,274
blackfizz/EazeGraph
EazeGraphLibrary/src/main/java/org/eazegraph/lib/charts/PieChart.java
PieChart.calcCurrentItem
private void calcCurrentItem() { int pointerAngle; // calculate the correct pointer angle, depending on clockwise drawing or not if(mOpenClockwise) { pointerAngle = (mIndicatorAngle + 360 - mPieRotation) % 360; } else { pointerAngle = (mIndicatorAngle + 180 + mPieRotation) % 360; } for (int i = 0; i < mPieData.size(); ++i) { PieModel model = mPieData.get(i); if (model.getStartAngle() <= pointerAngle && pointerAngle <= model.getEndAngle()) { if (i != mCurrentItem) { setCurrentItem(i, false); } break; } } }
java
private void calcCurrentItem() { int pointerAngle; // calculate the correct pointer angle, depending on clockwise drawing or not if(mOpenClockwise) { pointerAngle = (mIndicatorAngle + 360 - mPieRotation) % 360; } else { pointerAngle = (mIndicatorAngle + 180 + mPieRotation) % 360; } for (int i = 0; i < mPieData.size(); ++i) { PieModel model = mPieData.get(i); if (model.getStartAngle() <= pointerAngle && pointerAngle <= model.getEndAngle()) { if (i != mCurrentItem) { setCurrentItem(i, false); } break; } } }
[ "private", "void", "calcCurrentItem", "(", ")", "{", "int", "pointerAngle", ";", "// calculate the correct pointer angle, depending on clockwise drawing or not", "if", "(", "mOpenClockwise", ")", "{", "pointerAngle", "=", "(", "mIndicatorAngle", "+", "360", "-", "mPieRotation", ")", "%", "360", ";", "}", "else", "{", "pointerAngle", "=", "(", "mIndicatorAngle", "+", "180", "+", "mPieRotation", ")", "%", "360", ";", "}", "for", "(", "int", "i", "=", "0", ";", "i", "<", "mPieData", ".", "size", "(", ")", ";", "++", "i", ")", "{", "PieModel", "model", "=", "mPieData", ".", "get", "(", "i", ")", ";", "if", "(", "model", ".", "getStartAngle", "(", ")", "<=", "pointerAngle", "&&", "pointerAngle", "<=", "model", ".", "getEndAngle", "(", ")", ")", "{", "if", "(", "i", "!=", "mCurrentItem", ")", "{", "setCurrentItem", "(", "i", ",", "false", ")", ";", "}", "break", ";", "}", "}", "}" ]
Calculate which pie slice is under the pointer, and set the current item field accordingly.
[ "Calculate", "which", "pie", "slice", "is", "under", "the", "pointer", "and", "set", "the", "current", "item", "field", "accordingly", "." ]
ce5e68ecc70e154f83bbb2fcce1a970db125c1e6
https://github.com/blackfizz/EazeGraph/blob/ce5e68ecc70e154f83bbb2fcce1a970db125c1e6/EazeGraphLibrary/src/main/java/org/eazegraph/lib/charts/PieChart.java#L761-L781
162,275
blackfizz/EazeGraph
EazeGraphLibrary/src/main/java/org/eazegraph/lib/charts/PieChart.java
PieChart.centerOnCurrentItem
private void centerOnCurrentItem() { if(!mPieData.isEmpty()) { PieModel current = mPieData.get(getCurrentItem()); int targetAngle; if(mOpenClockwise) { targetAngle = (mIndicatorAngle - current.getStartAngle()) - ((current.getEndAngle() - current.getStartAngle()) / 2); if (targetAngle < 0 && mPieRotation > 0) targetAngle += 360; } else { targetAngle = current.getStartAngle() + (current.getEndAngle() - current.getStartAngle()) / 2; targetAngle += mIndicatorAngle; if (targetAngle > 270 && mPieRotation < 90) targetAngle -= 360; } mAutoCenterAnimator.setIntValues(targetAngle); mAutoCenterAnimator.setDuration(AUTOCENTER_ANIM_DURATION).start(); } }
java
private void centerOnCurrentItem() { if(!mPieData.isEmpty()) { PieModel current = mPieData.get(getCurrentItem()); int targetAngle; if(mOpenClockwise) { targetAngle = (mIndicatorAngle - current.getStartAngle()) - ((current.getEndAngle() - current.getStartAngle()) / 2); if (targetAngle < 0 && mPieRotation > 0) targetAngle += 360; } else { targetAngle = current.getStartAngle() + (current.getEndAngle() - current.getStartAngle()) / 2; targetAngle += mIndicatorAngle; if (targetAngle > 270 && mPieRotation < 90) targetAngle -= 360; } mAutoCenterAnimator.setIntValues(targetAngle); mAutoCenterAnimator.setDuration(AUTOCENTER_ANIM_DURATION).start(); } }
[ "private", "void", "centerOnCurrentItem", "(", ")", "{", "if", "(", "!", "mPieData", ".", "isEmpty", "(", ")", ")", "{", "PieModel", "current", "=", "mPieData", ".", "get", "(", "getCurrentItem", "(", ")", ")", ";", "int", "targetAngle", ";", "if", "(", "mOpenClockwise", ")", "{", "targetAngle", "=", "(", "mIndicatorAngle", "-", "current", ".", "getStartAngle", "(", ")", ")", "-", "(", "(", "current", ".", "getEndAngle", "(", ")", "-", "current", ".", "getStartAngle", "(", ")", ")", "/", "2", ")", ";", "if", "(", "targetAngle", "<", "0", "&&", "mPieRotation", ">", "0", ")", "targetAngle", "+=", "360", ";", "}", "else", "{", "targetAngle", "=", "current", ".", "getStartAngle", "(", ")", "+", "(", "current", ".", "getEndAngle", "(", ")", "-", "current", ".", "getStartAngle", "(", ")", ")", "/", "2", ";", "targetAngle", "+=", "mIndicatorAngle", ";", "if", "(", "targetAngle", ">", "270", "&&", "mPieRotation", "<", "90", ")", "targetAngle", "-=", "360", ";", "}", "mAutoCenterAnimator", ".", "setIntValues", "(", "targetAngle", ")", ";", "mAutoCenterAnimator", ".", "setDuration", "(", "AUTOCENTER_ANIM_DURATION", ")", ".", "start", "(", ")", ";", "}", "}" ]
Kicks off an animation that will result in the pointer being centered in the pie slice of the currently selected item.
[ "Kicks", "off", "an", "animation", "that", "will", "result", "in", "the", "pointer", "being", "centered", "in", "the", "pie", "slice", "of", "the", "currently", "selected", "item", "." ]
ce5e68ecc70e154f83bbb2fcce1a970db125c1e6
https://github.com/blackfizz/EazeGraph/blob/ce5e68ecc70e154f83bbb2fcce1a970db125c1e6/EazeGraphLibrary/src/main/java/org/eazegraph/lib/charts/PieChart.java#L819-L838
162,276
blackfizz/EazeGraph
EazeGraphLibrary/src/main/java/org/eazegraph/lib/charts/ValueLineChart.java
ValueLineChart.onLegendDataChanged
protected void onLegendDataChanged() { int legendCount = mLegendList.size(); float margin = (mGraphWidth / legendCount); float currentOffset = 0; for (LegendModel model : mLegendList) { model.setLegendBounds(new RectF(currentOffset, 0, currentOffset + margin, mLegendHeight)); currentOffset += margin; } Utils.calculateLegendInformation(mLegendList, 0, mGraphWidth, mLegendPaint); invalidateGlobal(); }
java
protected void onLegendDataChanged() { int legendCount = mLegendList.size(); float margin = (mGraphWidth / legendCount); float currentOffset = 0; for (LegendModel model : mLegendList) { model.setLegendBounds(new RectF(currentOffset, 0, currentOffset + margin, mLegendHeight)); currentOffset += margin; } Utils.calculateLegendInformation(mLegendList, 0, mGraphWidth, mLegendPaint); invalidateGlobal(); }
[ "protected", "void", "onLegendDataChanged", "(", ")", "{", "int", "legendCount", "=", "mLegendList", ".", "size", "(", ")", ";", "float", "margin", "=", "(", "mGraphWidth", "/", "legendCount", ")", ";", "float", "currentOffset", "=", "0", ";", "for", "(", "LegendModel", "model", ":", "mLegendList", ")", "{", "model", ".", "setLegendBounds", "(", "new", "RectF", "(", "currentOffset", ",", "0", ",", "currentOffset", "+", "margin", ",", "mLegendHeight", ")", ")", ";", "currentOffset", "+=", "margin", ";", "}", "Utils", ".", "calculateLegendInformation", "(", "mLegendList", ",", "0", ",", "mGraphWidth", ",", "mLegendPaint", ")", ";", "invalidateGlobal", "(", ")", ";", "}" ]
Calculates the legend bounds for a custom list of legends.
[ "Calculates", "the", "legend", "bounds", "for", "a", "custom", "list", "of", "legends", "." ]
ce5e68ecc70e154f83bbb2fcce1a970db125c1e6
https://github.com/blackfizz/EazeGraph/blob/ce5e68ecc70e154f83bbb2fcce1a970db125c1e6/EazeGraphLibrary/src/main/java/org/eazegraph/lib/charts/ValueLineChart.java#L958-L972
162,277
blackfizz/EazeGraph
EazeGraphLibrary/src/main/java/org/eazegraph/lib/charts/ValueLineChart.java
ValueLineChart.calculateValueTextHeight
private void calculateValueTextHeight() { Rect valueRect = new Rect(); Rect legendRect = new Rect(); String str = Utils.getFloatString(mFocusedPoint.getValue(), mShowDecimal) + (!mIndicatorTextUnit.isEmpty() ? " " + mIndicatorTextUnit : ""); // calculate the boundaries for both texts mIndicatorPaint.getTextBounds(str, 0, str.length(), valueRect); mLegendPaint.getTextBounds(mFocusedPoint.getLegendLabel(), 0, mFocusedPoint.getLegendLabel().length(), legendRect); // calculate string positions in overlay mValueTextHeight = valueRect.height(); mValueLabelY = (int) (mValueTextHeight + mIndicatorTopPadding); mLegendLabelY = (int) (mValueTextHeight + mIndicatorTopPadding + legendRect.height() + Utils.dpToPx(7.f)); int chosenWidth = valueRect.width() > legendRect.width() ? valueRect.width() : legendRect.width(); // check if text reaches over screen if (mFocusedPoint.getCoordinates().getX() + chosenWidth + mIndicatorLeftPadding > -Utils.getTranslationX(mDrawMatrixValues) + mGraphWidth) { mValueLabelX = (int) (mFocusedPoint.getCoordinates().getX() - (valueRect.width() + mIndicatorLeftPadding)); mLegendLabelX = (int) (mFocusedPoint.getCoordinates().getX() - (legendRect.width() + mIndicatorLeftPadding)); } else { mValueLabelX = mLegendLabelX = (int) (mFocusedPoint.getCoordinates().getX() + mIndicatorLeftPadding); } }
java
private void calculateValueTextHeight() { Rect valueRect = new Rect(); Rect legendRect = new Rect(); String str = Utils.getFloatString(mFocusedPoint.getValue(), mShowDecimal) + (!mIndicatorTextUnit.isEmpty() ? " " + mIndicatorTextUnit : ""); // calculate the boundaries for both texts mIndicatorPaint.getTextBounds(str, 0, str.length(), valueRect); mLegendPaint.getTextBounds(mFocusedPoint.getLegendLabel(), 0, mFocusedPoint.getLegendLabel().length(), legendRect); // calculate string positions in overlay mValueTextHeight = valueRect.height(); mValueLabelY = (int) (mValueTextHeight + mIndicatorTopPadding); mLegendLabelY = (int) (mValueTextHeight + mIndicatorTopPadding + legendRect.height() + Utils.dpToPx(7.f)); int chosenWidth = valueRect.width() > legendRect.width() ? valueRect.width() : legendRect.width(); // check if text reaches over screen if (mFocusedPoint.getCoordinates().getX() + chosenWidth + mIndicatorLeftPadding > -Utils.getTranslationX(mDrawMatrixValues) + mGraphWidth) { mValueLabelX = (int) (mFocusedPoint.getCoordinates().getX() - (valueRect.width() + mIndicatorLeftPadding)); mLegendLabelX = (int) (mFocusedPoint.getCoordinates().getX() - (legendRect.width() + mIndicatorLeftPadding)); } else { mValueLabelX = mLegendLabelX = (int) (mFocusedPoint.getCoordinates().getX() + mIndicatorLeftPadding); } }
[ "private", "void", "calculateValueTextHeight", "(", ")", "{", "Rect", "valueRect", "=", "new", "Rect", "(", ")", ";", "Rect", "legendRect", "=", "new", "Rect", "(", ")", ";", "String", "str", "=", "Utils", ".", "getFloatString", "(", "mFocusedPoint", ".", "getValue", "(", ")", ",", "mShowDecimal", ")", "+", "(", "!", "mIndicatorTextUnit", ".", "isEmpty", "(", ")", "?", "\" \"", "+", "mIndicatorTextUnit", ":", "\"\"", ")", ";", "// calculate the boundaries for both texts", "mIndicatorPaint", ".", "getTextBounds", "(", "str", ",", "0", ",", "str", ".", "length", "(", ")", ",", "valueRect", ")", ";", "mLegendPaint", ".", "getTextBounds", "(", "mFocusedPoint", ".", "getLegendLabel", "(", ")", ",", "0", ",", "mFocusedPoint", ".", "getLegendLabel", "(", ")", ".", "length", "(", ")", ",", "legendRect", ")", ";", "// calculate string positions in overlay", "mValueTextHeight", "=", "valueRect", ".", "height", "(", ")", ";", "mValueLabelY", "=", "(", "int", ")", "(", "mValueTextHeight", "+", "mIndicatorTopPadding", ")", ";", "mLegendLabelY", "=", "(", "int", ")", "(", "mValueTextHeight", "+", "mIndicatorTopPadding", "+", "legendRect", ".", "height", "(", ")", "+", "Utils", ".", "dpToPx", "(", "7.f", ")", ")", ";", "int", "chosenWidth", "=", "valueRect", ".", "width", "(", ")", ">", "legendRect", ".", "width", "(", ")", "?", "valueRect", ".", "width", "(", ")", ":", "legendRect", ".", "width", "(", ")", ";", "// check if text reaches over screen", "if", "(", "mFocusedPoint", ".", "getCoordinates", "(", ")", ".", "getX", "(", ")", "+", "chosenWidth", "+", "mIndicatorLeftPadding", ">", "-", "Utils", ".", "getTranslationX", "(", "mDrawMatrixValues", ")", "+", "mGraphWidth", ")", "{", "mValueLabelX", "=", "(", "int", ")", "(", "mFocusedPoint", ".", "getCoordinates", "(", ")", ".", "getX", "(", ")", "-", "(", "valueRect", ".", "width", "(", ")", "+", "mIndicatorLeftPadding", ")", ")", ";", "mLegendLabelX", "=", "(", "int", ")", "(", "mFocusedPoint", ".", "getCoordinates", "(", ")", ".", "getX", "(", ")", "-", "(", "legendRect", ".", "width", "(", ")", "+", "mIndicatorLeftPadding", ")", ")", ";", "}", "else", "{", "mValueLabelX", "=", "mLegendLabelX", "=", "(", "int", ")", "(", "mFocusedPoint", ".", "getCoordinates", "(", ")", ".", "getX", "(", ")", "+", "mIndicatorLeftPadding", ")", ";", "}", "}" ]
Calculates the text height for the indicator value and sets its x-coordinate.
[ "Calculates", "the", "text", "height", "for", "the", "indicator", "value", "and", "sets", "its", "x", "-", "coordinate", "." ]
ce5e68ecc70e154f83bbb2fcce1a970db125c1e6
https://github.com/blackfizz/EazeGraph/blob/ce5e68ecc70e154f83bbb2fcce1a970db125c1e6/EazeGraphLibrary/src/main/java/org/eazegraph/lib/charts/ValueLineChart.java#L977-L1000
162,278
blackfizz/EazeGraph
EazeGraphLibrary/src/main/java/org/eazegraph/lib/charts/BaseBarChart.java
BaseBarChart.calculateBarPositions
protected void calculateBarPositions(int _DataSize) { int dataSize = mScrollEnabled ? mVisibleBars : _DataSize; float barWidth = mBarWidth; float margin = mBarMargin; if (!mFixedBarWidth) { // calculate the bar width if the bars should be dynamically displayed barWidth = (mAvailableScreenSize / _DataSize) - margin; } else { if(_DataSize < mVisibleBars) { dataSize = _DataSize; } // calculate margin between bars if the bars have a fixed width float cumulatedBarWidths = barWidth * dataSize; float remainingScreenSize = mAvailableScreenSize - cumulatedBarWidths; margin = remainingScreenSize / dataSize; } boolean isVertical = this instanceof VerticalBarChart; int calculatedSize = (int) ((barWidth * _DataSize) + (margin * _DataSize)); int contentWidth = isVertical ? mGraphWidth : calculatedSize; int contentHeight = isVertical ? calculatedSize : mGraphHeight; mContentRect = new Rect(0, 0, contentWidth, contentHeight); mCurrentViewport = new RectF(0, 0, mGraphWidth, mGraphHeight); calculateBounds(barWidth, margin); mLegend.invalidate(); mGraph.invalidate(); }
java
protected void calculateBarPositions(int _DataSize) { int dataSize = mScrollEnabled ? mVisibleBars : _DataSize; float barWidth = mBarWidth; float margin = mBarMargin; if (!mFixedBarWidth) { // calculate the bar width if the bars should be dynamically displayed barWidth = (mAvailableScreenSize / _DataSize) - margin; } else { if(_DataSize < mVisibleBars) { dataSize = _DataSize; } // calculate margin between bars if the bars have a fixed width float cumulatedBarWidths = barWidth * dataSize; float remainingScreenSize = mAvailableScreenSize - cumulatedBarWidths; margin = remainingScreenSize / dataSize; } boolean isVertical = this instanceof VerticalBarChart; int calculatedSize = (int) ((barWidth * _DataSize) + (margin * _DataSize)); int contentWidth = isVertical ? mGraphWidth : calculatedSize; int contentHeight = isVertical ? calculatedSize : mGraphHeight; mContentRect = new Rect(0, 0, contentWidth, contentHeight); mCurrentViewport = new RectF(0, 0, mGraphWidth, mGraphHeight); calculateBounds(barWidth, margin); mLegend.invalidate(); mGraph.invalidate(); }
[ "protected", "void", "calculateBarPositions", "(", "int", "_DataSize", ")", "{", "int", "dataSize", "=", "mScrollEnabled", "?", "mVisibleBars", ":", "_DataSize", ";", "float", "barWidth", "=", "mBarWidth", ";", "float", "margin", "=", "mBarMargin", ";", "if", "(", "!", "mFixedBarWidth", ")", "{", "// calculate the bar width if the bars should be dynamically displayed", "barWidth", "=", "(", "mAvailableScreenSize", "/", "_DataSize", ")", "-", "margin", ";", "}", "else", "{", "if", "(", "_DataSize", "<", "mVisibleBars", ")", "{", "dataSize", "=", "_DataSize", ";", "}", "// calculate margin between bars if the bars have a fixed width", "float", "cumulatedBarWidths", "=", "barWidth", "*", "dataSize", ";", "float", "remainingScreenSize", "=", "mAvailableScreenSize", "-", "cumulatedBarWidths", ";", "margin", "=", "remainingScreenSize", "/", "dataSize", ";", "}", "boolean", "isVertical", "=", "this", "instanceof", "VerticalBarChart", ";", "int", "calculatedSize", "=", "(", "int", ")", "(", "(", "barWidth", "*", "_DataSize", ")", "+", "(", "margin", "*", "_DataSize", ")", ")", ";", "int", "contentWidth", "=", "isVertical", "?", "mGraphWidth", ":", "calculatedSize", ";", "int", "contentHeight", "=", "isVertical", "?", "calculatedSize", ":", "mGraphHeight", ";", "mContentRect", "=", "new", "Rect", "(", "0", ",", "0", ",", "contentWidth", ",", "contentHeight", ")", ";", "mCurrentViewport", "=", "new", "RectF", "(", "0", ",", "0", ",", "mGraphWidth", ",", "mGraphHeight", ")", ";", "calculateBounds", "(", "barWidth", ",", "margin", ")", ";", "mLegend", ".", "invalidate", "(", ")", ";", "mGraph", ".", "invalidate", "(", ")", ";", "}" ]
Calculates the bar width and bar margin based on the _DataSize and settings and starts the boundary calculation in child classes. @param _DataSize Amount of data sets
[ "Calculates", "the", "bar", "width", "and", "bar", "margin", "based", "on", "the", "_DataSize", "and", "settings", "and", "starts", "the", "boundary", "calculation", "in", "child", "classes", "." ]
ce5e68ecc70e154f83bbb2fcce1a970db125c1e6
https://github.com/blackfizz/EazeGraph/blob/ce5e68ecc70e154f83bbb2fcce1a970db125c1e6/EazeGraphLibrary/src/main/java/org/eazegraph/lib/charts/BaseBarChart.java#L322-L356
162,279
blackfizz/EazeGraph
EazeGraphLibrary/src/main/java/org/eazegraph/lib/charts/BaseBarChart.java
BaseBarChart.onGraphDraw
@Override protected void onGraphDraw(Canvas _Canvas) { super.onGraphDraw(_Canvas); _Canvas.translate(-mCurrentViewport.left, -mCurrentViewport.top); drawBars(_Canvas); }
java
@Override protected void onGraphDraw(Canvas _Canvas) { super.onGraphDraw(_Canvas); _Canvas.translate(-mCurrentViewport.left, -mCurrentViewport.top); drawBars(_Canvas); }
[ "@", "Override", "protected", "void", "onGraphDraw", "(", "Canvas", "_Canvas", ")", "{", "super", ".", "onGraphDraw", "(", "_Canvas", ")", ";", "_Canvas", ".", "translate", "(", "-", "mCurrentViewport", ".", "left", ",", "-", "mCurrentViewport", ".", "top", ")", ";", "drawBars", "(", "_Canvas", ")", ";", "}" ]
region Override Methods
[ "region", "Override", "Methods" ]
ce5e68ecc70e154f83bbb2fcce1a970db125c1e6
https://github.com/blackfizz/EazeGraph/blob/ce5e68ecc70e154f83bbb2fcce1a970db125c1e6/EazeGraphLibrary/src/main/java/org/eazegraph/lib/charts/BaseBarChart.java#L467-L472
162,280
blackfizz/EazeGraph
EazeGraphLibrary/src/main/java/org/eazegraph/lib/utils/Utils.java
Utils.calculatePointDiff
public static void calculatePointDiff(Point2D _P1, Point2D _P2, Point2D _Result, float _Multiplier) { float diffX = _P2.getX() - _P1.getX(); float diffY = _P2.getY() - _P1.getY(); _Result.setX(_P1.getX() + (diffX * _Multiplier)); _Result.setY(_P1.getY() + (diffY * _Multiplier)); }
java
public static void calculatePointDiff(Point2D _P1, Point2D _P2, Point2D _Result, float _Multiplier) { float diffX = _P2.getX() - _P1.getX(); float diffY = _P2.getY() - _P1.getY(); _Result.setX(_P1.getX() + (diffX * _Multiplier)); _Result.setY(_P1.getY() + (diffY * _Multiplier)); }
[ "public", "static", "void", "calculatePointDiff", "(", "Point2D", "_P1", ",", "Point2D", "_P2", ",", "Point2D", "_Result", ",", "float", "_Multiplier", ")", "{", "float", "diffX", "=", "_P2", ".", "getX", "(", ")", "-", "_P1", ".", "getX", "(", ")", ";", "float", "diffY", "=", "_P2", ".", "getY", "(", ")", "-", "_P1", ".", "getY", "(", ")", ";", "_Result", ".", "setX", "(", "_P1", ".", "getX", "(", ")", "+", "(", "diffX", "*", "_Multiplier", ")", ")", ";", "_Result", ".", "setY", "(", "_P1", ".", "getY", "(", ")", "+", "(", "diffY", "*", "_Multiplier", ")", ")", ";", "}" ]
Calculates the middle point between two points and multiplies its coordinates with the given smoothness _Mulitplier. @param _P1 First point @param _P2 Second point @param _Result Resulting point @param _Multiplier Smoothness multiplier
[ "Calculates", "the", "middle", "point", "between", "two", "points", "and", "multiplies", "its", "coordinates", "with", "the", "given", "smoothness", "_Mulitplier", "." ]
ce5e68ecc70e154f83bbb2fcce1a970db125c1e6
https://github.com/blackfizz/EazeGraph/blob/ce5e68ecc70e154f83bbb2fcce1a970db125c1e6/EazeGraphLibrary/src/main/java/org/eazegraph/lib/utils/Utils.java#L58-L63
162,281
blackfizz/EazeGraph
EazeGraphLibrary/src/main/java/org/eazegraph/lib/utils/Utils.java
Utils.calculateLegendInformation
public static void calculateLegendInformation(List<? extends BaseModel> _Models, float _StartX, float _EndX, Paint _Paint) { float textMargin = Utils.dpToPx(10.f); float lastX = _StartX; // calculate the legend label positions and check if there is enough space to display the label, // if not the label will not be shown for (BaseModel model : _Models) { if (!model.isIgnore()) { Rect textBounds = new Rect(); RectF legendBounds = model.getLegendBounds(); _Paint.getTextBounds(model.getLegendLabel(), 0, model.getLegendLabel().length(), textBounds); model.setTextBounds(textBounds); float centerX = legendBounds.centerX(); float centeredTextPos = centerX - (textBounds.width() / 2); float textStartPos = centeredTextPos - textMargin; // check if the text is too big to fit on the screen if (centeredTextPos + textBounds.width() > _EndX - textMargin) { model.setShowLabel(false); } else { // check if the current legend label overrides the label before // if the label overrides the label before, the current label will not be shown. // If not the label will be shown and the label position is calculated if (textStartPos < lastX) { if (lastX + textMargin < legendBounds.left) { model.setLegendLabelPosition((int) (lastX + textMargin)); model.setShowLabel(true); lastX = lastX + textMargin + textBounds.width(); } else { model.setShowLabel(false); } } else { model.setShowLabel(true); model.setLegendLabelPosition((int) centeredTextPos); lastX = centerX + (textBounds.width() / 2); } } } } }
java
public static void calculateLegendInformation(List<? extends BaseModel> _Models, float _StartX, float _EndX, Paint _Paint) { float textMargin = Utils.dpToPx(10.f); float lastX = _StartX; // calculate the legend label positions and check if there is enough space to display the label, // if not the label will not be shown for (BaseModel model : _Models) { if (!model.isIgnore()) { Rect textBounds = new Rect(); RectF legendBounds = model.getLegendBounds(); _Paint.getTextBounds(model.getLegendLabel(), 0, model.getLegendLabel().length(), textBounds); model.setTextBounds(textBounds); float centerX = legendBounds.centerX(); float centeredTextPos = centerX - (textBounds.width() / 2); float textStartPos = centeredTextPos - textMargin; // check if the text is too big to fit on the screen if (centeredTextPos + textBounds.width() > _EndX - textMargin) { model.setShowLabel(false); } else { // check if the current legend label overrides the label before // if the label overrides the label before, the current label will not be shown. // If not the label will be shown and the label position is calculated if (textStartPos < lastX) { if (lastX + textMargin < legendBounds.left) { model.setLegendLabelPosition((int) (lastX + textMargin)); model.setShowLabel(true); lastX = lastX + textMargin + textBounds.width(); } else { model.setShowLabel(false); } } else { model.setShowLabel(true); model.setLegendLabelPosition((int) centeredTextPos); lastX = centerX + (textBounds.width() / 2); } } } } }
[ "public", "static", "void", "calculateLegendInformation", "(", "List", "<", "?", "extends", "BaseModel", ">", "_Models", ",", "float", "_StartX", ",", "float", "_EndX", ",", "Paint", "_Paint", ")", "{", "float", "textMargin", "=", "Utils", ".", "dpToPx", "(", "10.f", ")", ";", "float", "lastX", "=", "_StartX", ";", "// calculate the legend label positions and check if there is enough space to display the label,", "// if not the label will not be shown", "for", "(", "BaseModel", "model", ":", "_Models", ")", "{", "if", "(", "!", "model", ".", "isIgnore", "(", ")", ")", "{", "Rect", "textBounds", "=", "new", "Rect", "(", ")", ";", "RectF", "legendBounds", "=", "model", ".", "getLegendBounds", "(", ")", ";", "_Paint", ".", "getTextBounds", "(", "model", ".", "getLegendLabel", "(", ")", ",", "0", ",", "model", ".", "getLegendLabel", "(", ")", ".", "length", "(", ")", ",", "textBounds", ")", ";", "model", ".", "setTextBounds", "(", "textBounds", ")", ";", "float", "centerX", "=", "legendBounds", ".", "centerX", "(", ")", ";", "float", "centeredTextPos", "=", "centerX", "-", "(", "textBounds", ".", "width", "(", ")", "/", "2", ")", ";", "float", "textStartPos", "=", "centeredTextPos", "-", "textMargin", ";", "// check if the text is too big to fit on the screen", "if", "(", "centeredTextPos", "+", "textBounds", ".", "width", "(", ")", ">", "_EndX", "-", "textMargin", ")", "{", "model", ".", "setShowLabel", "(", "false", ")", ";", "}", "else", "{", "// check if the current legend label overrides the label before", "// if the label overrides the label before, the current label will not be shown.", "// If not the label will be shown and the label position is calculated", "if", "(", "textStartPos", "<", "lastX", ")", "{", "if", "(", "lastX", "+", "textMargin", "<", "legendBounds", ".", "left", ")", "{", "model", ".", "setLegendLabelPosition", "(", "(", "int", ")", "(", "lastX", "+", "textMargin", ")", ")", ";", "model", ".", "setShowLabel", "(", "true", ")", ";", "lastX", "=", "lastX", "+", "textMargin", "+", "textBounds", ".", "width", "(", ")", ";", "}", "else", "{", "model", ".", "setShowLabel", "(", "false", ")", ";", "}", "}", "else", "{", "model", ".", "setShowLabel", "(", "true", ")", ";", "model", ".", "setLegendLabelPosition", "(", "(", "int", ")", "centeredTextPos", ")", ";", "lastX", "=", "centerX", "+", "(", "textBounds", ".", "width", "(", ")", "/", "2", ")", ";", "}", "}", "}", "}", "}" ]
Calculates the legend positions and which legend title should be displayed or not. Important: the LegendBounds in the _Models should be set and correctly calculated before this function is called! @param _Models The graph data which should have the BaseModel class as parent class. @param _StartX Left starting point on the screen. Should be the absolute pixel value! @param _Paint The correctly set Paint which will be used for the text painting in the later process
[ "Calculates", "the", "legend", "positions", "and", "which", "legend", "title", "should", "be", "displayed", "or", "not", "." ]
ce5e68ecc70e154f83bbb2fcce1a970db125c1e6
https://github.com/blackfizz/EazeGraph/blob/ce5e68ecc70e154f83bbb2fcce1a970db125c1e6/EazeGraphLibrary/src/main/java/org/eazegraph/lib/utils/Utils.java#L98-L140
162,282
blackfizz/EazeGraph
EazeGraphLibrary/src/main/java/org/eazegraph/lib/utils/Utils.java
Utils.calculateMaxTextHeight
public static float calculateMaxTextHeight(Paint _Paint, String _Text) { Rect height = new Rect(); String text = _Text == null ? "MgHITasger" : _Text; _Paint.getTextBounds(text, 0, text.length(), height); return height.height(); }
java
public static float calculateMaxTextHeight(Paint _Paint, String _Text) { Rect height = new Rect(); String text = _Text == null ? "MgHITasger" : _Text; _Paint.getTextBounds(text, 0, text.length(), height); return height.height(); }
[ "public", "static", "float", "calculateMaxTextHeight", "(", "Paint", "_Paint", ",", "String", "_Text", ")", "{", "Rect", "height", "=", "new", "Rect", "(", ")", ";", "String", "text", "=", "_Text", "==", "null", "?", "\"MgHITasger\"", ":", "_Text", ";", "_Paint", ".", "getTextBounds", "(", "text", ",", "0", ",", "text", ".", "length", "(", ")", ",", "height", ")", ";", "return", "height", ".", "height", "(", ")", ";", "}" ]
Calculates the maximum text height which is possible based on the used Paint and its settings. @param _Paint Paint object which will be used to display a text. @param _Text The text which should be measured. If null, a default text is chosen, which has a maximum possible height @return Maximum text height in px.
[ "Calculates", "the", "maximum", "text", "height", "which", "is", "possible", "based", "on", "the", "used", "Paint", "and", "its", "settings", "." ]
ce5e68ecc70e154f83bbb2fcce1a970db125c1e6
https://github.com/blackfizz/EazeGraph/blob/ce5e68ecc70e154f83bbb2fcce1a970db125c1e6/EazeGraphLibrary/src/main/java/org/eazegraph/lib/utils/Utils.java#L165-L170
162,283
blackfizz/EazeGraph
EazeGraphLibrary/src/main/java/org/eazegraph/lib/utils/Utils.java
Utils.intersectsPointWithRectF
public static boolean intersectsPointWithRectF(RectF _Rect, float _X, float _Y) { return _X > _Rect.left && _X < _Rect.right && _Y > _Rect.top && _Y < _Rect.bottom; }
java
public static boolean intersectsPointWithRectF(RectF _Rect, float _X, float _Y) { return _X > _Rect.left && _X < _Rect.right && _Y > _Rect.top && _Y < _Rect.bottom; }
[ "public", "static", "boolean", "intersectsPointWithRectF", "(", "RectF", "_Rect", ",", "float", "_X", ",", "float", "_Y", ")", "{", "return", "_X", ">", "_Rect", ".", "left", "&&", "_X", "<", "_Rect", ".", "right", "&&", "_Y", ">", "_Rect", ".", "top", "&&", "_Y", "<", "_Rect", ".", "bottom", ";", "}" ]
Checks if a point is in the given rectangle. @param _Rect rectangle which is checked @param _X x-coordinate of the point @param _Y y-coordinate of the point @return True if the points intersects with the rectangle.
[ "Checks", "if", "a", "point", "is", "in", "the", "given", "rectangle", "." ]
ce5e68ecc70e154f83bbb2fcce1a970db125c1e6
https://github.com/blackfizz/EazeGraph/blob/ce5e68ecc70e154f83bbb2fcce1a970db125c1e6/EazeGraphLibrary/src/main/java/org/eazegraph/lib/utils/Utils.java#L180-L182
162,284
airbnb/AirMapView
library/src/main/java/com/airbnb/android/airmapview/RuntimePermissionUtils.java
RuntimePermissionUtils.hasSelfPermissions
private static boolean hasSelfPermissions(Context context, String... permissions) { for (String permission : permissions) { if (checkSelfPermission(context, permission) == PackageManager.PERMISSION_GRANTED) { return true; } } return false; }
java
private static boolean hasSelfPermissions(Context context, String... permissions) { for (String permission : permissions) { if (checkSelfPermission(context, permission) == PackageManager.PERMISSION_GRANTED) { return true; } } return false; }
[ "private", "static", "boolean", "hasSelfPermissions", "(", "Context", "context", ",", "String", "...", "permissions", ")", "{", "for", "(", "String", "permission", ":", "permissions", ")", "{", "if", "(", "checkSelfPermission", "(", "context", ",", "permission", ")", "==", "PackageManager", ".", "PERMISSION_GRANTED", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Returns true if the context has access to any given permissions.
[ "Returns", "true", "if", "the", "context", "has", "access", "to", "any", "given", "permissions", "." ]
f715197db2cc2903e8d70f78385d339c3f6a1c3b
https://github.com/airbnb/AirMapView/blob/f715197db2cc2903e8d70f78385d339c3f6a1c3b/library/src/main/java/com/airbnb/android/airmapview/RuntimePermissionUtils.java#L41-L48
162,285
airbnb/AirMapView
library/src/main/java/com/airbnb/android/airmapview/RuntimePermissionUtils.java
RuntimePermissionUtils.shouldShowRequestPermissionRationale
static boolean shouldShowRequestPermissionRationale(Activity activity, String... permissions) { for (String permission : permissions) { if (ActivityCompat.shouldShowRequestPermissionRationale(activity, permission)) { return true; } } return false; }
java
static boolean shouldShowRequestPermissionRationale(Activity activity, String... permissions) { for (String permission : permissions) { if (ActivityCompat.shouldShowRequestPermissionRationale(activity, permission)) { return true; } } return false; }
[ "static", "boolean", "shouldShowRequestPermissionRationale", "(", "Activity", "activity", ",", "String", "...", "permissions", ")", "{", "for", "(", "String", "permission", ":", "permissions", ")", "{", "if", "(", "ActivityCompat", ".", "shouldShowRequestPermissionRationale", "(", "activity", ",", "permission", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Checks given permissions are needed to show rationale. @return returns true if one of the permission is needed to show rationale.
[ "Checks", "given", "permissions", "are", "needed", "to", "show", "rationale", "." ]
f715197db2cc2903e8d70f78385d339c3f6a1c3b
https://github.com/airbnb/AirMapView/blob/f715197db2cc2903e8d70f78385d339c3f6a1c3b/library/src/main/java/com/airbnb/android/airmapview/RuntimePermissionUtils.java#L55-L62
162,286
airbnb/AirMapView
library/src/main/java/com/airbnb/android/airmapview/DefaultAirMapViewBuilder.java
DefaultAirMapViewBuilder.builder
public AirMapViewBuilder builder(AirMapViewTypes mapType) { switch (mapType) { case NATIVE: if (isNativeMapSupported) { return new NativeAirMapViewBuilder(); } break; case WEB: return getWebMapViewBuilder(); } throw new UnsupportedOperationException("Requested map type is not supported"); }
java
public AirMapViewBuilder builder(AirMapViewTypes mapType) { switch (mapType) { case NATIVE: if (isNativeMapSupported) { return new NativeAirMapViewBuilder(); } break; case WEB: return getWebMapViewBuilder(); } throw new UnsupportedOperationException("Requested map type is not supported"); }
[ "public", "AirMapViewBuilder", "builder", "(", "AirMapViewTypes", "mapType", ")", "{", "switch", "(", "mapType", ")", "{", "case", "NATIVE", ":", "if", "(", "isNativeMapSupported", ")", "{", "return", "new", "NativeAirMapViewBuilder", "(", ")", ";", "}", "break", ";", "case", "WEB", ":", "return", "getWebMapViewBuilder", "(", ")", ";", "}", "throw", "new", "UnsupportedOperationException", "(", "\"Requested map type is not supported\"", ")", ";", "}" ]
Returns the AirMapView implementation as requested by the mapType argument. Use this method if you need to request a specific AirMapView implementation that is not necessarily the preferred type. For example, you can use it to explicit request a web-based map implementation. @param mapType Map type for the requested AirMapView implementation. @return An {@link AirMapViewBuilder} for the requested {@link AirMapViewTypes} mapType.
[ "Returns", "the", "AirMapView", "implementation", "as", "requested", "by", "the", "mapType", "argument", ".", "Use", "this", "method", "if", "you", "need", "to", "request", "a", "specific", "AirMapView", "implementation", "that", "is", "not", "necessarily", "the", "preferred", "type", ".", "For", "example", "you", "can", "use", "it", "to", "explicit", "request", "a", "web", "-", "based", "map", "implementation", "." ]
f715197db2cc2903e8d70f78385d339c3f6a1c3b
https://github.com/airbnb/AirMapView/blob/f715197db2cc2903e8d70f78385d339c3f6a1c3b/library/src/main/java/com/airbnb/android/airmapview/DefaultAirMapViewBuilder.java#L60-L71
162,287
airbnb/AirMapView
library/src/main/java/com/airbnb/android/airmapview/DefaultAirMapViewBuilder.java
DefaultAirMapViewBuilder.getWebMapViewBuilder
private AirMapViewBuilder getWebMapViewBuilder() { if (context != null) { try { ApplicationInfo ai = context.getPackageManager() .getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA); Bundle bundle = ai.metaData; String accessToken = bundle.getString("com.mapbox.ACCESS_TOKEN"); String mapId = bundle.getString("com.mapbox.MAP_ID"); if (!TextUtils.isEmpty(accessToken) && !TextUtils.isEmpty(mapId)) { return new MapboxWebMapViewBuilder(accessToken, mapId); } } catch (PackageManager.NameNotFoundException e) { Log.e(TAG, "Failed to load Mapbox access token and map id", e); } } return new WebAirMapViewBuilder(); }
java
private AirMapViewBuilder getWebMapViewBuilder() { if (context != null) { try { ApplicationInfo ai = context.getPackageManager() .getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA); Bundle bundle = ai.metaData; String accessToken = bundle.getString("com.mapbox.ACCESS_TOKEN"); String mapId = bundle.getString("com.mapbox.MAP_ID"); if (!TextUtils.isEmpty(accessToken) && !TextUtils.isEmpty(mapId)) { return new MapboxWebMapViewBuilder(accessToken, mapId); } } catch (PackageManager.NameNotFoundException e) { Log.e(TAG, "Failed to load Mapbox access token and map id", e); } } return new WebAirMapViewBuilder(); }
[ "private", "AirMapViewBuilder", "getWebMapViewBuilder", "(", ")", "{", "if", "(", "context", "!=", "null", ")", "{", "try", "{", "ApplicationInfo", "ai", "=", "context", ".", "getPackageManager", "(", ")", ".", "getApplicationInfo", "(", "context", ".", "getPackageName", "(", ")", ",", "PackageManager", ".", "GET_META_DATA", ")", ";", "Bundle", "bundle", "=", "ai", ".", "metaData", ";", "String", "accessToken", "=", "bundle", ".", "getString", "(", "\"com.mapbox.ACCESS_TOKEN\"", ")", ";", "String", "mapId", "=", "bundle", ".", "getString", "(", "\"com.mapbox.MAP_ID\"", ")", ";", "if", "(", "!", "TextUtils", ".", "isEmpty", "(", "accessToken", ")", "&&", "!", "TextUtils", ".", "isEmpty", "(", "mapId", ")", ")", "{", "return", "new", "MapboxWebMapViewBuilder", "(", "accessToken", ",", "mapId", ")", ";", "}", "}", "catch", "(", "PackageManager", ".", "NameNotFoundException", "e", ")", "{", "Log", ".", "e", "(", "TAG", ",", "\"Failed to load Mapbox access token and map id\"", ",", "e", ")", ";", "}", "}", "return", "new", "WebAirMapViewBuilder", "(", ")", ";", "}" ]
Decides what the Map Web provider should be used and generates a builder for it. @return The AirMapViewBuilder for the selected Map Web provider.
[ "Decides", "what", "the", "Map", "Web", "provider", "should", "be", "used", "and", "generates", "a", "builder", "for", "it", "." ]
f715197db2cc2903e8d70f78385d339c3f6a1c3b
https://github.com/airbnb/AirMapView/blob/f715197db2cc2903e8d70f78385d339c3f6a1c3b/library/src/main/java/com/airbnb/android/airmapview/DefaultAirMapViewBuilder.java#L78-L95
162,288
airbnb/AirMapView
library/src/main/java/com/airbnb/android/airmapview/AirMapView.java
AirMapView.initialize
public void initialize(FragmentManager fragmentManager) { AirMapInterface mapInterface = (AirMapInterface) fragmentManager.findFragmentById(R.id.map_frame); if (mapInterface != null) { initialize(fragmentManager, mapInterface); } else { initialize(fragmentManager, new DefaultAirMapViewBuilder(getContext()).builder().build()); } }
java
public void initialize(FragmentManager fragmentManager) { AirMapInterface mapInterface = (AirMapInterface) fragmentManager.findFragmentById(R.id.map_frame); if (mapInterface != null) { initialize(fragmentManager, mapInterface); } else { initialize(fragmentManager, new DefaultAirMapViewBuilder(getContext()).builder().build()); } }
[ "public", "void", "initialize", "(", "FragmentManager", "fragmentManager", ")", "{", "AirMapInterface", "mapInterface", "=", "(", "AirMapInterface", ")", "fragmentManager", ".", "findFragmentById", "(", "R", ".", "id", ".", "map_frame", ")", ";", "if", "(", "mapInterface", "!=", "null", ")", "{", "initialize", "(", "fragmentManager", ",", "mapInterface", ")", ";", "}", "else", "{", "initialize", "(", "fragmentManager", ",", "new", "DefaultAirMapViewBuilder", "(", "getContext", "(", ")", ")", ".", "builder", "(", ")", ".", "build", "(", ")", ")", ";", "}", "}" ]
Used for initialization of the underlying map provider. @param fragmentManager required for initialization
[ "Used", "for", "initialization", "of", "the", "underlying", "map", "provider", "." ]
f715197db2cc2903e8d70f78385d339c3f6a1c3b
https://github.com/airbnb/AirMapView/blob/f715197db2cc2903e8d70f78385d339c3f6a1c3b/library/src/main/java/com/airbnb/android/airmapview/AirMapView.java#L85-L94
162,289
SQiShER/java-object-diff
src/main/java/de/danielbechler/diff/introspection/PropertyAccessor.java
PropertyAccessor.getFieldAnnotations
private Set<Annotation> getFieldAnnotations(final Class<?> clazz) { try { return new LinkedHashSet<Annotation>(asList(clazz.getDeclaredField(propertyName).getAnnotations())); } catch (final NoSuchFieldException e) { if (clazz.getSuperclass() != null) { return getFieldAnnotations(clazz.getSuperclass()); } else { logger.debug("Cannot find propertyName: {}, declaring class: {}", propertyName, clazz); return new LinkedHashSet<Annotation>(0); } } }
java
private Set<Annotation> getFieldAnnotations(final Class<?> clazz) { try { return new LinkedHashSet<Annotation>(asList(clazz.getDeclaredField(propertyName).getAnnotations())); } catch (final NoSuchFieldException e) { if (clazz.getSuperclass() != null) { return getFieldAnnotations(clazz.getSuperclass()); } else { logger.debug("Cannot find propertyName: {}, declaring class: {}", propertyName, clazz); return new LinkedHashSet<Annotation>(0); } } }
[ "private", "Set", "<", "Annotation", ">", "getFieldAnnotations", "(", "final", "Class", "<", "?", ">", "clazz", ")", "{", "try", "{", "return", "new", "LinkedHashSet", "<", "Annotation", ">", "(", "asList", "(", "clazz", ".", "getDeclaredField", "(", "propertyName", ")", ".", "getAnnotations", "(", ")", ")", ")", ";", "}", "catch", "(", "final", "NoSuchFieldException", "e", ")", "{", "if", "(", "clazz", ".", "getSuperclass", "(", ")", "!=", "null", ")", "{", "return", "getFieldAnnotations", "(", "clazz", ".", "getSuperclass", "(", ")", ")", ";", "}", "else", "{", "logger", ".", "debug", "(", "\"Cannot find propertyName: {}, declaring class: {}\"", ",", "propertyName", ",", "clazz", ")", ";", "return", "new", "LinkedHashSet", "<", "Annotation", ">", "(", "0", ")", ";", "}", "}", "}" ]
Private function to allow looking for the field recursively up the superclasses. @param clazz @return
[ "Private", "function", "to", "allow", "looking", "for", "the", "field", "recursively", "up", "the", "superclasses", "." ]
6f576669d49087f0e825a417cadc3d4c707a4924
https://github.com/SQiShER/java-object-diff/blob/6f576669d49087f0e825a417cadc3d4c707a4924/src/main/java/de/danielbechler/diff/introspection/PropertyAccessor.java#L92-L110
162,290
SQiShER/java-object-diff
src/main/java/de/danielbechler/diff/ObjectDiffer.java
ObjectDiffer.compare
public <T> DiffNode compare(final T working, final T base) { dispatcher.resetInstanceMemory(); try { return dispatcher.dispatch(DiffNode.ROOT, Instances.of(working, base), RootAccessor.getInstance()); } finally { dispatcher.clearInstanceMemory(); } }
java
public <T> DiffNode compare(final T working, final T base) { dispatcher.resetInstanceMemory(); try { return dispatcher.dispatch(DiffNode.ROOT, Instances.of(working, base), RootAccessor.getInstance()); } finally { dispatcher.clearInstanceMemory(); } }
[ "public", "<", "T", ">", "DiffNode", "compare", "(", "final", "T", "working", ",", "final", "T", "base", ")", "{", "dispatcher", ".", "resetInstanceMemory", "(", ")", ";", "try", "{", "return", "dispatcher", ".", "dispatch", "(", "DiffNode", ".", "ROOT", ",", "Instances", ".", "of", "(", "working", ",", "base", ")", ",", "RootAccessor", ".", "getInstance", "(", ")", ")", ";", "}", "finally", "{", "dispatcher", ".", "clearInstanceMemory", "(", ")", ";", "}", "}" ]
Recursively inspects the given objects and returns a node representing their differences. Both objects have be have the same type. @param working This object will be treated as the successor of the `base` object. @param base This object will be treated as the predecessor of the <code>working</code> object. @return A node representing the differences between the given objects.
[ "Recursively", "inspects", "the", "given", "objects", "and", "returns", "a", "node", "representing", "their", "differences", ".", "Both", "objects", "have", "be", "have", "the", "same", "type", "." ]
6f576669d49087f0e825a417cadc3d4c707a4924
https://github.com/SQiShER/java-object-diff/blob/6f576669d49087f0e825a417cadc3d4c707a4924/src/main/java/de/danielbechler/diff/ObjectDiffer.java#L47-L58
162,291
SQiShER/java-object-diff
src/main/java/de/danielbechler/diff/node/DiffNode.java
DiffNode.getChild
public DiffNode getChild(final NodePath nodePath) { if (parentNode != null) { return parentNode.getChild(nodePath.getElementSelectors()); } else { return getChild(nodePath.getElementSelectors()); } }
java
public DiffNode getChild(final NodePath nodePath) { if (parentNode != null) { return parentNode.getChild(nodePath.getElementSelectors()); } else { return getChild(nodePath.getElementSelectors()); } }
[ "public", "DiffNode", "getChild", "(", "final", "NodePath", "nodePath", ")", "{", "if", "(", "parentNode", "!=", "null", ")", "{", "return", "parentNode", ".", "getChild", "(", "nodePath", ".", "getElementSelectors", "(", ")", ")", ";", "}", "else", "{", "return", "getChild", "(", "nodePath", ".", "getElementSelectors", "(", ")", ")", ";", "}", "}" ]
Retrieve a child that matches the given absolute path, starting from the current node. @param nodePath The path from the object root to the requested child node. @return The requested child node or <code>null</code>.
[ "Retrieve", "a", "child", "that", "matches", "the", "given", "absolute", "path", "starting", "from", "the", "current", "node", "." ]
6f576669d49087f0e825a417cadc3d4c707a4924
https://github.com/SQiShER/java-object-diff/blob/6f576669d49087f0e825a417cadc3d4c707a4924/src/main/java/de/danielbechler/diff/node/DiffNode.java#L307-L317
162,292
SQiShER/java-object-diff
src/main/java/de/danielbechler/diff/node/DiffNode.java
DiffNode.addChild
public void addChild(final DiffNode node) { if (node == this) { throw new IllegalArgumentException("Detected attempt to add a node to itself. " + "This would cause inifite loops and must never happen."); } else if (node.isRootNode()) { throw new IllegalArgumentException("Detected attempt to add root node as child. " + "This is not allowed and must be a mistake."); } else if (node.getParentNode() != null && node.getParentNode() != this) { throw new IllegalArgumentException("Detected attempt to add child node that is already the " + "child of another node. Adding nodes multiple times is not allowed, since it could " + "cause infinite loops."); } if (node.getParentNode() == null) { node.setParentNode(this); } children.put(node.getElementSelector(), node); if (state == State.UNTOUCHED && node.hasChanges()) { state = State.CHANGED; } }
java
public void addChild(final DiffNode node) { if (node == this) { throw new IllegalArgumentException("Detected attempt to add a node to itself. " + "This would cause inifite loops and must never happen."); } else if (node.isRootNode()) { throw new IllegalArgumentException("Detected attempt to add root node as child. " + "This is not allowed and must be a mistake."); } else if (node.getParentNode() != null && node.getParentNode() != this) { throw new IllegalArgumentException("Detected attempt to add child node that is already the " + "child of another node. Adding nodes multiple times is not allowed, since it could " + "cause infinite loops."); } if (node.getParentNode() == null) { node.setParentNode(this); } children.put(node.getElementSelector(), node); if (state == State.UNTOUCHED && node.hasChanges()) { state = State.CHANGED; } }
[ "public", "void", "addChild", "(", "final", "DiffNode", "node", ")", "{", "if", "(", "node", "==", "this", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Detected attempt to add a node to itself. \"", "+", "\"This would cause inifite loops and must never happen.\"", ")", ";", "}", "else", "if", "(", "node", ".", "isRootNode", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Detected attempt to add root node as child. \"", "+", "\"This is not allowed and must be a mistake.\"", ")", ";", "}", "else", "if", "(", "node", ".", "getParentNode", "(", ")", "!=", "null", "&&", "node", ".", "getParentNode", "(", ")", "!=", "this", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Detected attempt to add child node that is already the \"", "+", "\"child of another node. Adding nodes multiple times is not allowed, since it could \"", "+", "\"cause infinite loops.\"", ")", ";", "}", "if", "(", "node", ".", "getParentNode", "(", ")", "==", "null", ")", "{", "node", ".", "setParentNode", "(", "this", ")", ";", "}", "children", ".", "put", "(", "node", ".", "getElementSelector", "(", ")", ",", "node", ")", ";", "if", "(", "state", "==", "State", ".", "UNTOUCHED", "&&", "node", ".", "hasChanges", "(", ")", ")", "{", "state", "=", "State", ".", "CHANGED", ";", "}", "}" ]
Adds a child to this node and sets this node as its parent node. @param node The node to add.
[ "Adds", "a", "child", "to", "this", "node", "and", "sets", "this", "node", "as", "its", "parent", "node", "." ]
6f576669d49087f0e825a417cadc3d4c707a4924
https://github.com/SQiShER/java-object-diff/blob/6f576669d49087f0e825a417cadc3d4c707a4924/src/main/java/de/danielbechler/diff/node/DiffNode.java#L364-L391
162,293
SQiShER/java-object-diff
src/main/java/de/danielbechler/diff/node/DiffNode.java
DiffNode.visit
public final void visit(final Visitor visitor) { final Visit visit = new Visit(); try { visit(visitor, visit); } catch (final StopVisitationException ignored) { } }
java
public final void visit(final Visitor visitor) { final Visit visit = new Visit(); try { visit(visitor, visit); } catch (final StopVisitationException ignored) { } }
[ "public", "final", "void", "visit", "(", "final", "Visitor", "visitor", ")", "{", "final", "Visit", "visit", "=", "new", "Visit", "(", ")", ";", "try", "{", "visit", "(", "visitor", ",", "visit", ")", ";", "}", "catch", "(", "final", "StopVisitationException", "ignored", ")", "{", "}", "}" ]
Visit this and all child nodes. @param visitor The visitor to use.
[ "Visit", "this", "and", "all", "child", "nodes", "." ]
6f576669d49087f0e825a417cadc3d4c707a4924
https://github.com/SQiShER/java-object-diff/blob/6f576669d49087f0e825a417cadc3d4c707a4924/src/main/java/de/danielbechler/diff/node/DiffNode.java#L398-L408
162,294
SQiShER/java-object-diff
src/main/java/de/danielbechler/diff/node/DiffNode.java
DiffNode.visitChildren
public final void visitChildren(final Visitor visitor) { for (final DiffNode child : children.values()) { try { child.visit(visitor); } catch (final StopVisitationException e) { return; } } }
java
public final void visitChildren(final Visitor visitor) { for (final DiffNode child : children.values()) { try { child.visit(visitor); } catch (final StopVisitationException e) { return; } } }
[ "public", "final", "void", "visitChildren", "(", "final", "Visitor", "visitor", ")", "{", "for", "(", "final", "DiffNode", "child", ":", "children", ".", "values", "(", ")", ")", "{", "try", "{", "child", ".", "visit", "(", "visitor", ")", ";", "}", "catch", "(", "final", "StopVisitationException", "e", ")", "{", "return", ";", "}", "}", "}" ]
Visit all child nodes but not this one. @param visitor The visitor to use.
[ "Visit", "all", "child", "nodes", "but", "not", "this", "one", "." ]
6f576669d49087f0e825a417cadc3d4c707a4924
https://github.com/SQiShER/java-object-diff/blob/6f576669d49087f0e825a417cadc3d4c707a4924/src/main/java/de/danielbechler/diff/node/DiffNode.java#L435-L448
162,295
SQiShER/java-object-diff
src/main/java/de/danielbechler/diff/node/DiffNode.java
DiffNode.getPropertyAnnotations
public Set<Annotation> getPropertyAnnotations() { if (accessor instanceof PropertyAwareAccessor) { return unmodifiableSet(((PropertyAwareAccessor) accessor).getReadMethodAnnotations()); } return unmodifiableSet(Collections.<Annotation>emptySet()); }
java
public Set<Annotation> getPropertyAnnotations() { if (accessor instanceof PropertyAwareAccessor) { return unmodifiableSet(((PropertyAwareAccessor) accessor).getReadMethodAnnotations()); } return unmodifiableSet(Collections.<Annotation>emptySet()); }
[ "public", "Set", "<", "Annotation", ">", "getPropertyAnnotations", "(", ")", "{", "if", "(", "accessor", "instanceof", "PropertyAwareAccessor", ")", "{", "return", "unmodifiableSet", "(", "(", "(", "PropertyAwareAccessor", ")", "accessor", ")", ".", "getReadMethodAnnotations", "(", ")", ")", ";", "}", "return", "unmodifiableSet", "(", "Collections", ".", "<", "Annotation", ">", "emptySet", "(", ")", ")", ";", "}" ]
If this node represents a bean property this method returns all annotations of its getter. @return A set of annotations of this nodes property getter or an empty set.
[ "If", "this", "node", "represents", "a", "bean", "property", "this", "method", "returns", "all", "annotations", "of", "its", "getter", "." ]
6f576669d49087f0e825a417cadc3d4c707a4924
https://github.com/SQiShER/java-object-diff/blob/6f576669d49087f0e825a417cadc3d4c707a4924/src/main/java/de/danielbechler/diff/node/DiffNode.java#L499-L506
162,296
SQiShER/java-object-diff
src/main/java/de/danielbechler/diff/node/DiffNode.java
DiffNode.setParentNode
protected final void setParentNode(final DiffNode parentNode) { if (this.parentNode != null && this.parentNode != parentNode) { throw new IllegalStateException("The parent of a node cannot be changed, once it's set."); } this.parentNode = parentNode; }
java
protected final void setParentNode(final DiffNode parentNode) { if (this.parentNode != null && this.parentNode != parentNode) { throw new IllegalStateException("The parent of a node cannot be changed, once it's set."); } this.parentNode = parentNode; }
[ "protected", "final", "void", "setParentNode", "(", "final", "DiffNode", "parentNode", ")", "{", "if", "(", "this", ".", "parentNode", "!=", "null", "&&", "this", ".", "parentNode", "!=", "parentNode", ")", "{", "throw", "new", "IllegalStateException", "(", "\"The parent of a node cannot be changed, once it's set.\"", ")", ";", "}", "this", ".", "parentNode", "=", "parentNode", ";", "}" ]
Sets the parent node. @param parentNode The parent of this node. May be null, if this is a root node.
[ "Sets", "the", "parent", "node", "." ]
6f576669d49087f0e825a417cadc3d4c707a4924
https://github.com/SQiShER/java-object-diff/blob/6f576669d49087f0e825a417cadc3d4c707a4924/src/main/java/de/danielbechler/diff/node/DiffNode.java#L616-L623
162,297
uber/tchannel-java
tchannel-hyperbahn/src/main/java/com/uber/tchannel/hyperbahn/api/HyperbahnClient.java
HyperbahnClient.advertise
public TFuture<JsonResponse<AdvertiseResponse>> advertise() { final AdvertiseRequest advertiseRequest = new AdvertiseRequest(); advertiseRequest.addService(service, 0); // TODO: options for hard fail, retries etc. final JsonRequest<AdvertiseRequest> request = new JsonRequest.Builder<AdvertiseRequest>( HYPERBAHN_SERVICE_NAME, HYPERBAHN_ADVERTISE_ENDPOINT ) .setBody(advertiseRequest) .setTimeout(REQUEST_TIMEOUT) .setRetryLimit(4) .build(); final TFuture<JsonResponse<AdvertiseResponse>> future = hyperbahnChannel.send(request); future.addCallback(new TFutureCallback<JsonResponse<AdvertiseResponse>>() { @Override public void onResponse(JsonResponse<AdvertiseResponse> response) { if (response.isError()) { logger.error("Failed to advertise to Hyperbahn: {} - {}", response.getError().getErrorType(), response.getError().getMessage()); } if (destroyed.get()) { return; } scheduleAdvertise(); } }); return future; }
java
public TFuture<JsonResponse<AdvertiseResponse>> advertise() { final AdvertiseRequest advertiseRequest = new AdvertiseRequest(); advertiseRequest.addService(service, 0); // TODO: options for hard fail, retries etc. final JsonRequest<AdvertiseRequest> request = new JsonRequest.Builder<AdvertiseRequest>( HYPERBAHN_SERVICE_NAME, HYPERBAHN_ADVERTISE_ENDPOINT ) .setBody(advertiseRequest) .setTimeout(REQUEST_TIMEOUT) .setRetryLimit(4) .build(); final TFuture<JsonResponse<AdvertiseResponse>> future = hyperbahnChannel.send(request); future.addCallback(new TFutureCallback<JsonResponse<AdvertiseResponse>>() { @Override public void onResponse(JsonResponse<AdvertiseResponse> response) { if (response.isError()) { logger.error("Failed to advertise to Hyperbahn: {} - {}", response.getError().getErrorType(), response.getError().getMessage()); } if (destroyed.get()) { return; } scheduleAdvertise(); } }); return future; }
[ "public", "TFuture", "<", "JsonResponse", "<", "AdvertiseResponse", ">", ">", "advertise", "(", ")", "{", "final", "AdvertiseRequest", "advertiseRequest", "=", "new", "AdvertiseRequest", "(", ")", ";", "advertiseRequest", ".", "addService", "(", "service", ",", "0", ")", ";", "// TODO: options for hard fail, retries etc.", "final", "JsonRequest", "<", "AdvertiseRequest", ">", "request", "=", "new", "JsonRequest", ".", "Builder", "<", "AdvertiseRequest", ">", "(", "HYPERBAHN_SERVICE_NAME", ",", "HYPERBAHN_ADVERTISE_ENDPOINT", ")", ".", "setBody", "(", "advertiseRequest", ")", ".", "setTimeout", "(", "REQUEST_TIMEOUT", ")", ".", "setRetryLimit", "(", "4", ")", ".", "build", "(", ")", ";", "final", "TFuture", "<", "JsonResponse", "<", "AdvertiseResponse", ">", ">", "future", "=", "hyperbahnChannel", ".", "send", "(", "request", ")", ";", "future", ".", "addCallback", "(", "new", "TFutureCallback", "<", "JsonResponse", "<", "AdvertiseResponse", ">", ">", "(", ")", "{", "@", "Override", "public", "void", "onResponse", "(", "JsonResponse", "<", "AdvertiseResponse", ">", "response", ")", "{", "if", "(", "response", ".", "isError", "(", ")", ")", "{", "logger", ".", "error", "(", "\"Failed to advertise to Hyperbahn: {} - {}\"", ",", "response", ".", "getError", "(", ")", ".", "getErrorType", "(", ")", ",", "response", ".", "getError", "(", ")", ".", "getMessage", "(", ")", ")", ";", "}", "if", "(", "destroyed", ".", "get", "(", ")", ")", "{", "return", ";", "}", "scheduleAdvertise", "(", ")", ";", "}", "}", ")", ";", "return", "future", ";", "}" ]
Starts advertising on Hyperbahn at a fixed interval. @return a future that resolves to the response of the first advertise request
[ "Starts", "advertising", "on", "Hyperbahn", "at", "a", "fixed", "interval", "." ]
009cf1e6decc9bbd2daf90eb3401b13c03bfc7e1
https://github.com/uber/tchannel-java/blob/009cf1e6decc9bbd2daf90eb3401b13c03bfc7e1/tchannel-hyperbahn/src/main/java/com/uber/tchannel/hyperbahn/api/HyperbahnClient.java#L91-L125
162,298
bluelinelabs/LoganSquare
core/src/main/java/com/bluelinelabs/logansquare/JsonMapper.java
JsonMapper.parseList
public List<T> parseList(JsonParser jsonParser) throws IOException { List<T> list = new ArrayList<>(); if (jsonParser.getCurrentToken() == JsonToken.START_ARRAY) { while (jsonParser.nextToken() != JsonToken.END_ARRAY) { list.add(parse(jsonParser)); } } return list; }
java
public List<T> parseList(JsonParser jsonParser) throws IOException { List<T> list = new ArrayList<>(); if (jsonParser.getCurrentToken() == JsonToken.START_ARRAY) { while (jsonParser.nextToken() != JsonToken.END_ARRAY) { list.add(parse(jsonParser)); } } return list; }
[ "public", "List", "<", "T", ">", "parseList", "(", "JsonParser", "jsonParser", ")", "throws", "IOException", "{", "List", "<", "T", ">", "list", "=", "new", "ArrayList", "<>", "(", ")", ";", "if", "(", "jsonParser", ".", "getCurrentToken", "(", ")", "==", "JsonToken", ".", "START_ARRAY", ")", "{", "while", "(", "jsonParser", ".", "nextToken", "(", ")", "!=", "JsonToken", ".", "END_ARRAY", ")", "{", "list", ".", "add", "(", "parse", "(", "jsonParser", ")", ")", ";", "}", "}", "return", "list", ";", "}" ]
Parse a list of objects from a JsonParser. @param jsonParser The JsonParser, preconfigured to be at the START_ARRAY token.
[ "Parse", "a", "list", "of", "objects", "from", "a", "JsonParser", "." ]
6c5ec5281fb58d85a99413b7b6f55e9ef18a6e06
https://github.com/bluelinelabs/LoganSquare/blob/6c5ec5281fb58d85a99413b7b6f55e9ef18a6e06/core/src/main/java/com/bluelinelabs/logansquare/JsonMapper.java#L137-L145
162,299
bluelinelabs/LoganSquare
core/src/main/java/com/bluelinelabs/logansquare/JsonMapper.java
JsonMapper.parseMap
public Map<String, T> parseMap(JsonParser jsonParser) throws IOException { HashMap<String, T> map = new HashMap<String, T>(); while (jsonParser.nextToken() != JsonToken.END_OBJECT) { String key = jsonParser.getText(); jsonParser.nextToken(); if (jsonParser.getCurrentToken() == JsonToken.VALUE_NULL) { map.put(key, null); } else{ map.put(key, parse(jsonParser)); } } return map; }
java
public Map<String, T> parseMap(JsonParser jsonParser) throws IOException { HashMap<String, T> map = new HashMap<String, T>(); while (jsonParser.nextToken() != JsonToken.END_OBJECT) { String key = jsonParser.getText(); jsonParser.nextToken(); if (jsonParser.getCurrentToken() == JsonToken.VALUE_NULL) { map.put(key, null); } else{ map.put(key, parse(jsonParser)); } } return map; }
[ "public", "Map", "<", "String", ",", "T", ">", "parseMap", "(", "JsonParser", "jsonParser", ")", "throws", "IOException", "{", "HashMap", "<", "String", ",", "T", ">", "map", "=", "new", "HashMap", "<", "String", ",", "T", ">", "(", ")", ";", "while", "(", "jsonParser", ".", "nextToken", "(", ")", "!=", "JsonToken", ".", "END_OBJECT", ")", "{", "String", "key", "=", "jsonParser", ".", "getText", "(", ")", ";", "jsonParser", ".", "nextToken", "(", ")", ";", "if", "(", "jsonParser", ".", "getCurrentToken", "(", ")", "==", "JsonToken", ".", "VALUE_NULL", ")", "{", "map", ".", "put", "(", "key", ",", "null", ")", ";", "}", "else", "{", "map", ".", "put", "(", "key", ",", "parse", "(", "jsonParser", ")", ")", ";", "}", "}", "return", "map", ";", "}" ]
Parse a map of objects from a JsonParser. @param jsonParser The JsonParser, preconfigured to be at the START_ARRAY token.
[ "Parse", "a", "map", "of", "objects", "from", "a", "JsonParser", "." ]
6c5ec5281fb58d85a99413b7b6f55e9ef18a6e06
https://github.com/bluelinelabs/LoganSquare/blob/6c5ec5281fb58d85a99413b7b6f55e9ef18a6e06/core/src/main/java/com/bluelinelabs/logansquare/JsonMapper.java#L196-L208