java类com.google.common.collect.ObjectArrays的实例源码

CaliperRunner.java 文件源码 项目:vogar 阅读 36 收藏 0 点赞 0 评论 0
public boolean run(String actionName, Profiler profiler,
        String[] args) {
    monitor.outcomeStarted(this, testClass.getName(), actionName);
    String[] arguments = ObjectArrays.concat(testClass.getName(), args);
    if (profile) {
        arguments = ObjectArrays.concat("--debug", arguments);
    }
    try {
        if (profiler != null) {
            profiler.start();
        }
        new Runner().run(arguments);
    } catch (Exception ex) {
        ex.printStackTrace();
    } finally {
        if (profiler != null) {
            profiler.stop();
        }
    }
    monitor.outcomeFinished(Result.SUCCESS);
    return true;
}
SimpleTimeLimiter.java 文件源码 项目:guava-mock 阅读 26 收藏 0 点赞 0 评论 0
private static Exception throwCause(Exception e, boolean combineStackTraces) throws Exception {
  Throwable cause = e.getCause();
  if (cause == null) {
    throw e;
  }
  if (combineStackTraces) {
    StackTraceElement[] combined =
        ObjectArrays.concat(cause.getStackTrace(), e.getStackTrace(), StackTraceElement.class);
    cause.setStackTrace(combined);
  }
  if (cause instanceof Exception) {
    throw (Exception) cause;
  }
  if (cause instanceof Error) {
    throw (Error) cause;
  }
  // The cause is a weird kind of Throwable, so throw the outer exception.
  throw e;
}
OptimizedFlywayTestExecutionListener.java 文件源码 项目:embedded-database-spring-test 阅读 23 收藏 0 点赞 0 评论 0
private static void prepareDataSourceContext(FlywayDataSourceContext dataSourceContext, Flyway flywayBean, FlywayTest annotation) throws Exception {
    if (isAppendable(flywayBean, annotation)) {
        dataSourceContext.reload(flywayBean);
    } else {
        String[] oldLocations = flywayBean.getLocations();
        try {
            if (annotation.overrideLocations()) {
                flywayBean.setLocations(annotation.locationsForMigrate());
            } else {
                flywayBean.setLocations(ObjectArrays.concat(oldLocations, annotation.locationsForMigrate(), String.class));
            }
            dataSourceContext.reload(flywayBean);
        } finally {
            flywayBean.setLocations(oldLocations);
        }
    }
}
SimpleTimeLimiter.java 文件源码 项目:googles-monorepo-demo 阅读 28 收藏 0 点赞 0 评论 0
private static Exception throwCause(Exception e, boolean combineStackTraces) throws Exception {
  Throwable cause = e.getCause();
  if (cause == null) {
    throw e;
  }
  if (combineStackTraces) {
    StackTraceElement[] combined =
        ObjectArrays.concat(cause.getStackTrace(), e.getStackTrace(), StackTraceElement.class);
    cause.setStackTrace(combined);
  }
  if (cause instanceof Exception) {
    throw (Exception) cause;
  }
  if (cause instanceof Error) {
    throw (Error) cause;
  }
  // The cause is a weird kind of Throwable, so throw the outer exception.
  throw e;
}
ModDiscoverer.java 文件源码 项目:CustomWorldGen 阅读 29 收藏 0 点赞 0 评论 0
public void findModDirMods(File modsDir, File[] supplementalModFileCandidates)
{
    File[] modList = FileListHelper.sortFileList(modsDir, null);
    modList = FileListHelper.sortFileList(ObjectArrays.concat(modList, supplementalModFileCandidates, File.class));
    for (File modFile : modList)
    {
        // skip loaded coremods
        if (CoreModManager.getIgnoredMods().contains(modFile.getName()))
        {
            FMLLog.finer("Skipping already parsed coremod or tweaker %s", modFile.getName());
        }
        else if (modFile.isDirectory())
        {
            FMLLog.fine("Found a candidate mod directory %s", modFile.getName());
            addCandidate(new ModCandidate(modFile, modFile, ContainerType.DIR));
        }
        else
        {
            Matcher matcher = zipJar.matcher(modFile.getName());

            if (matcher.matches())
            {
                FMLLog.fine("Found a candidate zip or jar file %s", matcher.group(0));
                addCandidate(new ModCandidate(modFile, modFile, ContainerType.JAR));
            }
            else
            {
                FMLLog.fine("Ignoring unknown file %s in mods directory", modFile.getName());
            }
        }
    }
}
BdioMain.java 文件源码 项目:bdio 阅读 24 收藏 0 点赞 0 评论 0
@SuppressWarnings("MissingSuperCall")
@Override
protected Tool parseArguments(String[] args) {
    commandName = Iterables.getFirst(arguments(args), Command.help.name());
    commandArgs = removeFirst(commandName, args);

    // Special behavior for help
    if (options(args).contains("--help")) {
        commandArgs = removeFirst("--help", ObjectArrays.concat(commandName, commandArgs));
        commandName = Command.help.name();
        args = removeFirst("--help", args);
    }

    // Display our version number and stop (note that commands can still override '--version')
    if (options(args).contains("--version")
            && (commandName.equals(Command.help.name()) || isBefore("--version", commandName, args))) {
        printVersion();
        return doNothing();
    }

    // Do not delegate to the super, allow the commands to do the parsing
    return this;
}
SimpleTimeLimiter.java 文件源码 项目:codebuff 阅读 23 收藏 0 点赞 0 评论 0
private static Exception throwCause(Exception e, boolean combineStackTraces) throws Exception {
  Throwable cause = e.getCause();
  if (cause == null) {
    throw e;
  }
  if (combineStackTraces) {
    StackTraceElement[] combined = ObjectArrays.concat(cause.getStackTrace(), e.getStackTrace(), StackTraceElement.class);
    cause.setStackTrace(combined);
  }
  if (cause instanceof Exception) {
    throw (Exception) cause;
  }
  if (cause instanceof Error) {
    throw (Error) cause;
  }
  // The cause is a weird kind of Throwable, so throw the outer exception.
  throw e;
}
SimpleTimeLimiter.java 文件源码 项目:codebuff 阅读 25 收藏 0 点赞 0 评论 0
private static Exception throwCause(Exception e, boolean combineStackTraces) throws Exception {
  Throwable cause = e.getCause();
  if (cause == null) {
    throw e;
  }
  if (combineStackTraces) {
    StackTraceElement[] combined = ObjectArrays.concat(cause.getStackTrace(), e.getStackTrace(), StackTraceElement.class);
    cause.setStackTrace(combined);
  }
  if (cause instanceof Exception) {
    throw (Exception) cause;
  }
  if (cause instanceof Error) {
    throw (Error) cause;
  }
  // The cause is a weird kind of Throwable, so throw the outer exception.
  throw e;
}
SimpleTimeLimiter.java 文件源码 项目:codebuff 阅读 31 收藏 0 点赞 0 评论 0
private static Exception throwCause(Exception e, boolean combineStackTraces) throws Exception {
  Throwable cause = e.getCause();
  if (cause == null) {
    throw e;
  }
  if (combineStackTraces) {
    StackTraceElement[] combined = ObjectArrays.concat(cause.getStackTrace(), e.getStackTrace(), StackTraceElement.class);
    cause.setStackTrace(combined);
  }
  if (cause instanceof Exception) {
    throw (Exception) cause;
  }
  if (cause instanceof Error) {
    throw (Error) cause;
  }
  // The cause is a weird kind of Throwable, so throw the outer exception.
  throw e;
}
SimpleTimeLimiter.java 文件源码 项目:codebuff 阅读 27 收藏 0 点赞 0 评论 0
private static Exception throwCause(Exception e, boolean combineStackTraces) throws Exception {
  Throwable cause = e.getCause();
  if (cause == null) {
    throw e;
  }
  if (combineStackTraces) {
    StackTraceElement[] combined = ObjectArrays.concat(cause.getStackTrace(), e.getStackTrace(), StackTraceElement.class);
    cause.setStackTrace(combined);
  }
  if (cause instanceof Exception) {
    throw (Exception) cause;
  }
  if (cause instanceof Error) {
    throw (Error) cause;
  }
  // The cause is a weird kind of Throwable, so throw the outer exception.
  throw e;
}
SimpleTimeLimiter.java 文件源码 项目:codebuff 阅读 24 收藏 0 点赞 0 评论 0
private static Exception throwCause(Exception e, boolean combineStackTraces) throws Exception {
  Throwable cause = e.getCause();
  if (cause == null) {
    throw e;
  }
  if (combineStackTraces) {
    StackTraceElement[] combined =
        ObjectArrays.concat(cause.getStackTrace(), e.getStackTrace(), StackTraceElement.class);
    cause.setStackTrace(combined);
  }
  if (cause instanceof Exception) {
    throw (Exception) cause;
  }
  if (cause instanceof Error) {
    throw (Error) cause;
  }
  // The cause is a weird kind of Throwable, so throw the outer exception.
  throw e;
}
SlaveController.java 文件源码 项目:SecureSmartHome 阅读 30 收藏 0 点赞 0 评论 0
/**
 * Add a new Module.
 *
 * @param module Module to add.
 */
public void addModule(Module module) throws DatabaseControllerException {
    try {
        //Notice: Changed order of values to avoid having to concat twice!
        databaseConnector.executeSql("insert into "
                        + DatabaseContract.ElectronicModule.TABLE_NAME + " ("
                        + DatabaseContract.ElectronicModule.COLUMN_GPIO_PIN + ", "
                        + DatabaseContract.ElectronicModule.COLUMN_USB_PORT + ", "
                        + DatabaseContract.ElectronicModule.COLUMN_WLAN_PORT + ", "
                        + DatabaseContract.ElectronicModule.COLUMN_WLAN_USERNAME + ", "
                        + DatabaseContract.ElectronicModule.COLUMN_WLAN_PASSWORD + ", "
                        + DatabaseContract.ElectronicModule.COLUMN_WLAN_IP + ", "
                        + DatabaseContract.ElectronicModule.COLUMN_MODULE_TYPE + ", "
                        + DatabaseContract.ElectronicModule.COLUMN_CONNECTOR_TYPE + ", "
                        + DatabaseContract.ElectronicModule.COLUMN_SLAVE_ID + ", "
                        + DatabaseContract.ElectronicModule.COLUMN_NAME + ") values "
                        + "(?, ?, ?, ?, ?, ?, ?, ?, (" + DatabaseContract.SqlQueries.SLAVE_ID_FROM_FINGERPRINT_SQL_QUERY + "), ?)",
                ObjectArrays.concat(
                        createCombinedModulesAccessInformationFromSingle(module.getModuleAccessPoint()),
                        new String[]{module.getModuleType().toString(), module.getModuleAccessPoint().getType(),
                                module.getAtSlave().getIDString(), module.getName()}, String.class));
    } catch (SQLiteConstraintException sqlce) {
        throw new DatabaseControllerException("The given Slave does not exist in the database"
                + " or the name is already used by another Module", sqlce);
    }
}
LatestActionDAOMysqlImpl.java 文件源码 项目:easyrec_major 阅读 28 收藏 0 点赞 0 评论 0
public int getLatestRatingPageCount(int tenantId, int itemTypeId, Date since) {
    final StringBuilder query = new StringBuilder("SELECT CEIL(count(*) / ?)");
    query.append("\n");
    query.append("FROM ").append(DEFAULT_TABLE_NAME).append("\n");
    query.append("WHERE ");
    query.append(DEFAULT_TENANT_COLUMN_NAME).append(" = ? AND ");
    query.append(DEFAULT_ITEM_TYPE_COLUMN_NAME).append(" = ?");

    Object[] args = new Object[]{PAGE_SIZE, tenantId, itemTypeId};
    int[] argt = new int[]{Types.INTEGER, Types.INTEGER, Types.INTEGER};

    if (since != null) {
        query.append(" AND ").append(DEFAULT_ACTION_TIME_COLUMN_NAME).append(" > ?");

        args = ObjectArrays.concat(args, since);
        argt = Ints.concat(argt, new int[]{Types.TIMESTAMP});
    }

    int count = getJdbcTemplate().queryForInt(query.toString(), args, argt);

    return count;
}
AbstractBaseRecommendationDAOMysqlImpl.java 文件源码 项目:easyrec_major 阅读 27 收藏 0 点赞 0 评论 0
protected String getRecommendationIteratorQueryString(TimeConstraintVO timeConstraints, ArgsAndTypesHolder holder) {
    StringBuilder query = new StringBuilder("SELECT * FROM ");
    query.append(DEFAULT_TABLE_NAME);

    if (timeConstraints.getDateFrom() != null) {
        query.append(" WHERE ");
        query.append(DEFAULT_RECOMMENDATION_TIME_COLUMN_NAME);
        query.append(" >= ?");
        holder.getArgs()[0] = timeConstraints.getDateFrom();
        if (timeConstraints.getDateTo() != null) {
            query.append(" AND ");
            query.append(DEFAULT_RECOMMENDATION_TIME_COLUMN_NAME);
            query.append(" <= ?");
            holder.setArgs(ObjectArrays.concat(holder.getArgs(), timeConstraints.getDateTo()));
            holder.setArgTypes(Ints.concat(holder.getArgTypes(), new int[] { Types.TIMESTAMP }));
        }
    } else {
        query.append(" WHERE ");
        query.append(DEFAULT_RECOMMENDATION_TIME_COLUMN_NAME);
        query.append(" <= ?");
        holder.getArgs()[0] = timeConstraints.getDateTo();
    }

    return query.toString();
}
ArrayUtils.java 文件源码 项目:dsl-devkit 阅读 25 收藏 0 点赞 0 评论 0
/**
 * Removes the first occurrence of a given value from an array, if it is present in the array.
 * The array is assumed to be unordered.
 *
 * @param array
 *          to remove the value from; may be {@code null}
 * @param value
 *          to remove; must not be {@code null}
 * @return an array not containing the first occurrence of value, but containing all other elements of
 *         the original array. If the original array does not contain the given value, the returned
 *         array is == identical to the array passed in.
 */
public T[] remove(final T[] array, final T value) {
  if (array == null) {
    return null;
  }
  int i = find(array, value);
  if (i == 0 && array.length == 1) {
    return null;
  }
  if (i >= 0) {
    // Found it: remove value. i is guaranteed to be < array.length here.
    T[] newArray = ObjectArrays.newArray(componentType, array.length - 1);
    if (i > 0) {
      System.arraycopy(array, 0, newArray, 0, i);
    }
    if (i + 1 < array.length) {
      System.arraycopy(array, i + 1, newArray, i, array.length - i - 1);
    }
    return newArray;
  }
  return array;
}
CommonProxy.java 文件源码 项目:TerrafirmaPunk-Tweaks 阅读 37 收藏 0 点赞 0 评论 0
private static OreSpawnData getOreData(String category, String type, String size, String blockName, int meta, int rarity, String[] rocks, int min, int max, int v, int h)
{
    oresConfig = TFC_ConfigFiles.getOresConfig();
    String[] ALLOWED_TYPES = new String[] { "default", "veins" };
    String[] ALLOWED_SIZES = new String[] { "small", "medium", "large" };
    String[] ALLOWED_BASE_ROCKS = ObjectArrays.concat(Global.STONE_ALL, new String[] { "igneous intrusive", "igneous extrusive", "sedimentary", "metamorphic" }, String.class);

    return new OreSpawnData(
            oresConfig.get(category, "type", type).setValidValues(ALLOWED_TYPES).getString(),
            oresConfig.get(category, "size", size).setValidValues(ALLOWED_SIZES).getString(),
            oresConfig.get(category, "oreName", blockName).getString(),
            oresConfig.get(category, "oreMeta", meta).getInt(),
            oresConfig.get(category, "rarity", rarity).getInt(),
            oresConfig.get(category, "baseRocks", rocks).setValidValues(ALLOWED_BASE_ROCKS).getStringList(),
            oresConfig.get(category, "Minimum Height", min).getInt(),
            oresConfig.get(category, "Maximum Height", max).getInt(),
            oresConfig.get(category, "Vertical Density", v).getInt(),
            oresConfig.get(category, "Horizontal Density", h).getInt()
    );
}
RepositoryPullRequestDaoImpl.java 文件源码 项目:jira-dvcs-connector 阅读 23 收藏 0 点赞 0 评论 0
/**
 * {@inheritDoc}
 */
@Override
public void unlinkCommits(Repository domain, RepositoryPullRequestMapping request, Iterable<? extends RepositoryCommitMapping> commits)
{
    Iterable<Integer> commitIds = Iterables.transform(commits, new Function<RepositoryCommitMapping, Integer>()
    {
        @Override
        public Integer apply(final RepositoryCommitMapping repositoryCommitMapping)
        {
            return repositoryCommitMapping.getID();
        }
    });

    final String baseWhereClause = ActiveObjectsUtils.renderListOperator(RepositoryPullRequestToCommitMapping.COMMIT, "IN", "OR", commitIds);

    Query query = Query.select().where(RepositoryPullRequestToCommitMapping.REQUEST_ID + " = ? AND "
            + baseWhereClause, ObjectArrays.concat(request.getID(), Iterables.toArray(commitIds, Object.class)));
    ActiveObjectsUtils.delete(activeObjects, RepositoryPullRequestToCommitMapping.class, query);
}
RepositoryPullRequestDaoImpl.java 文件源码 项目:jira-dvcs-connector 阅读 24 收藏 0 点赞 0 评论 0
@Override
public List<RepositoryPullRequestMapping> getByIssueKeys(final Iterable<String> issueKeys)
{
    Collection<Integer> prIds = findRelatedPullRequests(issueKeys);
    if (prIds.isEmpty())
    {
        return Lists.newArrayList();
    }
    final String whereClause = ActiveObjectsUtils.renderListOperator("pr.ID", "IN", "OR", prIds).toString();
    final Object [] params = ObjectArrays.concat(new Object[]{Boolean.FALSE, Boolean.TRUE}, prIds.toArray(), Object.class);

    Query select = Query.select()
            .alias(RepositoryMapping.class, "repo")
            .alias(RepositoryPullRequestMapping.class, "pr")
            .join(RepositoryMapping.class, "repo.ID = pr." + RepositoryPullRequestMapping.TO_REPO_ID)
            .where("repo." + RepositoryMapping.DELETED + " = ? AND repo." + RepositoryMapping.LINKED + " = ? AND " + whereClause, params);
    return Arrays.asList(activeObjects.find(RepositoryPullRequestMapping.class, select));
}
RepositoryPullRequestDaoImpl.java 文件源码 项目:jira-dvcs-connector 阅读 24 收藏 0 点赞 0 评论 0
@Override
public List<RepositoryPullRequestMapping> getByIssueKeys(final Iterable<String> issueKeys, final String dvcsType)
{
    Collection<Integer> prIds = findRelatedPullRequests(issueKeys);

    if (prIds.isEmpty())
    {
        return Lists.newArrayList();
    }

    final String whereClause = ActiveObjectsUtils.renderListOperator("pr.ID", "IN", "OR", prIds).toString();
    final Object [] params = ObjectArrays.concat(new Object[] { dvcsType, Boolean.FALSE, Boolean.TRUE }, prIds.toArray(), Object.class);

    Query select = Query.select()
            .alias(RepositoryMapping.class, "repo")
            .alias(RepositoryPullRequestMapping.class, "pr")
            .alias(OrganizationMapping.class, "org")
            .join(RepositoryMapping.class, "repo.ID = pr." + RepositoryPullRequestMapping.TO_REPO_ID)
            .join(OrganizationMapping.class, "repo." + RepositoryMapping.ORGANIZATION_ID + " = org.ID")
            .where("org." + OrganizationMapping.DVCS_TYPE + " = ? AND repo." + RepositoryMapping.DELETED + " = ? AND repo." + RepositoryMapping.LINKED + " = ? AND " + whereClause, params);

    return Arrays.asList(activeObjects.find(RepositoryPullRequestMapping.class, select));
}
SimpleTimeLimiter.java 文件源码 项目:bts 阅读 30 收藏 0 点赞 0 评论 0
private static Exception throwCause(Exception e, boolean combineStackTraces)
    throws Exception {
  Throwable cause = e.getCause();
  if (cause == null) {
    throw e;
  }
  if (combineStackTraces) {
    StackTraceElement[] combined = ObjectArrays.concat(cause.getStackTrace(),
        e.getStackTrace(), StackTraceElement.class);
    cause.setStackTrace(combined);
  }
  if (cause instanceof Exception) {
    throw (Exception) cause;
  }
  if (cause instanceof Error) {
    throw (Error) cause;
  }
  // The cause is a weird kind of Throwable, so throw the outer exception.
  throw e;
}
CfUsersService.java 文件源码 项目:user-management 阅读 25 收藏 0 点赞 0 评论 0
@Override
public Optional<User> addOrgUser(UserRequest userRequest, UUID orgGuid, String currentUser) {
    Optional<UserIdNamePair> idNamePair = uaaClient.findUserIdByName(userRequest.getUsername());
    if(!idNamePair.isPresent()) {
        inviteUserToOrg(userRequest.getUsername(), currentUser, orgGuid,
                ImmutableSet.<Role>builder()
                        .addAll(userRequest.getRoles())
                        .add(Role.USERS)
                        .build());
    }

    return idNamePair.map(pair -> {
        UUID userGuid = pair.getGuid();
        Role[] roles = ObjectArrays
                .concat(userRequest.getRoles().toArray(new Role[]{}), Role.USERS);
        assignOrgRolesToUser(userGuid, orgGuid, roles);
        return new User(userRequest.getUsername(), userGuid, userRequest.getRoles(), orgGuid);
    });
}
SimpleTimeLimiter.java 文件源码 项目:j2objc 阅读 28 收藏 0 点赞 0 评论 0
private static Exception throwCause(Exception e, boolean combineStackTraces)
    throws Exception {
  Throwable cause = e.getCause();
  if (cause == null) {
    throw e;
  }
  if (combineStackTraces) {
    StackTraceElement[] combined = ObjectArrays.concat(cause.getStackTrace(),
        e.getStackTrace(), StackTraceElement.class);
    cause.setStackTrace(combined);
  }
  if (cause instanceof Exception) {
    throw (Exception) cause;
  }
  if (cause instanceof Error) {
    throw (Error) cause;
  }
  // The cause is a weird kind of Throwable, so throw the outer exception.
  throw e;
}
SimpleTimeLimiter.java 文件源码 项目:guava-libraries 阅读 28 收藏 0 点赞 0 评论 0
private static Exception throwCause(Exception e, boolean combineStackTraces)
    throws Exception {
  Throwable cause = e.getCause();
  if (cause == null) {
    throw e;
  }
  if (combineStackTraces) {
    StackTraceElement[] combined = ObjectArrays.concat(cause.getStackTrace(),
        e.getStackTrace(), StackTraceElement.class);
    cause.setStackTrace(combined);
  }
  if (cause instanceof Exception) {
    throw (Exception) cause;
  }
  if (cause instanceof Error) {
    throw (Error) cause;
  }
  // The cause is a weird kind of Throwable, so throw the outer exception.
  throw e;
}
Data.java 文件源码 项目:MCProfiler 阅读 30 收藏 0 点赞 0 评论 0
/**
 * Returns a String of all the UUIDs, comma separated, of the player's UUID given.
 *
 * @param pUUID
 *            Player UUID
 * @param isRecursive
 *            Is the search recursive?
 * @return the alt accounts of the player, or null if an error occurs.
 */
public BaseAccount[] getAltsOfPlayer(final UUID pUUID, final boolean isRecursive) {
    ResultSet rs;
    BaseAccount[] array = new BaseAccount[0];
    try {
        rs = getResultSet("SELECT * FROM " + s.dbPrefix + "iplog WHERE uuid = \"" + pUUID.toString() + "\";");
        while (rs.next()) {
            final ResultSet ipSet = getResultSet("SELECT * FROM " + s.dbPrefix + "iplog WHERE ip = \"" + rs.getString("ip") + "\";");
            while (ipSet.next())
                array = ObjectArrays.concat(array, new UUIDAlt(UUID.fromString(ipSet.getString("uuid")), ipSet.getString("ip")));
            ipSet.close();
        }
        rs.close();
        if (isRecursive)
            return format(recursivePlayerSearch(array));
        return format(array);
    } catch (final SQLException e) {
        error(e);
        return null;
    }
}
NatureUtils.java 文件源码 项目:CooperateModelingEnvironment 阅读 25 收藏 0 点赞 0 评论 0
public static IStatus addNatureToProjectDescription(IProjectDescription description, String natureId) {
    String[] natureIds = description.getNatureIds();

    // calculate new nature IDs
    if (Arrays.asList(natureIds).contains(natureId)) {
        return Status.OK_STATUS;
    }       
    natureIds = ObjectArrays.concat(description.getNatureIds(), natureId);

    // validate the natures
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    IStatus validationResult = workspace.validateNatureSet(natureIds);

    if (validationResult.getCode() == IStatus.OK) {
        description.setNatureIds(natureIds);
    }

    return validationResult;
}
SimpleTimeLimiter.java 文件源码 项目:guava 阅读 30 收藏 0 点赞 0 评论 0
private static Exception throwCause(Exception e, boolean combineStackTraces) throws Exception {
  Throwable cause = e.getCause();
  if (cause == null) {
    throw e;
  }
  if (combineStackTraces) {
    StackTraceElement[] combined =
        ObjectArrays.concat(cause.getStackTrace(), e.getStackTrace(), StackTraceElement.class);
    cause.setStackTrace(combined);
  }
  if (cause instanceof Exception) {
    throw (Exception) cause;
  }
  if (cause instanceof Error) {
    throw (Error) cause;
  }
  // The cause is a weird kind of Throwable, so throw the outer exception.
  throw e;
}
SimpleTimeLimiter.java 文件源码 项目:guava 阅读 33 收藏 0 点赞 0 评论 0
private static Exception throwCause(Exception e, boolean combineStackTraces) throws Exception {
  Throwable cause = e.getCause();
  if (cause == null) {
    throw e;
  }
  if (combineStackTraces) {
    StackTraceElement[] combined =
        ObjectArrays.concat(cause.getStackTrace(), e.getStackTrace(), StackTraceElement.class);
    cause.setStackTrace(combined);
  }
  if (cause instanceof Exception) {
    throw (Exception) cause;
  }
  if (cause instanceof Error) {
    throw (Error) cause;
  }
  // The cause is a weird kind of Throwable, so throw the outer exception.
  throw e;
}
CycleChainPackingPolytope.java 文件源码 项目:kidneyExchange 阅读 25 收藏 0 点赞 0 评论 0
@Override
public UserSolution createUserSolution(Set<E> edges, Set<EdgeCycle<E>> cycles) {
  IloIntVar[] variables = ObjectArrays.concat(edgeVariables.getVars(),
      cycleVariables.getVars(), IloIntVar.class);

  double[] values = new double[edgeVariables.size() + cycleVariables.size()];
  int ansPos = 0;
  for (IloIntVar edgeVar : edgeVariables.getVars()) {
    if (edges.contains(edgeVariables.getInverse(edgeVar))) {
      values[ansPos] = 1.0;
    } else {
      values[ansPos] = 0.0;
    }
    ansPos++;
  }
  for (IloIntVar cycleVar : cycleVariables.getVars()) {
    if (cycles.contains(cycleVariables.getInverse(cycleVar))) {
      values[ansPos] = 1.0;
    } else {
      values[ansPos] = 0.0;
    }
    ansPos++;
  }
  return new UserSolution(variables, values);
}
LatestActionDAOMysqlImpl.java 文件源码 项目:easyrec-PoC 阅读 31 收藏 0 点赞 0 评论 0
public int getLatestRatingPageCount(int tenantId, int itemTypeId, Date since) {
    final StringBuilder query = new StringBuilder("SELECT CEIL(count(*) / ?)");
    query.append("\n");
    query.append("FROM ").append(DEFAULT_TABLE_NAME).append("\n");
    query.append("WHERE ");
    query.append(DEFAULT_TENANT_COLUMN_NAME).append(" = ? AND ");
    query.append(DEFAULT_ITEM_TYPE_COLUMN_NAME).append(" = ?");

    Object[] args = new Object[]{PAGE_SIZE, tenantId, itemTypeId};
    int[] argt = new int[]{Types.INTEGER, Types.INTEGER, Types.INTEGER};

    if (since != null) {
        query.append(" AND ").append(DEFAULT_ACTION_TIME_COLUMN_NAME).append(" > ?");

        args = ObjectArrays.concat(args, since);
        argt = Ints.concat(argt, new int[]{Types.TIMESTAMP});
    }

    int count = getJdbcTemplate().queryForInt(query.toString(), args, argt);

    return count;
}
AbstractBaseRecommendationDAOMysqlImpl.java 文件源码 项目:easyrec-PoC 阅读 31 收藏 0 点赞 0 评论 0
protected String getRecommendationIteratorQueryString(TimeConstraintVO timeConstraints, ArgsAndTypesHolder holder) {
    StringBuilder query = new StringBuilder("SELECT * FROM ");
    query.append(DEFAULT_TABLE_NAME);

    if (timeConstraints.getDateFrom() != null) {
        query.append(" WHERE ");
        query.append(DEFAULT_RECOMMENDATION_TIME_COLUMN_NAME);
        query.append(" >= ?");
        holder.getArgs()[0] = timeConstraints.getDateFrom();
        if (timeConstraints.getDateTo() != null) {
            query.append(" AND ");
            query.append(DEFAULT_RECOMMENDATION_TIME_COLUMN_NAME);
            query.append(" <= ?");
            holder.setArgs(ObjectArrays.concat(holder.getArgs(), timeConstraints.getDateTo()));
            holder.setArgTypes(Ints.concat(holder.getArgTypes(), new int[] { Types.TIMESTAMP }));
        }
    } else {
        query.append(" WHERE ");
        query.append(DEFAULT_RECOMMENDATION_TIME_COLUMN_NAME);
        query.append(" <= ?");
        holder.getArgs()[0] = timeConstraints.getDateTo();
    }

    return query.toString();
}


问题


面经


文章

微信
公众号

扫码关注公众号