List of usage examples for com.google.common.collect Lists newLinkedList
@GwtCompatible(serializable = true) public static <E> LinkedList<E> newLinkedList()
From source file:org.gradle.model.internal.manage.schema.extraction.ModelSchemaExtractor.java
public <T> ModelSchema<T> extract(Class<T> type) throws InvalidManagedModelElementTypeException { validateType(type);//from w w w .j a v a2s .c o m List<Method> methodList = Arrays.asList(type.getDeclaredMethods()); if (methodList.isEmpty()) { return new ModelSchema<T>(type, Collections.<ModelProperty<?>>emptyList()); } List<ModelProperty<?>> properties = Lists.newLinkedList(); Map<String, Method> methods = Maps.newHashMap(); for (Method method : methodList) { String name = method.getName(); if (methods.containsKey(name)) { throw invalidMethod(type, name, "overloaded methods are not supported"); } methods.put(name, method); } List<String> methodNames = Lists.newLinkedList(methods.keySet()); List<String> handled = Lists.newArrayList(); for (ListIterator<String> iterator = methodNames.listIterator(); iterator.hasNext();) { String methodName = iterator.next(); Method method = methods.get(methodName); if (methodName.startsWith("get") && !methodName.equals("get")) { if (method.getParameterTypes().length != 0) { throw invalidMethod(type, methodName, "getter methods cannot take parameters"); } Character getterPropertyNameFirstChar = methodName.charAt(3); if (!Character.isUpperCase(getterPropertyNameFirstChar)) { throw invalidMethod(type, methodName, "the 4th character of the getter method name must be an uppercase character"); } Class<?> returnType = method.getReturnType(); ModelType<?> returnModelType = ModelType.of(returnType); if (returnType.equals(String.class)) { properties.add(extractNonManagedProperty(type, methods, methodName, returnModelType, handled)); } else if (isManaged(returnType)) { properties.add(extractManagedProperty(type, methods, methodName, returnModelType, handled)); } else { throw invalidMethod(type, methodName, "only String and managed properties are supported"); } iterator.remove(); } } methodNames.removeAll(handled); // TODO - should call out valid getters without setters if (!methodNames.isEmpty()) { throw invalid(type, "only paired getter/setter methods are supported (invalid methods: [" + Joiner.on(", ").join(methodNames) + "])"); } return new ModelSchema<T>(type, properties); }
From source file:org.apache.streams.datasift.processor.DatasiftTypeConverterProcessor.java
@Override public List<StreamsDatum> process(StreamsDatum entry) { List<StreamsDatum> result = Lists.newLinkedList(); Object doc;//from w w w . j a v a2 s . co m try { if (entry.getDocument() instanceof String) { ObjectNode node = this.mapper.readValue((String) entry.getDocument(), ObjectNode.class); doc = this.converter.convert(node, this.mapper); } else { doc = this.converter.convert(entry.getDocument(), this.mapper); } if (doc != null) { result.add(new StreamsDatum(doc, entry.getId())); } } catch (Exception e) { LOGGER.error("Exception converting Datasift Interaction to " + this.outClass.getName() + " : {}", e); } return result; }
From source file:com.nesscomputing.syslog4j.impl.AbstractSyslogWriter.java
public void initialize(AbstractSyslog abstractSyslog) { this.syslog = abstractSyslog; try {/* w w w .j a v a 2 s .c om*/ this.syslogConfig = (AbstractSyslogConfigIF) this.syslog.getConfig(); } catch (ClassCastException cce) { throw new SyslogRuntimeException("config must implement interface AbstractSyslogConfigIF"); } if (this.syslogConfig.isThreaded()) { this.queuedMessages = Lists.newLinkedList(); } }
From source file:cc.kave.commons.model.naming.impl.v0.codeelements.PropertyName.java
public List<IParameterName> getParameters() { if (_parameters == null) { if (isUnknown()) { _parameters = Lists.newLinkedList(); } else {/* w w w .j a v a 2s . c o m*/ int endOfParameters = identifier.lastIndexOf(')'); int startOfParameters = FindCorrespondingOpenBracket(identifier, endOfParameters); _parameters = GetParameterNamesFromSignature(identifier, startOfParameters, endOfParameters); } } return _parameters; }
From source file:org.summer.ss.core.richstring.DefaultIndentationHandler.java
public DefaultIndentationHandler() { this.indentationData = Lists.newLinkedList(); this.indentationDataStack = Lists.newLinkedList(); indentationDataStack.add(indentationData); }
From source file:com.romeikat.datamessie.core.base.util.sparsetable.SparseMultiTable.java
protected List<Z> createInnerList() { return Lists.newLinkedList(); }
From source file:org.sonar.batch.components.TimeMachineConfiguration.java
private void initPastSnapshots(PastSnapshotFinder pastSnapshotFinder) { Snapshot projectSnapshot = buildProjectSnapshot(); projectPastSnapshots = Lists.newLinkedList(); if (projectSnapshot != null) { for (int index = 1; index <= NUMBER_OF_VARIATION_SNAPSHOTS; index++) { PastSnapshot pastSnapshot = pastSnapshotFinder.find(projectSnapshot, configuration, index); if (pastSnapshot != null) { log(pastSnapshot);/* w w w. j a va 2 s .c o m*/ projectPastSnapshots.add(pastSnapshot); } } } }
From source file:com.dteoh.tidal.platform.windows.SuspendAndResumeListener.java
/** * Creates a new listener for Windows suspend and resume events. * //ww w .j av a 2s. co m * @param broadcastFrame * A visible frame capable of receiving broadcast events. Must * not be null. */ public SuspendAndResumeListener() { listeners = Lists.newLinkedList(); final VistaUser32 user32 = VistaUser32.INSTANCE; Runnable edtTask = new Runnable() { @Override public void run() { broadcastTarget = new JWindow(); broadcastTarget.setSize(0, 0); broadcastTarget.setLocation(-9999, 0); broadcastTarget.setFocusable(false); broadcastTarget.setVisible(true); broadcastWindow = new HWND(Native.getWindowPointer(broadcastTarget)); notificationHandle = user32.RegisterPowerSettingNotification(broadcastWindow, VistaUser32.GUID_SYSTEM_AWAYMODE, 0); if (notificationHandle == null) { logger.error("Failed to register for PowerSettingNotification"); return; } proc = new WNDPROC() { @Override public int WndProc(final HWND hWnd, final int uMsg, final WPARAM wParam, final LPARAM lParam) { if (uMsg == VistaUser32.WM_POWERBROADCAST) { if (VistaUser32.PBT_APMSUSPEND.equals(wParam)) { // Notify listeners of impending system sleep. for (PowerStateListener l : listeners) { l.suspend(); } return 0; } if (VistaUser32.PBT_APMRESUMESUSPEND.equals(wParam)) { // Notify listeners that system has resumed. for (PowerStateListener l : listeners) { l.resume(); } return 0; } } return user32.DefWindowProc(hWnd, uMsg, wParam, lParam); } }; LONG_PTR ptr = user32.SetWindowLongPtr(broadcastWindow, VistaUser32.GWL_WNDPROC, proc); if (ptr.longValue() == 0) { logger.error("Failed to set new address of window procedure"); } } }; EDTUtils.runOnEDT(edtTask); }
From source file:org.nmdp.ngs.range.tree.AbstractRangeTree.java
@Override public Iterable<Set<Range<C>>> intersect(final Iterable<Range<C>> query) { checkNotNull(query);/*from w w w . ja va 2 s . c om*/ List<Set<Range<C>>> result = Lists.newLinkedList(); for (Range<C> range0 : query) { for (Range<C> range1 : intersect(range0)) { result.add(ImmutableSet.of(range0, range1)); } } return result; }
From source file:com.google.jstestdriver.config.YamlParser.java
@SuppressWarnings("unchecked") public Configuration parse(Reader configReader, BasePaths defaultBasePaths) { Map<Object, Object> data = (Map<Object, Object>) YAML.load(configReader); Set<FileInfo> resolvedFilesLoad = new LinkedHashSet<FileInfo>(); Set<FileInfo> testFiles = new LinkedHashSet<FileInfo>(); Set<FileInfo> resolvedFilesExclude = new LinkedHashSet<FileInfo>(); String server = ""; DocType doctype = docTypeParser.parse("quirks"); BasePaths basePaths = defaultBasePaths; long timeOut = 0; List<Plugin> plugins = Lists.newLinkedList(); JsonArray gatewayConfig = new JsonArray(); if (data.containsKey("load")) { resolvedFilesLoad.addAll(createFileInfos((List<String>) data.get("load"), false)); }//from ww w. ja v a2s .co m if (data.containsKey("test")) { testFiles.addAll(createFileInfos((List<String>) data.get("test"), false)); } if (data.containsKey("exclude")) { resolvedFilesExclude.addAll(createFileInfos((List<String>) data.get("exclude"), false)); } if (data.containsKey("server")) { server = (String) data.get("server"); } if (data.containsKey("plugin")) { for (Map<String, String> value : (List<Map<String, String>>) data.get("plugin")) { plugins.add(new Plugin(value.get("name"), value.get("jar"), value.get("module"), createArgsList(value.get("args")))); } } if (data.containsKey("serve")) { Set<FileInfo> resolvedServeFiles = createFileInfos((List<String>) data.get("serve"), true); resolvedFilesLoad.addAll(resolvedServeFiles); } if (data.containsKey("doctype")) { doctype = docTypeParser.parse((String) data.get("doctype")); } if (data.containsKey("timeout")) { timeOut = (Long) data.get("timeout"); } if (data.containsKey("basepath")) { Object rawBasePaths = data.get("basepath"); List<String> stringBasePaths = Lists.newArrayList(); if (rawBasePaths instanceof String) { stringBasePaths.add((String) data.get("basepath")); } else if (rawBasePaths instanceof List) { stringBasePaths.addAll((List<String>) rawBasePaths); } for (String stringPath : stringBasePaths) { File basePath = new File(stringPath); if (!basePath.isAbsolute()) { basePaths = basePaths.applyRelativePath(stringPath); } else { basePaths.add(basePath); } } } if (data.containsKey("proxy")) { copyDataToGatewayConfig(data, "proxy", gatewayConfig); } if (data.containsKey("gateway")) { copyDataToGatewayConfig(data, "gateway", gatewayConfig); } return new ParsedConfiguration(resolvedFilesLoad, resolvedFilesExclude, plugins, server, timeOut, basePaths, Lists.newArrayList(testFiles), gatewayConfig, doctype); }