List of usage examples for com.google.common.base Preconditions checkNotNull
public static <T> T checkNotNull(T reference, @Nullable Object errorMessage)
From source file:com.google.security.zynamics.zylib.gui.zygraph.helpers.ClipboardCopier.java
/** * Copies the text content of a node to the clip board. * //w w w . j a v a 2 s. c om * @param node The node to copy to the clip board. */ public static void copyToClipboard(final ZyGraphNode<?> node) { Preconditions.checkNotNull(node, "Error: Node argument can not be null"); final IZyNodeRealizer realizer = node.getRealizer(); final ZyLabelContent content = realizer.getNodeContent(); if (content.isSelectable()) { final ZyLabelContent zyContent = content; final StringBuilder textBuilder = new StringBuilder(); for (final ZyLineContent zyLineContent : zyContent) { textBuilder.append(zyLineContent.getText()); textBuilder.append("\n"); //$NON-NLS-1$ } ClipboardHelpers.copyToClipboard(textBuilder.toString()); } }
From source file:de.flapdoodle.guava.Folds.java
public static <S, D> D foldLeft(Iterable<? extends S> collection, Foldleft<? super S, D> foldFunction, D leftValue) {// w w w.j a v a2 s.c o m Preconditions.checkNotNull(collection, "collection is null"); Preconditions.checkNotNull(foldFunction, "foldFunction is null"); D ret = leftValue; for (S value : collection) { ret = foldFunction.apply(ret, value); } return ret; }
From source file:com.github.jcustenborder.kafka.connect.cdc.Change.java
static Map<String, Object> sourcePartition(Change change) { Preconditions.checkNotNull(change, "change cannot be null."); return ImmutableMap.of(Constants.DATABASE_NAME_VARIABLE, change.databaseName(), Constants.SCHEMA_NAME_VARIABLE, change.schemaName(), Constants.TABLE_NAME_VARIABLE, change.tableName());/*from w ww . ja va2 s. co m*/ }
From source file:net.bither.viewsystem.themes.Themes.java
public static synchronized void switchTheme(Theme newTheme) { Preconditions.checkNotNull(newTheme, "'newTheme' must be present"); currentTheme = newTheme;//from w w w . j a v a2 s. co m // Gets used in combo box borders and provides the basis for a "default button" UIManager.put("nimbusBase", currentTheme.readOnlyComboBox()); // Provides basis for text UIManager.put("nimbusBlueGrey", currentTheme.fadedText()); UIManager.put("nimbusBorder", currentTheme.text()); UIManager.put("nimbusDisabledText", currentTheme.fadedText()); UIManager.put("nimbusLightBackground", currentTheme.sidebarPanelBackground()); UIManager.put("nimbusFocus", currentTheme.infoAlertBorder()); UIManager.put("nimbusSelectedText", currentTheme.infoAlertText()); UIManager.put("nimbusSelection", currentTheme.infoAlertBackground()); UIManager.put("nimbusSelectionBackground", currentTheme.infoAlertBackground()); // Scrollbar UI Color scrollBarThumb = currentTheme.infoAlertBackground(); UIManager.put("ScrollBar.thumb", scrollBarThumb); UIManager.put("ScrollBar.thumbDarkShadow", scrollBarThumb); UIManager.put("ScrollBar.thumbShadow", scrollBarThumb.darker()); UIManager.put("ScrollBar.thumbHighlight", scrollBarThumb.darker()); Color scrollBarTrack = currentTheme.detailPanelBackground(); UIManager.put("ScrollBar.background", new ColorUIResource(Color.RED)); UIManager.put("ScrollBar.foreground", new ColorUIResource(Color.BLUE)); UIManager.put("ScrollBar.track", scrollBarTrack); UIManager.put("ScrollBar.trackHighlight", new ColorUIResource(Color.YELLOW)); // Ensure the language icons match the colour scheme LanguageKey.resetIcons(); // Adjust the font size initializeFontSize(); }
From source file:co.cask.cdap.examples.profiles.Event.java
public static Event fromJson(ByteBuffer input) { Event event = GSON.fromJson(//from w w w . j a va2 s. com new InputStreamReader(new ChannelBufferInputStream(ChannelBuffers.wrappedBuffer(input))), Event.class); Preconditions.checkNotNull(event.getTime(), "Time cannot be null."); Preconditions.checkNotNull(event.getUserId(), "User ID cannot be null."); Preconditions.checkNotNull(event.getUrl(), "URL cannot be null."); return event; }
From source file:com.google.security.zynamics.binnavi.ZyGraph.Painters.CrossReferencePainter.java
public static void paintCrossReference(final NaviNode node, final INaviCodeNode codeNode, final TypeInstanceReference reference, final INaviInstruction instruction) { Preconditions.checkNotNull(node, "Error: node argument can not be null"); Preconditions.checkNotNull(codeNode, "Error: codeNode argument can not be null"); Preconditions.checkNotNull(reference, "Error: reference argument can not be null"); Preconditions.checkNotNull(instruction, "Error: instruction argument can not be null"); final int line = CCodeNodeHelpers.instructionToLine(codeNode, instruction); node.clearHighlighting(CHighlightLayers.VARIABLE_LAYER, line); node.setHighlighting(CHighlightLayers.VARIABLE_LAYER, line, ConfigManager.instance().getColorSettings().getMemRefColor()); }
From source file:org.eclipse.lsp4j.util.Ranges.java
/** * {@code true} if the {@link Position position} is either inside or on the * border of the {@link Range range}. Otherwise, {@code false}. *///from w ww . ja v a 2 s. c om public static boolean containsPosition(Range range, Position position) { Preconditions.checkNotNull(range, "range"); Preconditions.checkNotNull(position, "position"); return (range.getStart().equals(position) || Positions.isBefore(range.getStart(), position) && (range.getEnd().equals(position) || Positions.isBefore(position, range.getEnd()))); }
From source file:com.zaradai.kunzite.optimizer.control.OptimizeRequest.java
public static OptimizeRequest newRequest(Class<? extends OptimizerTactic> tactic, String target, boolean lookForMaxima, InputRow start) { Preconditions.checkNotNull(tactic, "Invalid tactic specified"); Preconditions.checkArgument(!Strings.isNullOrEmpty(target), "No target specified"); Preconditions.checkNotNull(start, "No start position specified"); return new OptimizeRequest(tactic, target, lookForMaxima, start); }
From source file:com.outerspacecat.memcache.Memcache.java
/** * Returns whether or not {@code key} is a valid Memcache key. * <p>/*from w ww . j a va 2 s .c o m*/ * Memcache keys must be between 1 and 250 characters in length (inclusive), * and must contain only non-control, non-whitespace ASCII characters, which * corresponds to the range U+0021-U+007E (inclusive). * * @param key the key to check for validity. Must be non {@code null}. * @return whether or not {@code key} is a valid Memcache key */ public static boolean isValidKey(final CharSequence key) { Preconditions.checkNotNull(key, "key required"); return KEY_PATTERN.matcher(key).matches(); }
From source file:com.isotrol.impe3.nr.api.NRTerm.java
/** * Creates a new term.//from w w w .java2 s.c o m * @param field Field name. * @param text Term text. * @return The created term. */ public static NRTerm of(String field, String text) { Preconditions.checkNotNull(field, "A field name must be provided"); return new NRTerm(field, text); }