List of usage examples for com.google.common.collect Lists newLinkedList
@GwtCompatible(serializable = true) public static <E> LinkedList<E> newLinkedList(Iterable<? extends E> elements)
From source file:eu.project.ttc.models.scored.ScoredTerm.java
public void setVariations(Iterable<ScoredVariation> variations) { this.variations = Lists.newLinkedList(variations); }
From source file:exceptionparser.StackTrace.java
public StackTrace(final String exceptionType, final String message, final List<StackTraceElement> elements, final StackTrace causedBy) { this.exceptionType = exceptionType; this.message = message; this.elements = Lists.newLinkedList(elements); //this.elementsWithoutRecursion=deleteRecursions(elements); this.causedBy = causedBy; }
From source file:brooklyn.entity.rebind.transformer.impl.DeleteOrphanedLocationsTransformer.java
public BrooklynMemento transform(BrooklynMemento input) throws Exception { Set<String> referencedLocationIds = findReferencedLocationIds(input); Set<String> unreferencedLocationIds = Sets.newLinkedHashSet(); List<String> toCheck = Lists.newLinkedList(input.getLocationIds()); while (!toCheck.isEmpty()) { String locationId = toCheck.remove(0); List<String> locationsInHierarchy = MutableList.<String>builder().add(locationId) .addAll(findLocationAncestors(input, locationId)) .addAll(findLocationDescendents(input, locationId)).build(); if (containsAny(referencedLocationIds, locationsInHierarchy)) { // keep them all } else {//from w w w . j av a 2s . c o m unreferencedLocationIds.addAll(locationsInHierarchy); } toCheck.removeAll(locationsInHierarchy); } // TODO What about brooklyn version? return BrooklynMementoImpl.builder().applicationIds(input.getApplicationIds()) .topLevelLocationIds(MutableSet.<String>builder().addAll(input.getTopLevelLocationIds()) .removeAll(unreferencedLocationIds).build()) .entities(input.getEntityMementos()) .locations(MutableMap.<String, LocationMemento>builder().putAll(input.getLocationMementos()) .removeAll(unreferencedLocationIds).build()) .policies(input.getPolicyMementos()).enrichers(input.getEnricherMementos()) .catalogItems(input.getCatalogItemMementos()).build(); }
From source file:org.auraframework.test.mock.MockModelDef.java
public MockModelDef(DefDescriptor<ModelDef> descriptor, Set<ValueDef> members, List<Answer<Model>> instances) { super(descriptor); this.members = Maps.newLinkedHashMap(); if (members != null) { for (ValueDef val : members) { this.members.put(val.getName(), val); }/* w w w . j a v a2 s. c om*/ } this.instances = instances != null ? Lists.newLinkedList(instances) : Lists.<Answer<Model>>newLinkedList(); }
From source file:com.mycila.guice.ext.injection.MemberInjectorTypeListener.java
@Override public <I> void hear(final TypeLiteral<I> injectableType, TypeEncounter<I> encounter) { final Provider<? extends KeyProvider<A>> provider = encounter.getProvider(providerClass); final Provider<Injector> injectorProvider = encounter.getProvider(Injector.class); final List<Field> fields = Lists .newLinkedList(Reflect.findAllAnnotatedFields(injectableType.getRawType(), annotationType)); final List<MethodInvoker> methods = Lists .newLinkedList(Reflect.findAllAnnotatedInvokables(injectableType.getRawType(), annotationType)); if (!fields.isEmpty() || !methods.isEmpty()) { encounter.register(new MembersInjector<I>() { @Override/*w w w . j a va 2 s . c o m*/ public void injectMembers(I injectee) { KeyProvider<A> keyProvider = provider.get(); // inject fields for (Field field : fields) { Object value = injectorProvider.get().getProvider( keyProvider.getKey(injectableType, field, field.getAnnotation(annotationType))) .get(); if (!field.isAccessible()) field.setAccessible(true); try { field.set(injectee, value); } catch (IllegalAccessException e) { throw new IllegalStateException( "Failed to inject field " + field + ". Reason: " + e.getMessage(), e); } } // inject methods for (MethodInvoker invokable : methods) { List<Key<?>> parameterKeys = keyProvider.getParameterKeys(injectableType, invokable.method, invokable.getAnnotation(annotationType)); Object[] parameters = new Object[parameterKeys.size()]; for (int i = 0; i < parameters.length; i++) parameters[i] = injectorProvider.get().getProvider(parameterKeys.get(i)).get(); try { invokable.invoke(injectee, parameters); } catch (Exception e) { throw MycilaGuiceException.toRuntime(e); } } } }); } }
From source file:com.samskivert.depot.MultiKeySet.java
@Override public SQLExpression<?> getWhereExpression() { Set<Integer> columns = Sets.newHashSet(); for (int ii = 0; ii < _keyFields.length; ii++) { columns.add(ii);/* ww w. java 2 s .co m*/ } return rowsToSQLExpression(Lists.newLinkedList(Arrays.asList(_keys)), columns); }
From source file:org.richfaces.tests.metamer.ftest.extension.configurator.config.SimpleConfig.java
public SimpleConfig(List<FieldConfiguration> config) { this.injectionsConfigurations = Lists.newLinkedList(config); }
From source file:org.apache.james.jmap.model.ContinuationToken.java
public static ContinuationToken fromString(String serializedToken) throws MalformedContinuationTokenException { Preconditions.checkArgument(!Strings.isNullOrEmpty(serializedToken), "Serialized continuation token should not be null or empty"); LinkedList<String> tokenParts = Lists.newLinkedList(Splitter.on(SEPARATOR).split(serializedToken)); try {/* ww w. j av a 2s . co m*/ return ContinuationToken.builder().signature(tokenParts.removeLast()) .expirationDate( ZonedDateTime.parse(tokenParts.removeLast(), DateTimeFormatter.ISO_OFFSET_DATE_TIME)) .username(Joiner.on(SEPARATOR).join(tokenParts)).build(); } catch (NoSuchElementException | IllegalArgumentException e) { throw new MalformedContinuationTokenException( "Token " + serializedToken + " does not have enough parts", e); } catch (DateTimeException e) { throw new MalformedContinuationTokenException("Token " + serializedToken + " as an incorrect date", e); } }
From source file:org.apache.twill.internal.utils.Dependencies.java
/** * Finds the class dependencies of the given class. * @param classLoader ClassLoader for finding class bytecode. * @param acceptor Predicate to accept a found class and its bytecode. * @param classesToResolve Classes for looking for dependencies. * @throws IOException Thrown where there is error when loading in class bytecode. *///from w ww .j a v a2 s.c o m public static void findClassDependencies(ClassLoader classLoader, ClassAcceptor acceptor, Iterable<String> classesToResolve) throws IOException { final Set<String> seenClasses = Sets.newHashSet(classesToResolve); final Queue<String> classes = Lists.newLinkedList(classesToResolve); // Breadth-first-search classes dependencies. while (!classes.isEmpty()) { String className = classes.remove(); URL classUrl = getClassURL(className, classLoader); if (classUrl == null) { continue; } // Call the accept to see if it accept the current class. if (!acceptor.accept(className, classUrl, getClassPathURL(className, classUrl))) { continue; } try (InputStream is = classUrl.openStream()) { // Visit the bytecode to lookup classes that the visiting class is depended on. new ClassReader(ByteStreams.toByteArray(is)) .accept(new DependencyClassVisitor(new DependencyAcceptor() { @Override public void accept(String className) { // See if the class is accepted if (seenClasses.add(className)) { classes.add(className); } } }), ClassReader.SKIP_DEBUG + ClassReader.SKIP_FRAMES); } } }
From source file:com.mycila.inject.injector.AnnotatedMemberHandlerTypeListener.java
@Override public <I> void hear(final TypeLiteral<I> type, TypeEncounter<I> encounter) { final Provider<? extends AnnotatedMemberHandler<A>> provider = encounter.getProvider(handlerClass); final List<Field> fields = Lists.newLinkedList(findFields(type.getRawType(), annotatedBy(annotationType))); final List<Method> methods = Lists .newLinkedList(filter(findMethods(type.getRawType()), annotatedBy(annotationType))); if (!fields.isEmpty() || !methods.isEmpty()) { encounter.register(new InjectionListener<I>() { @Override/*from ww w . j ava2 s. c o m*/ public void afterInjection(I injectee) { AnnotatedMemberHandler<A> handler = provider.get(); for (Field field : fields) handler.handle(type, injectee, new AnnotatedMember<Field>(field), field.getAnnotation(annotationType)); for (Method method : methods) handler.handle(type, injectee, new AnnotatedMember<Method>(method), method.getAnnotation(annotationType)); } }); } }