List of usage examples for com.google.common.collect Lists asList
public static <E> List<E> asList(@Nullable E first, E[] rest)
From source file:com.leacox.dagger.servlet.DaggerServletContextListener.java
/** * @param urlPattern Any Servlet-style pattern. examples: /*, /html/*, *.html, etc. *//*w ww. j ava 2 s.c o m*/ protected final ServletDefinitionBuilder serve(String urlPattern, String... morePatterns) { return new ServletDefinitionBuilderImpl(Lists.asList(urlPattern, morePatterns), UriPatternType.SERVLET); }
From source file:org.eclipse.xtext.ui.editor.contentassist.AbstractJavaBasedContentProposalProvider.java
protected void invokeMethod(String methodName, ICompletionProposalAcceptor acceptor, Object... params) { PolymorphicDispatcher<Void> dispatcher = dispatchers.get(methodName); if (dispatcher == null) { ErrorHandler<Void> errorHandler = WarningErrorHandler.get(log); dispatcher = new PolymorphicDispatcher<Void>(methodName, params.length + 1, params.length + 1, Collections.singletonList(this), errorHandler) { @Override//from w w w .j av a 2s.co m public Class<?> getDefaultClass(int paramIndex) { if (paramIndex == 0) return EObject.class; return super.getDefaultClass(paramIndex); } }; dispatchers.put(methodName, dispatcher); } Object[] paramAsArray = new Object[params.length + 1]; System.arraycopy(params, 0, paramAsArray, 0, params.length); paramAsArray[params.length] = acceptor; if (announceProcessing(Lists.asList(methodName, paramAsArray))) { dispatcher.invoke(paramAsArray); } }
From source file:com.leacox.dagger.servlet.DaggerServletContextListener.java
/** * @param regex Any Java-style regular expression. *///www.j av a2s . com protected final ServletDefinitionBuilder serveRegex(String regex, String... moreRegexes) { return new ServletDefinitionBuilderImpl(Lists.asList(regex, moreRegexes), UriPatternType.REGEX); }
From source file:org.sonar.db.component.ComponentDao.java
public void insert(DbSession session, ComponentDto item, ComponentDto... others) { insert(session, Lists.asList(item, others)); }
From source file:mx.bigdata.sat.cfdi.CFDv33.java
private static JAXBContext getContext(String[] contexts) throws Exception { List<String> ctx = Lists.asList(BASE_CONTEXT, contexts); if (!contextMap.containsKey(ctx)) { JAXBContext context = JAXBContext.newInstance(JOINER.join(ctx)); contextMap.put(ctx, context);/*from w w w . j a v a 2 s . c o m*/ } return contextMap.get(ctx); }
From source file:org.apache.hadoop.hbase.security.visibility.ExpAsStringVisibilityLabelServiceImpl.java
private List<String> getSystemAndSuperUsers() throws IOException { User user = User.getCurrent();/*from w ww. j a v a 2 s . c om*/ if (user == null) { throw new IOException("Unable to obtain the current user, " + "authorization checks for internal operations will not work correctly!"); } if (LOG.isTraceEnabled()) { LOG.trace("Current user name is " + user.getShortName()); } String currentUser = user.getShortName(); List<String> superUsers = Lists.asList(currentUser, this.conf.getStrings(AccessControlLists.SUPERUSER_CONF_KEY, new String[0])); return superUsers; }
From source file:tiger.Utils.java
public static String getCanonicalName(ClassName className) { Joiner joiner = Joiner.on("."); return joiner.join(Lists.asList(className.packageName(), className.simpleNames().toArray(new String[0]))); }
From source file:com.samskivert.depot.DepotRepository.java
/** * Updates all fields of the supplied persistent object, using its primary key along with the * supplied extra {@code conditions} to identify the row to be updated. * * @return the number of rows modified by this action. * * @throws DatabaseException if any problem is encountered communicating with the database. */// www .ja v a 2s . c o m public int update(PersistentRecord record, SQLExpression<?>... conditions) throws DatabaseException { Class<? extends PersistentRecord> pClass = record.getClass(); requireNotComputed(pClass, "update"); DepotMarshaller<? extends PersistentRecord> marsh = _ctx.getMarshaller(pClass); Key<? extends PersistentRecord> key = marsh.getPrimaryKey(record); checkArgument(key != null, "Can't update record with null primary key."); WhereClause where = (conditions.length == 0) ? key : new Where(Ops.and(Lists.asList(key.getWhereExpression(), conditions))); return doUpdate(key, new UpdateClause(pClass, where, marsh.getColumnFieldNames(), record)); }
From source file:dagger.internal.codegen.BindingMethodValidator.java
/** * Formats an error message whose first {@code %s} parameter should be replaced with the simple * name of the method annotation./*from w w w .j a va 2 s.com*/ */ protected String formatErrorMessage(String format, Object... otherParameters) { return otherParameters.length == 0 ? String.format(format, methodAnnotation.getSimpleName()) : String.format(format, Lists.asList(methodAnnotation.getSimpleName(), otherParameters).toArray()); }
From source file:com.fluidops.iwb.tools.RepositoryTool.java
private static RepositoryStatus analyzeAndFixInternal(File dbModelFolder, File targetFolder, boolean fixMode, boolean checkGhostContexts, String nativeStoreIndices) throws FileNotFoundException, IOException { print("Analyzing repository at " + dbModelFolder.getPath()); // precondition: check whether the repository is accessible // if not: the appropriate exception is thrown checkRepositoryAccessible(dbModelFolder, nativeStoreIndices); RepositoryState stateDefault;//w ww.j av a 2 s . com // Step 1: check if repository is broken with default indices resetIndexConfiguration(dbModelFolder); print("1) Checking repository state with default indices (" + nativeStoreIndices + ")"); stateDefault = checkRepositoryState(dbModelFolder, nativeStoreIndices, checkGhostContexts); // individual indices String[] indices = nativeStoreIndices.split(","); List<RepositoryState> indexStates = Lists.newArrayList(); // Step 2: check with all individual indices print("2) Checking repository state with individual indices"); for (String index : indices) { resetIndexConfiguration(dbModelFolder); print(" Checking " + index + " index"); RepositoryState s = checkRepositoryState(dbModelFolder, index, stateDefault.isCorrupt() && checkGhostContexts); indexStates.add(s); } // delete the index configuration, in case the repository is reused late on resetIndexConfiguration(dbModelFolder); // Step 3: print analysis results print("3) Analysis result:"); boolean repositoryCorrupt = false; boolean allIndicesCorrupt = false; if (stateDefault.isCorrupt()) { repositoryCorrupt = true; print(" * Repository indices are corrupt: " + stateDefault.getCorruptMessage()); allIndicesCorrupt = true; for (RepositoryState indexState : indexStates) { if (!indexState.isCorrupt()) { allIndicesCorrupt = false; continue; } print(" * " + indexState.getIndices() + " index is corrupt: " + indexState.getCorruptMessage()); } if (allIndicesCorrupt) print(" * All available indices are corrupt, repository cannot be repaired."); } // check the size of the individual index configurations long size = stateDefault.getSize(); for (RepositoryState indexState : indexStates) { if (size != indexState.getSize()) { repositoryCorrupt = true; print(" * Repository indices are out of synch: size of at least one index configuration differs"); break; } size = indexState.getSize(); } // check for ghost contexts boolean isAffectedByGhosts = false; for (RepositoryState indexState : Lists.asList(stateDefault, indexStates.toArray(new RepositoryState[0]))) { if (indexState.isAffectedByGhosts()) { repositoryCorrupt = true; isAffectedByGhosts = true; print(" * Repository is affected by inconsistent index states: " + stateDefault.getNumberOfGhosts() + " garbage contexts"); print(" See Sesame bug SES-1867 for further details"); break; } } // try to find a non-corrupt index, take the one with largest size String goodIndex = null; long goodIndexSize = -1; for (RepositoryState indexState : indexStates) { if (!indexState.isCorrupt() && indexState.size > goodIndexSize) { goodIndex = indexState.getIndices(); goodIndexSize = indexState.getSize(); } } if (!repositoryCorrupt) { if (checkGhostContexts) print(String.format(" * Repository is healthy (No garbage contexts detected, size: %s)", stateDefault.getSize())); else print(String.format(" * Repository is healthy (No checks for garbage contexts, size: %s)", stateDefault.getSize())); return RepositoryStatus.OK; } else if (!allIndicesCorrupt) { print(" * Index " + goodIndex + " can be used for recovery process."); } // Step 5: if desired automatically fix if (!fixMode) return RepositoryStatus.INCONSISTENT; System.out.println("4) Trying to repair database"); if (allIndicesCorrupt) { print(" * Cannot recover database, all indices are corrupt."); throw new IllegalStateException("Database cannot be automatically recovered, all indices are corrupt."); } print("Trying to recover database using " + goodIndex + " index"); if (isAffectedByGhosts) print("(Note: garbage contexts arising through invalid data states will be removed in this process)"); try { rebuildRepository(dbModelFolder, targetFolder, goodIndex, nativeStoreIndices); } catch (IllegalStateException e) { // try to find another good context, if available (and retry) String secondIndex = null; for (RepositoryState indexState : indexStates) { if (!indexState.isCorrupt() && goodIndex.equals(indexState.getIndices())) { secondIndex = indexState.getIndices(); } } if (secondIndex == null) throw e; // retry with secondIndex (delete temp files first) print("Retrying with second good index: " + secondIndex); File targetRepoTmpFolder = new File(dbModelFolder.getParentFile(), dbModelFolder.getName() + ".tmp"); FileUtils.deleteDirectory(targetRepoTmpFolder); rebuildRepository(dbModelFolder, targetFolder, secondIndex, nativeStoreIndices); } // if the repository was affected by ghosts: remove them if (checkGhostContexts && isAffectedByGhosts) removeGhostContexts(targetFolder, nativeStoreIndices); return RepositoryStatus.FIXED; }