下面列出了com.google.common.collect.ObjectArrays#concat ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
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;
}
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;
}
RedirectedInvokeData(Target target, MethodInsnNode node) {
super(target);
this.node = node;
this.returnType = Type.getReturnType(node.desc);
this.targetArgs = Type.getArgumentTypes(node.desc);
this.handlerArgs = node.getOpcode() == Opcodes.INVOKESTATIC
? this.targetArgs
: ObjectArrays.concat(Type.getObjectType(node.owner), this.targetArgs);
}
/**
* 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);
}
/**
* 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);
}
EObject[] prependedGrammarElements() {
if(grammarElements instanceof EObject) {
return new EObject[] {grammarElement, (EObject) grammarElements};
} else {
return ObjectArrays.concat(grammarElement, (EObject[]) grammarElements);
}
}
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);
}
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;
}
/**
* 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);
}
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);
}
}
@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);
}
/**
* Try to make a new compound from two term. Called by the inference rules.
* @param term1 The first component
* @param term2 The second component
* @return A compound generated or a term it reduced to
*/
public static Term make(final Term term1, final Term term2) {
if ((term1 instanceof SetExt) && (term2 instanceof SetExt)) {
// set union
final Term[] both = ObjectArrays.concat(
((CompoundTerm) term1).term,
((CompoundTerm) term2).term, Term.class);
return SetExt.make(both);
}
if ((term1 instanceof SetInt) && (term2 instanceof SetInt)) {
// set intersection
final NavigableSet<Term> set = Term.toSortedSet(((CompoundTerm) term1).term);
set.retainAll(((CompoundTerm) term2).asTermList());
//technically this can be used directly if it can be converted to array
//but wait until we can verify that NavigableSet.toarray does it or write a helper function like existed previously
return SetInt.make(set.toArray(new Term[0]));
}
final List<Term> se = new ArrayList();
if (term1 instanceof IntersectionInt) {
((CompoundTerm) term1).addTermsTo(se);
if (term2 instanceof IntersectionInt) {
// (&,(&,P,Q),(&,R,S)) = (&,P,Q,R,S)
((CompoundTerm) term2).addTermsTo(se);
}
else {
// (&,(&,P,Q),R) = (&,P,Q,R)
se.add(term2);
}
} else if (term2 instanceof IntersectionInt) {
// (&,R,(&,P,Q)) = (&,P,Q,R)
((CompoundTerm) term2).addTermsTo(se);
se.add(term1);
} else {
se.add(term1);
se.add(term2);
}
return make(se.toArray(new Term[0]));
}
/**
* 添加元素到数组头.
*/
public static <T> T[] concat(@Nullable T element, T[] array) {
return ObjectArrays.concat(element, array);
}
/**
* 添加元素到数组末尾.
*/
public static <T> T[] concat(T[] array, @Nullable T element) {
return ObjectArrays.concat(array, element);
}
@Override
protected String[] collectContextMenuPreferencePages() {
String[] commonPages = super.collectContextMenuPreferencePages();
String[] langSpecificPages = collectLanguageContextMenuPreferencePages();
return ObjectArrays.concat(langSpecificPages, commonPages, String.class);
}
private Repository.Option[] applyOffset(Repository.Option[] options, long offset) {
return ObjectArrays.concat(options, new OffsetOption(offset));
}
@SuppressWarnings("unchecked")
@Override
public <T extends EssentialFilter> Class<T>[] filters() {
return (Class[]) ObjectArrays.concat(GzipFilter.class, super.filters());
}
private Repository.Option[] applyLimit(Repository.Option[] options, long limit) {
return ObjectArrays.concat(options, new LimitOption(limit));
}
/**
* 添加元素到数组末尾,没有银弹,复制扩容.
*/
public static <T> T[] concat(T[] array, @Nullable T element) {
return ObjectArrays.concat(array, element);
}
/**
* Combine driver dependency contexts with the specified core Selenium Grid contexts.
*
* @param dependencyContexts core Selenium Grid dependency contexts
* @param driverPlugin driver plug-in from which to acquire dependencies
* @return combined contexts for Selenium Grid dependencies
*/
public static String[] combineDependencyContexts(String[] dependencyContexts, DriverPlugin driverPlugin) {
return ObjectArrays.concat(dependencyContexts, driverPlugin.getDependencyContexts(), String.class);
}