com.google.common.collect.ObjectArrays源码实例Demo

类com.google.common.collect.ObjectArrays源码实例Demo

下面列出了com.google.common.collect.ObjectArrays 类实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: NullAway   文件: JarInferTest.java
/**
 * Create, compile, and run a unit test.
 *
 * @param testName An useful name for the unit test.
 * @param pkg Qualified package name.
 * @param cls Target class to be analyzed.
 * @param expected Map of 'method signatures' to their 'expected list of NonNull parameters'.
 * @param lines Source lines for the test code.
 */
private void testTemplate(
    String testName,
    String pkg, // in dot syntax
    String cls,
    Map<String, Set<Integer>> expected,
    String... lines)
    throws Exception {
  boolean compileSucceeded =
      compilerUtil
          .addSourceLines(cls + ".java", ObjectArrays.concat("package " + pkg + ";\n", lines))
          .run();
  Assert.assertTrue(
      testName + ": test compilation failed!\n" + compilerUtil.getOutput(), compileSucceeded);
  DefinitelyDerefedParamsDriver driver = new DefinitelyDerefedParamsDriver();
  Map<String, Set<Integer>> result =
      driver.run(
          temporaryFolder.getRoot().getAbsolutePath(), "L" + pkg.replaceAll("\\.", "/"), true);
  Assert.assertTrue(
      testName + ": test failed! \n" + result + " does not match " + expected,
      verify(result, new HashMap<>(expected)));
}
 
protected static DataSource reloadDataSource(FlywayDataSourceContext dataSourceContext, Flyway flywayBean, FlywayTest annotation) throws Exception {
    if (isAppendable(flywayBean, annotation)) {
        return dataSourceContext.reload(flywayBean).get();
    } else {
        String[] oldLocations = getFlywayLocations(flywayBean);
        try {
            if (annotation.overrideLocations()) {
                setFlywayLocations(flywayBean, annotation.locationsForMigrate());
            } else {
                setFlywayLocations(flywayBean, ObjectArrays.concat(oldLocations, annotation.locationsForMigrate(), String.class));
            }
            return dataSourceContext.reload(flywayBean).get();
        } finally {
            setFlywayLocations(flywayBean, oldLocations);
        }
    }
}
 
源代码3 项目: codebuff   文件: SimpleTimeLimiter.java
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;
}
 
源代码4 项目: codebuff   文件: SimpleTimeLimiter.java
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;
}
 
源代码5 项目: teammates   文件: AppPage.java
/**
 * Waits and verifies that the texts of user status messages in the page are equal to the expected texts.
 * The check is done multiple times with waiting times in between to account for
 * timing issues due to page load, inconsistencies in Selenium API, etc.
 */
public void waitForTextsForAllStatusMessagesToUserEquals(String firstExpectedText, String... remainingExpectedTexts) {
    List<String> expectedTexts = Arrays.asList(ObjectArrays.concat(firstExpectedText, remainingExpectedTexts));
    try {
        uiRetryManager.runUntilNoRecognizedException(new RetryableTask("Verify status to user") {
            @Override
            public void run() {
                // Scroll to status message because it must be visible in order to get its text
                new Actions(browser.driver).moveToElement(statusMessage).perform();
                waitForElementVisibility(statusMessage);

                assertEquals(expectedTexts, getTextsForAllStatusMessagesToUser());
            }
        }, WebDriverException.class, AssertionError.class);
    } catch (MaximumRetriesExceededException e) {
        assertEquals(expectedTexts, getTextsForAllStatusMessagesToUser());
    }
}
 
源代码6 项目: codebuff   文件: SimpleTimeLimiter.java
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;
}
 
源代码7 项目: codebuff   文件: SimpleTimeLimiter.java
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;
}
 
源代码8 项目: pnc   文件: AbstractProvider.java
@Override
public Page<DTO> queryForCollection(
        int pageIndex,
        int pageSize,
        String sortingRsql,
        String query,
        Predicate<DB>... predicates) {
    Predicate<DB> rsqlPredicate = rsqlPredicateProducer.getCriteriaPredicate(type, query);
    PageInfo pageInfo = pageInfoProducer.getPageInfo(pageIndex, pageSize);
    SortInfo sortInfo = rsqlPredicateProducer.getSortInfo(type, sortingRsql);
    List<DB> collection = repository
            .queryWithPredicates(pageInfo, sortInfo, ObjectArrays.concat(rsqlPredicate, predicates));
    int totalHits = repository.count(ObjectArrays.concat(rsqlPredicate, predicates));
    int totalPages = (totalHits + pageSize - 1) / pageSize;
    List<DTO> content = nullableStreamOf(collection).map(mapper::toDTO).collect(Collectors.toList());
    return new Page<>(pageIndex, pageSize, totalPages, totalHits, content);
}
 
源代码9 项目: plugins   文件: WorldHopperPlugin.java
private void insertMenuEntry(MenuEntry newEntry, MenuEntry[] entries, boolean after)
{
	MenuEntry[] newMenu = ObjectArrays.concat(entries, newEntry);

	if (after)
	{
		int menuEntryCount = newMenu.length;
		ArrayUtils.swap(newMenu, menuEntryCount - 1, menuEntryCount - 2);
	}

	client.setMenuEntries(newMenu);
}
 
源代码10 项目: presto   文件: RequestErrorTracker.java
static void logError(Throwable t, String format, Object... args)
{
    if (isExpectedError(t)) {
        log.error(format + ": %s", ObjectArrays.concat(args, t));
    }
    else {
        log.error(t, format, args);
    }
}
 
源代码11 项目: browserup-proxy   文件: TrustSource.java
/**
 * Returns a new TrustSource containing the same trusted CAs as this TrustSource, plus zero or more additional
 * trusted X509Certificates. If trustedCertificates is null or empty, returns this same TrustSource.
 *
 * @param trustedCertificates X509Certificates of CAs to trust
 * @return a new TrustSource containing this TrustSource's trusted CAs plus the specified CAs
 */
public TrustSource add(X509Certificate... trustedCertificates) {
    if (trustedCertificates == null || trustedCertificates.length == 0) {
        return this;
    }

    X509Certificate[] newTrustedCAs = ObjectArrays.concat(trustedCAs, trustedCertificates, X509Certificate.class);

    return new TrustSource(newTrustedCAs);
}
 
源代码12 项目: patchwork-api   文件: ForgeConfigSpec.java
public <V extends Comparable<? super V>> ConfigValue<V> defineInRange(List<String> path, Supplier<V> defaultSupplier, V min, V max, Class<V> clazz) {
	Range<V> range = new Range<>(clazz, min, max);
	context.setRange(range);
	context.setComment(ObjectArrays.concat(context.getComment(), "Range: " + range.toString()));

	if (min.compareTo(max) > 0) {
		throw new IllegalArgumentException("Range min most be less then max.");
	}

	return define(path, defaultSupplier, range);
}
 
源代码13 项目: CapturePacket   文件: TrustSource.java
/**
 * Returns a new TrustSource containing the same trusted CAs as this TrustSource, plus zero or more additional
 * trusted X509Certificates. If trustedCertificates is null or empty, returns this same TrustSource.
 *
 * @param trustedCertificates X509Certificates of CAs to trust
 * @return a new TrustSource containing this TrustSource's trusted CAs plus the specified CAs
 */
public TrustSource add(X509Certificate... trustedCertificates) {
    if (trustedCertificates == null || trustedCertificates.length == 0) {
        return this;
    }

    X509Certificate[] newTrustedCAs = ObjectArrays.concat(trustedCAs, trustedCertificates, X509Certificate.class);

    return new TrustSource(newTrustedCAs);
}
 
源代码14 项目: bundletool   文件: ManifestProtoUtils.java
public static XmlNode androidManifestForFeature(
    String packageName, ManifestMutator... manifestMutators) {
  return androidManifest(
      packageName,
      ObjectArrays.concat(
          new ManifestMutator[] {withOnDemandAttribute(true), withFusingAttribute(true)},
          manifestMutators,
          ManifestMutator.class));
}
 
源代码15 项目: ProjectAres   文件: LaneMatchModule.java
private static Block getAdjacentRegionBlock(Region region, Block origin) {
    for(BlockFace face : ObjectArrays.concat(CARDINAL_DIRECTIONS, DIAGONAL_DIRECTIONS, BlockFace.class)) {
        Block adjacent = origin.getRelative(face);
        if(region.contains(BlockUtils.center(adjacent).toVector())) {
            return adjacent;
        }
    }
    return null;
}
 
源代码16 项目: javaide   文件: LocalSdk.java
public IAndroidTarget[] getTargets(boolean includeMissing) {
    IAndroidTarget[] result = getTargets();
    if (includeMissing) {
        result = ObjectArrays.concat(result, getMissingTargets(), IAndroidTarget.class);
    }
    return result;
}
 
源代码17 项目: Elasticsearch   文件: GetIndexRequest.java
public GetIndexRequest addFeatures(Feature... features) {
    if (this.features == DEFAULT_FEATURES) {
        return features(features);
    } else {
        return features(ObjectArrays.concat(featuresAsEnums(), features, Feature.class));
    }
}
 
/**
 * Create a new string array with 'moreEntries' appended to the 'entries'
 * array.
 * @param entries initial entries in the array
 * @param moreEntries variable-length additional entries.
 * @return an array containing entries with all of moreEntries appended.
 */
protected String [] newStrArray(String [] entries, String... moreEntries)  {
  if (null == moreEntries) {
    return entries;
  }

  if (null == entries) {
    entries = new String[0];
  }

  return ObjectArrays.concat(entries, moreEntries, String.class);
}
 
源代码19 项目: NioSmtpClient   文件: SmtpSession.java
private SendSequence beginSequence(Optional<SendInterceptor> sequenceInterceptor, int expectedResponses, Object... objects) {
  if (requiresRset) {
    if (ehloResponse.isSupported(Extension.PIPELINING)) {
      return new SendSequence(sequenceInterceptor, expectedResponses + 1, ObjectArrays.concat(SmtpRequests.rset(), objects));
    } else {
      return new SendSequence(sequenceInterceptor, 1,  SmtpRequests.rset()).thenSend(objects);
    }
  } else {
    requiresRset = true;
    return new SendSequence(sequenceInterceptor, expectedResponses, objects);
  }
}
 
源代码20 项目: dremio-oss   文件: QBlockHashTable.java
private void addDataBlocks() {

    try(RollbackCloseable rollbackable = new RollbackCloseable()) {

      // make sure can fit the next batch.
      listener.addBatch();

      {
        FixedBlockVector newFixed = new FixedBlockVector(allocator, pivot.getBlockWidth());
        rollbackable.add(newFixed);
        newFixed.ensureAvailableBlocks(MAX_VALUES_PER_BATCH);
        fixedBlocks = ObjectArrays.concat(fixedBlocks, newFixed);
        tableFixedAddresses = Longs.concat(tableFixedAddresses, new long[]{newFixed.getMemoryAddress()});
      }

      {
        VariableBlockVector newVariable = new VariableBlockVector(allocator, pivot.getVariableCount());
        rollbackable.add(newVariable);
        newVariable.ensureAvailableDataSpace(pivot.getVariableCount() == 0 ? 0 : MAX_VALUES_PER_BATCH * defaultVariableLengthSize);
        variableBlocks = ObjectArrays.concat(variableBlocks, newVariable);
        initVariableAddresses = Longs.concat(initVariableAddresses, new long[]{newVariable.getMemoryAddress()});
        openVariableAddresses = Longs.concat(openVariableAddresses, new long[]{newVariable.getMemoryAddress()});
        maxVariableAddresses = Longs.concat(maxVariableAddresses, new long[]{newVariable.getMaxMemoryAddress()});
      }
      rollbackable.commit();
    } catch (Exception e) {
      throw Throwables.propagate(e);
    }
  }
 
源代码21 项目: dremio-oss   文件: LBlockHashTableNoSpill.java
private void addDataBlocks(){

    // make sure can fit the next batch.
    listener.resized(currentOrdinal + MAX_VALUES_PER_BATCH);

    try(RollbackCloseable rollbackable = new RollbackCloseable()) {

      {
        FixedBlockVector newFixed = new FixedBlockVector(allocator, pivot.getBlockWidth());
        rollbackable.add(newFixed);
        newFixed.ensureAvailableBlocks(MAX_VALUES_PER_BATCH);
        fixedBlocks = ObjectArrays.concat(fixedBlocks, newFixed);
        tableFixedAddresses = Longs.concat(tableFixedAddresses, new long[]{newFixed.getMemoryAddress()});
      }

      {
        VariableBlockVector newVariable = new VariableBlockVector(allocator, pivot.getVariableCount());
        rollbackable.add(newVariable);
        newVariable.ensureAvailableDataSpace(pivot.getVariableCount() == 0 ? 0 : MAX_VALUES_PER_BATCH * defaultVariableLengthSize);
        variableBlocks = ObjectArrays.concat(variableBlocks, newVariable);
        initVariableAddresses = Longs.concat(initVariableAddresses, new long[]{newVariable.getMemoryAddress()});
        openVariableAddresses = Longs.concat(openVariableAddresses, new long[]{newVariable.getMemoryAddress()});
        maxVariableAddresses = Longs.concat(maxVariableAddresses, new long[]{newVariable.getMaxMemoryAddress()});
      }
      rollbackable.commit();
    } catch (Exception e) {
      throw Throwables.propagate(e);
    }
  }
 
源代码22 项目: science-journal   文件: SimpleBackupAgent.java
@Override
public void onCreate() {
  Context context = getApplicationContext();
  String defaultPrefsName = getDefaultSharedPreferencesName(context);
  String[] accountsPrefsNames = AccountsUtils.getSharedPreferencesNamesForAllAccounts(context);
  SharedPreferencesBackupHelper helper =
      new SharedPreferencesBackupHelper(
          this, ObjectArrays.concat(defaultPrefsName, accountsPrefsNames));
  addHelper(PREFS_BACKUP_KEY, helper);
}
 
源代码23 项目: buck   文件: BuildCommandIntegrationTest.java
private String[] getCommandArgsForShowOutputOrShowOutputs(
    String showOutputCommand, String... args) {
  if (useShowOutputs) {
    return ObjectArrays.concat(
        SHOW_OUTPUT_TO_SHOW_OUTPUTS.get(showOutputCommand), args, String.class);
  }
  return ObjectArrays.concat(showOutputCommand, args);
}
 
源代码24 项目: runelite   文件: FriendNotesPlugin.java
@Subscribe
public void onMenuEntryAdded(MenuEntryAdded event)
{
	final int groupId = WidgetInfo.TO_GROUP(event.getActionParam1());

	// Look for "Message" on friends list
	if ((groupId == WidgetInfo.FRIENDS_LIST.getGroupId() && event.getOption().equals("Message")) ||
			(groupId == WidgetInfo.IGNORE_LIST.getGroupId() && event.getOption().equals("Delete")))
	{
		// Friends have color tags
		setHoveredFriend(Text.toJagexName(Text.removeTags(event.getTarget())));

		// Build "Add Note" or "Edit Note" menu entry
		final MenuEntry addNote = new MenuEntry();
		addNote.setOption(hoveredFriend == null || hoveredFriend.getNote() == null ? ADD_NOTE : EDIT_NOTE);
		addNote.setType(MenuAction.RUNELITE.getId());
		addNote.setTarget(event.getTarget()); //Preserve color codes here
		addNote.setParam0(event.getActionParam0());
		addNote.setParam1(event.getActionParam1());

		// Add menu entry
		final MenuEntry[] menuEntries = ObjectArrays.concat(client.getMenuEntries(), addNote);
		client.setMenuEntries(menuEntries);
	}
	else if (hoveredFriend != null)
	{
		hoveredFriend = null;
	}
}
 
源代码25 项目: levelup-java-examples   文件: CombineTwoArrays.java
@Test
public void join_two_object_arrays_in_java_with_guava() {

	String[] allStateCapitals = ObjectArrays.concat(firstHalfStateCapital,
			secondHalfStateCapital, String.class);

	assertTrue(allStateCapitals.length == 50);
}
 
源代码26 项目: runelite   文件: WorldHopperPlugin.java
private void insertMenuEntry(MenuEntry newEntry, MenuEntry[] entries, boolean after)
{
	MenuEntry[] newMenu = ObjectArrays.concat(entries, newEntry);

	if (after)
	{
		int menuEntryCount = newMenu.length;
		ArrayUtils.swap(newMenu, menuEntryCount - 1, menuEntryCount - 2);
	}

	client.setMenuEntries(newMenu);
}
 
源代码27 项目: Dream-Catcher   文件: TrustSource.java
/**
 * Returns a new TrustSource containing the same trusted CAs as this TrustSource, plus zero or more additional
 * trusted X509Certificates. If trustedCertificates is null or empty, returns this same TrustSource.
 *
 * @param trustedCertificates X509Certificates of CAs to trust
 * @return a new TrustSource containing this TrustSource's trusted CAs plus the specified CAs
 */
public TrustSource add(X509Certificate... trustedCertificates) {
    if (trustedCertificates == null || trustedCertificates.length == 0) {
        return this;
    }

    X509Certificate[] newTrustedCAs = ObjectArrays.concat(trustedCAs, trustedCertificates, X509Certificate.class);

    return new TrustSource(newTrustedCAs);
}
 
源代码28 项目: envelope   文件: RowUtils.java
public static Row append(Row row, String fieldName, DataType fieldType, boolean nullable, Object value) {
  StructType appendedSchema = row.schema().add(fieldName, fieldType, nullable);
  Object[] appendedValues = ObjectArrays.concat(valuesFor(row), value);
  Row appendedRow = new RowWithSchema(appendedSchema, appendedValues);

  return appendedRow;
}
 
源代码29 项目: immutables   文件: Proto.java
static @Nullable String[] concat(@Nullable String[] first, @Nullable String[] second) {
  if (first == null)
    return second;
  if (second == null)
    return first;
  return ObjectArrays.concat(first, second, String.class);
}
 
源代码30 项目: cuba   文件: BaseEntityInternalAccess.java
public static void addRequiredAttributes(SecurityState state, String[] requiredAttributes) {
    if (state.requiredAttributes == null) {
        state.requiredAttributes = requiredAttributes;
    } else {
        state.requiredAttributes =
                ObjectArrays.concat(state.requiredAttributes, requiredAttributes, String.class);
    }
}
 
源代码评论
动弹
沙发等你来抢
 类方法
 同包方法