Search in sources :

Example 1 with Nullable

use of javax.annotation.Nullable in project buck by facebook.

the class AdbHelper method createAdb.

/**
   * Creates connection to adb and waits for this connection to be initialized
   * and receive initial list of devices.
   */
@Nullable
@SuppressWarnings("PMD.EmptyCatchBlock")
private AndroidDebugBridge createAdb(ExecutionContext context) throws InterruptedException {
    DdmPreferences.setTimeOut(60000);
    try {
        AndroidDebugBridge.init(/* clientSupport */
        false);
    } catch (IllegalStateException ex) {
    // ADB was already initialized, we're fine, so just ignore.
    }
    AndroidDebugBridge adb = AndroidDebugBridge.createBridge(context.getPathToAdbExecutable(), false);
    if (adb == null) {
        console.printBuildFailure("Failed to connect to adb. Make sure adb server is running.");
        return null;
    }
    long start = System.currentTimeMillis();
    while (!isAdbInitialized(adb)) {
        long timeLeft = start + ADB_CONNECT_TIMEOUT_MS - System.currentTimeMillis();
        if (timeLeft <= 0) {
            break;
        }
        Thread.sleep(ADB_CONNECT_TIME_STEP_MS);
    }
    return isAdbInitialized(adb) ? adb : null;
}
Also used : AndroidDebugBridge(com.android.ddmlib.AndroidDebugBridge) Nullable(javax.annotation.Nullable)

Example 2 with Nullable

use of javax.annotation.Nullable in project buck by facebook.

the class AdbHelper method deviceUninstallPackage.

/**
   * Modified version of <a href="http://fburl.com/8840769">Device.uninstallPackage()</a>.
   *
   * @param device an {@link IDevice}
   * @param packageName application package name
   * @param keepData  true if user data is to be kept
   * @return error message or null if successful
   * @throws InstallException
   */
@Nullable
private String deviceUninstallPackage(IDevice device, String packageName, boolean keepData) throws InstallException {
    try {
        AdbHelper.ErrorParsingReceiver receiver = new AdbHelper.ErrorParsingReceiver() {

            @Override
            @Nullable
            protected String matchForError(String line) {
                return line.toLowerCase(Locale.US).contains("failure") ? line : null;
            }
        };
        device.executeShellCommand("pm uninstall " + (keepData ? "-k " : "") + packageName, receiver, AdbHelper.INSTALL_TIMEOUT, TimeUnit.MILLISECONDS);
        return receiver.getErrorMessage();
    } catch (AdbCommandRejectedException | IOException | ShellCommandUnresponsiveException | TimeoutException e) {
        throw new InstallException(e);
    }
}
Also used : ShellCommandUnresponsiveException(com.android.ddmlib.ShellCommandUnresponsiveException) AdbCommandRejectedException(com.android.ddmlib.AdbCommandRejectedException) IOException(java.io.IOException) InstallException(com.android.ddmlib.InstallException) TimeoutException(com.android.ddmlib.TimeoutException) Nullable(javax.annotation.Nullable)

Example 3 with Nullable

use of javax.annotation.Nullable in project buck by facebook.

the class ResolveAliasHelper method validateBuildTargetForFullyQualifiedTarget.

/**
   * Verify that the given target is a valid full-qualified (non-alias) target.
   */
@Nullable
static String validateBuildTargetForFullyQualifiedTarget(CommandRunnerParams params, ListeningExecutorService executor, boolean enableProfiling, String target, Parser parser) {
    BuildTarget buildTarget = getBuildTargetForFullyQualifiedTarget(params.getBuckConfig(), target);
    Cell owningCell = params.getCell().getCell(buildTarget);
    Path buildFile;
    try {
        buildFile = owningCell.getAbsolutePathToBuildFile(buildTarget);
    } catch (Cell.MissingBuildFileException e) {
        throw new HumanReadableException(e);
    }
    // Get all valid targets in our target directory by reading the build file.
    ImmutableSet<TargetNode<?, ?>> targetNodes;
    try {
        targetNodes = parser.getAllTargetNodes(params.getBuckEventBus(), owningCell, enableProfiling, executor, buildFile);
    } catch (BuildFileParseException e) {
        throw new HumanReadableException(e);
    }
    // Check that the given target is a valid target.
    for (TargetNode<?, ?> candidate : targetNodes) {
        if (candidate.getBuildTarget().equals(buildTarget)) {
            return buildTarget.getFullyQualifiedName();
        }
    }
    return null;
}
Also used : Path(java.nio.file.Path) TargetNode(com.facebook.buck.rules.TargetNode) BuildTarget(com.facebook.buck.model.BuildTarget) HumanReadableException(com.facebook.buck.util.HumanReadableException) Cell(com.facebook.buck.rules.Cell) BuildFileParseException(com.facebook.buck.json.BuildFileParseException) Nullable(javax.annotation.Nullable)

Example 4 with Nullable

use of javax.annotation.Nullable in project crate by crate.

the class ExpressionAnalyzer method getQuotedSubscriptLiteral.

@Nullable
protected static String getQuotedSubscriptLiteral(String nodeName) {
    Matcher matcher = SUBSCRIPT_SPLIT_PATTERN.matcher(nodeName);
    if (matcher.matches()) {
        StringBuilder quoted = new StringBuilder();
        String group1 = matcher.group(1);
        if (!group1.isEmpty()) {
            quoted.append("\"").append(group1).append("\"");
        } else {
            quoted.append(group1);
        }
        String group2 = matcher.group(2);
        String group3 = matcher.group(3);
        if (!group2.isEmpty() && !group3.isEmpty()) {
            quoted.append(matcher.group(2));
            quoted.append("\"").append(group3).append("\"");
        } else if (!group2.isEmpty() && group3.isEmpty()) {
            return null;
        }
        quoted.append(matcher.group(4));
        return quoted.toString();
    } else {
        return null;
    }
}
Also used : Matcher(java.util.regex.Matcher) Nullable(javax.annotation.Nullable)

Example 5 with Nullable

use of javax.annotation.Nullable in project crate by crate.

the class OrderBy method subset.

/**
     * Create a new OrderBy with symbols that match the predicate
     */
@Nullable
public OrderBy subset(Predicate<? super Symbol> predicate) {
    List<Integer> subSet = new ArrayList<>();
    Integer i = 0;
    for (Symbol orderBySymbol : orderBySymbols) {
        if (predicate.apply(orderBySymbol)) {
            subSet.add(i);
        }
        i++;
    }
    if (subSet.isEmpty()) {
        return null;
    }
    return subset(subSet);
}
Also used : Symbol(io.crate.analyze.symbol.Symbol) Nullable(javax.annotation.Nullable)

Aggregations

Nullable (javax.annotation.Nullable)3367 List (java.util.List)383 IOException (java.io.IOException)315 Map (java.util.Map)312 ArrayList (java.util.ArrayList)301 Nonnull (javax.annotation.Nonnull)270 File (java.io.File)228 Collectors (java.util.stream.Collectors)195 HashMap (java.util.HashMap)173 Arrays (java.util.Arrays)168 Test (org.junit.Test)137 ItemStack (net.minecraft.item.ItemStack)122 Logger (org.slf4j.Logger)122 LoggerFactory (org.slf4j.LoggerFactory)120 ImmutableList (com.google.common.collect.ImmutableList)116 Layer (com.simiacryptus.mindseye.lang.Layer)116 Tensor (com.simiacryptus.mindseye.lang.Tensor)116 Set (java.util.Set)116 Result (com.simiacryptus.mindseye.lang.Result)104 Function (com.google.common.base.Function)103