List of usage examples for com.google.common.base Strings isNullOrEmpty
public static boolean isNullOrEmpty(@Nullable String string)
From source file:org.fusesource.fabric.service.jclouds.functions.ToAdminAccess.java
public static Optional<AdminAccess> apply(CreateJCloudsContainerOptions input) { AdminAccess.Builder builder = AdminAccess.builder(); //There are images that have issues with copying of public keys, creation of admin user accounts,etc //To allow/*from w w w. java 2 s. co m*/ if (input.isAdminAccess()) { if (!Strings.isNullOrEmpty(input.getPublicKeyFile())) { File publicKey = new File(input.getPublicKeyFile()); if (publicKey.exists()) { builder.adminPublicKey(publicKey); } else { LOGGER.warn("Public key has been specified file: {} files cannot be found. Ignoring.", publicKey.getAbsolutePath()); return Optional.of(AdminAccess.standard()); } } if (!Strings.isNullOrEmpty(input.getUser())) { builder.adminUsername(input.getUser()); } return Optional.of(builder.build()); } return Optional.absent(); }
From source file:org.caleydo.core.internal.startup.StartupAddons.java
public static Map<String, IStartupAddon> findAll() { List<StartupAddonDesc> tmp = new ArrayList<>(); try {/*from w w w . ja va 2s . c o m*/ for (IConfigurationElement elem : RegistryFactory.getRegistry() .getConfigurationElementsFor(EXTENSION_POINT)) { final Object o = elem.createExecutableExtension("class"); if (o instanceof IStartupAddon) { String orderS = elem.getAttribute("order"); int order = Strings.isNullOrEmpty(orderS) ? 10 : Integer.parseInt(orderS); tmp.add(new StartupAddonDesc(elem.getAttribute("name"), (IStartupAddon) o, order)); } } } catch (CoreException e) { System.err.println("can't find implementations of " + EXTENSION_POINT + " : " + "name"); e.printStackTrace(); } // sort by order Collections.sort(tmp); Map<String, IStartupAddon> factories = Maps.newLinkedHashMap(); for (StartupAddonDesc desc : tmp) factories.put(desc.label, desc.addon); return Collections.unmodifiableMap(factories); }
From source file:org.sonar.server.util.Validation.java
public static void checkMandatoryParameter(String value, String paramName) { if (Strings.isNullOrEmpty(value)) { throw new BadRequestException(Validation.CANT_BE_EMPTY_MESSAGE, paramName); }//from w w w .j ava2s . c o m }
From source file:com.github.jcustenborder.kafka.connect.utils.util.VersionUtil.java
public static String version(Class<?> cls) { final String FALLBACK_VERSION = "0.0.0.0"; try {/*from w w w .j a v a2 s . c om*/ String version = cls.getPackage().getImplementationVersion(); if (Strings.isNullOrEmpty(version)) { version = FALLBACK_VERSION; } return version; } catch (Exception ex) { return FALLBACK_VERSION; } }
From source file:org.apache.james.jmap.api.vacation.AccountId.java
public static AccountId fromString(String identifier) { Preconditions.checkArgument(!Strings.isNullOrEmpty(identifier), "AccountId identifier should not be null or empty"); return new AccountId(identifier); }
From source file:org.sonatype.nexus.plugins.cas.CasUtil.java
/** * Returns {@code true} if the request was issued by a web browser. * * * @param request http request//from ww w . j av a2s . com * * @return {@code true} if the request was issued by a web browser. */ public static boolean isBrowser(HttpServletRequest request) { boolean browser = false; String ua = request.getHeader("User-Agent"); if (!Strings.isNullOrEmpty(ua)) { browser = isWebInterface(request) || isBrowserUserAgent(ua); } return browser; }
From source file:org.apache.james.jmap.model.BlobId.java
public static BlobId of(String rawValue) { Preconditions.checkArgument(!Strings.isNullOrEmpty(rawValue), "'rawValue' is mandatory"); return new BlobId(rawValue); }
From source file:co.cask.cdap.operations.OperationalStatsUtils.java
@Nullable static OperationalExtensionId getOperationalExtensionId(OperationalStats operationalStats) { String serviceName = operationalStats.getServiceName(); String statType = operationalStats.getStatType(); if (Strings.isNullOrEmpty(serviceName) && Strings.isNullOrEmpty(statType)) { return null; }// w w w .j av a 2 s. c o m if (!Strings.isNullOrEmpty(serviceName)) { serviceName = serviceName.toLowerCase(); } else { LOG.warn( "Found operational stat without service name - {}. This stat will not be discovered by service name.", operationalStats.getClass().getName()); } if (!Strings.isNullOrEmpty(statType)) { statType = statType.toLowerCase(); } else { LOG.warn( "Found operational stat without stat type - {}. This stat will not be discovered by stat type.", operationalStats.getClass().getName()); } return new OperationalExtensionId(serviceName, statType); }
From source file:com.facebook.buck.intellij.ideabuck.config.BuckWSServerPortUtils.java
public static int getPort(String runInPath) throws NumberFormatException, IOException, ExecutionException { BuckSettingsProvider.State state = BuckSettingsProvider.getInstance().getState(); if (state == null) { throw new RuntimeException("Cannot load ideabuck settings."); }// w ww. ja v a 2 s. c om String exec = state.buckExecutable; if (Strings.isNullOrEmpty(exec)) { throw new RuntimeException("Buck executable is not defined in settings."); } GeneralCommandLine commandLine = new GeneralCommandLine(); commandLine.setExePath(exec); commandLine.withWorkDirectory(runInPath); commandLine.addParameter("server"); commandLine.addParameter("status"); commandLine.addParameter("--http-port"); commandLine.setRedirectErrorStream(true); Process p = commandLine.createProcess(); BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream())); int port = CONNECTION_FAILED_PORT; String line; while ((line = reader.readLine()) != null) { if (line.startsWith(SEARCH_FOR)) { port = Integer.parseInt(line.substring(SEARCH_FOR.length())); if (port == CONNECTION_FAILED_PORT) { // if the buck server is off, and it gives us -1, throw this exception String error = "Your buck server may be turned off, since the Buck daemon is on port " + port + ".\nTry adding to your '.buckconfig.local' or '.buckconfig' file," + " if you don't have it already set:\n" + "[httpserver]\n" + " port = 0\n" + "After that, restart IntelliJ or reopen your project.\n"; throw new RuntimeException(error); } } } return port; }
From source file:org.apache.kylin.metrics.property.QueryPropertyEnum.java
public static QueryPropertyEnum getByName(String name) { if (Strings.isNullOrEmpty(name)) { return null; }//from ww w.j a v a2s . c o m for (QueryPropertyEnum property : QueryPropertyEnum.values()) { if (property.propertyName.equals(name.toUpperCase())) { return property; } } return null; }