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.enonic.cms.core.locale.LocaleXmlCreator.java
public Document createLocalesDocument(final Locale[] locales) { Preconditions.checkNotNull(locales, "locales cannot be null"); Element localesEl = new Element("locales"); for (Locale locale : locales) { localesEl.addContent(doCreateLocaleElement(locale, null)); }/*from w w w . jav a 2 s . c o m*/ return new Document(localesEl); }
From source file:org.onsteroids.eve.api.WeldApi.java
public synchronized static void shutdownApi() { Preconditions.checkNotNull(weld, "Weld not running"); weld.shutdown();//from ww w. jav a2s. c o m weld = null; weldContainer = null; }
From source file:com.salesforce.jprotoc.ProtocPlugin.java
/** * Apply multiple generators to the parsed proto descriptor, aggregating their results. * @param generators The list of generators to run. *//*from ww w . ja va 2 s . c o m*/ public static void generate(@Nonnull List<Generator> generators) { Preconditions.checkNotNull(generators, "generators"); Preconditions.checkArgument(!generators.isEmpty(), "generators.isEmpty()"); try { // Parse the input stream to extract the generator request byte[] generatorRequestBytes = ByteStreams.toByteArray(System.in); PluginProtos.CodeGeneratorRequest request = PluginProtos.CodeGeneratorRequest .parseFrom(generatorRequestBytes); // Run each file generator, collecting the output List<PluginProtos.CodeGeneratorResponse.File> outputFiles = generators.stream() .flatMap(gen -> gen.generate(request)).collect(Collectors.toList()); // Send the files back to protoc PluginProtos.CodeGeneratorResponse response = PluginProtos.CodeGeneratorResponse.newBuilder() .addAllFile(outputFiles).build(); response.writeTo(System.out); } catch (GeneratorException ex) { try { PluginProtos.CodeGeneratorResponse.newBuilder().setError(ex.getMessage()).build() .writeTo(System.out); } catch (IOException ex2) { abort(ex2); } } catch (Throwable ex) { // Catch all the things! abort(ex); } }
From source file:com.google.security.zynamics.binnavi.yfileswrap.zygraph.Implementations.CLayoutFunctions.java
/** * Updates the background depending on the graph settings. * * @param graph The graph whose backround is updated. *//* w w w.j a v a 2s. co m*/ public static void updateBackground(final ZyGraph graph) { Preconditions.checkNotNull(graph, "IE02126: Graph argument can not be null"); // TODO: Buffer and share the background gradient between views final DefaultBackgroundRenderer dBGRender = new DefaultBackgroundRenderer(graph.getView()); if (graph.getSettings().getDisplaySettings().getGradientBackground()) { dBGRender.setImage(new ImageIcon(CMain.class.getResource("data/gradientbackground2.jpg")).getImage()); dBGRender.setMode(DefaultBackgroundRenderer.FULLSCREEN); } else { dBGRender.setColor(new Color(250, 250, 250)); } graph.getView().setBackgroundRenderer(dBGRender); graph.updateViews(); }
From source file:com.google.security.zynamics.binnavi.Gui.CTableSearcherHelper.java
/** * Searches through a table./*w w w.j a v a 2 s .c o m*/ * * @param parent Parent window used for dialogs. * @param table The table to search through. */ public static void search(final Window parent, final JTable table) { Preconditions.checkNotNull(parent, "IE01198: Parent argument can not be null"); Preconditions.checkNotNull(table, "IE01199: Table argument can not be null"); final CTableSearcher searcher = new CTableSearcher(parent, "", table, 0); String searchText = ""; do { searchText = (String) JOptionPane.showInputDialog(parent, "Search", Constants.DEFAULT_WINDOW_TITLE, JOptionPane.QUESTION_MESSAGE, null, null, searchText); if ((searchText != null) && (searchText.length() > 0) && !searcher.search(searchText)) { JOptionPane.showMessageDialog(parent, "Search string not found", Constants.DEFAULT_WINDOW_TITLE, JOptionPane.ERROR_MESSAGE); } } while ((searchText != null) && (searchText.length() > 0)); }
From source file:com.zaradai.kunzite.optimizer.data.dataset.driver.dummy.DummyDataSetDriver.java
public static DummyDataSetDriver createWithContext(DataSetContext context) { Preconditions.checkNotNull(context, "Invalid context"); return new DummyDataSetDriver(context); }
From source file:com.google.api.services.samples.tasks.android.ClientCredentials.java
public static void errorIfNotSpecified() { Preconditions.checkNotNull(KEY, "Please enter your API key from https://code.google.com/apis/console/?api=tasks in " + ClientCredentials.class); }
From source file:org.apache.usergrid.persistence.core.util.ValidationUtils.java
/** * Verify the entity has an id and a version *//*w w w . ja v a 2 s . c om*/ public static void verifyEntityWrite(Entity entity) { Preconditions.checkNotNull(entity, "Entity is required in the new stage of the mvcc write"); verifyIdentity(entity.getId()); }
From source file:com.google.collide.client.code.debugging.StaticSourceMapping.java
static StaticSourceMapping create(String baseUri) { Preconditions.checkNotNull(baseUri, "Base URI is NULL!"); return new StaticSourceMapping(baseUri); }
From source file:com.proofpoint.galaxy.shared.SlotLifecycleState.java
public static SlotLifecycleState lookup(String name) { Preconditions.checkNotNull(name, "name is null"); return byName.get(name.toLowerCase()); }