List of usage examples for com.google.common.base Strings isNullOrEmpty
public static boolean isNullOrEmpty(@Nullable String string)
From source file:cpw.mods.fml.common.ProxyInjector.java
public static void inject(ModContainer mod, ASMDataTable data, Side side, ILanguageAdapter languageAdapter) { FMLLog.fine("Attempting to inject @SidedProxy classes into %s", mod.getModId()); Set<ASMData> targets = data.getAnnotationsFor(mod).get(SidedProxy.class.getName()); ClassLoader mcl = Loader.instance().getModClassLoader(); for (ASMData targ : targets) { try {/*from w w w . j ava 2 s . c om*/ Class<?> proxyTarget = Class.forName(targ.getClassName(), true, mcl); Field target = proxyTarget.getDeclaredField(targ.getObjectName()); if (target == null) { // Impossible? FMLLog.severe("Attempted to load a proxy type into %s.%s but the field was not found", targ.getClassName(), targ.getObjectName()); throw new LoaderException(); } target.setAccessible(true); SidedProxy annotation = target.getAnnotation(SidedProxy.class); if (!Strings.isNullOrEmpty(annotation.modId()) && !annotation.modId().equals(mod.getModId())) { FMLLog.fine("Skipping proxy injection for %s.%s since it is not for mod %s", targ.getClassName(), targ.getObjectName(), mod.getModId()); continue; } String targetType = side.isClient() ? annotation.clientSide() : annotation.serverSide(); Object proxy = Class.forName(targetType, true, mcl).newInstance(); if (languageAdapter.supportsStatics() && (target.getModifiers() & Modifier.STATIC) == 0) { FMLLog.severe("Attempted to load a proxy type %s into %s.%s, but the field is not static", targetType, targ.getClassName(), targ.getObjectName()); throw new LoaderException(); } if (!target.getType().isAssignableFrom(proxy.getClass())) { FMLLog.severe("Attempted to load a proxy type %s into %s.%s, but the types don't match", targetType, targ.getClassName(), targ.getObjectName()); throw new LoaderException(); } languageAdapter.setProxy(target, proxyTarget, proxy); } catch (Exception e) { FMLLog.log(Level.ERROR, e, "An error occured trying to load a proxy into %s.%s", targ.getAnnotationInfo(), targ.getClassName(), targ.getObjectName()); throw new LoaderException(e); } } // Allow language specific proxy injection. languageAdapter.setInternalProxies(mod, side, mcl); }
From source file:com.picdrop.exception.ApplicationExeptionMapper.java
@Override protected void log(ErrorMessage msg, Throwable e) { Level lvl = msg.lvl;//w w w .j av a 2 s. co m if (lvl == null) { lvl = msg.status >= 500 ? Level.ERROR : Level.DEBUG; } String stringMsg = Strings.isNullOrEmpty(msg.devMessage) ? msg.message : msg.devMessage; if (e.getCause() == null) { this.log.log(lvl, stringMsg); } else { this.log.log(lvl, stringMsg, e.getCause()); } }
From source file:org.xacml4j.v30.StatusCodeIds.java
public static StatusCodeId parse(final String v) { Preconditions.checkArgument(!Strings.isNullOrEmpty(v)); StatusCodeId code = BY_ID.get(v);//from www . ja v a2 s. c om if (code != null) { return code; } return new StatusCodeId() { @Override public String getId() { return v; } @Override public int hashCode() { return v.hashCode(); } @Override public String toString() { return v; } @Override public boolean equals(Object o) { if (o == this) { return true; } if (!(o instanceof StatusCodeId)) { return false; } StatusCodeId code = (StatusCodeId) o; return code.getId().equals(v); } }; }
From source file:com.github.avarabyeu.restendpoint.http.IOUtils.java
/** * Check whether provided url string is a valid java {@link java.net.URL} * * @param url URL to be validated//from w ww. ja v a 2s . c o m * @return TRUE if URL is valid */ public static boolean isValidUrl(String url) { try { if (Strings.isNullOrEmpty(url)) { return false; } new URL(url); return true; } catch (MalformedURLException e) { return false; } }
From source file:org.haiku.haikudepotserver.pkg.model.PkgIconImportArchiveJobSpecification.java
public Collection<String> getSuppliedDataGuids() { if (!Strings.isNullOrEmpty(inputDataGuid)) { return Collections.singleton(inputDataGuid); }/*from w w w. java 2 s . co m*/ return super.getSuppliedDataGuids(); }
From source file:th.co.geniustree.dental.angular.validator.NameUniqueValidator.java
@Override public boolean isValid(String value, ConstraintValidatorContext context) { if (Strings.isNullOrEmpty(value)) { return true; }//from w ww . j ava 2s . co m Customer findByNameIgnoreCase = customerRepo.findByNameIgnoreCase(value); return findByNameIgnoreCase == null; }
From source file:org.robobinding.gallery.model.typedcursor.GetAllQuery.java
public GetAllQuery(String tableName, RowMapper<T> rowMapper) { Preconditions.checkNotNull(Strings.isNullOrEmpty(tableName), "table name cannot be empty"); Preconditions.checkNotNull(rowMapper, "row mapper cannot be null"); this.tableName = tableName; this.rowMapper = rowMapper; }
From source file:org.apache.james.transport.matchers.utils.MailAddressCollectionReader.java
public static Set<MailAddress> read(String condition) { Preconditions.checkArgument(!Strings.isNullOrEmpty(condition)); return FluentIterable.from(Splitter.onPattern("(,| |\t)").split(condition)).filter(new Predicate<String>() { @Override/*from w w w.j a v a 2s . c o m*/ public boolean apply(String s) { return !Strings.isNullOrEmpty(s); } }).transform(new Function<String, MailAddress>() { @Override public MailAddress apply(String s) { try { return new MailAddress(s); } catch (AddressException e) { throw Throwables.propagate(e); } } }).toSet(); }
From source file:th.co.geniustree.dental.angular.validator.PidUniqueValidator.java
@Override public boolean isValid(String value, ConstraintValidatorContext context) { if (Strings.isNullOrEmpty(value)) { return true; }/*from w ww . jav a2 s. c om*/ Customer findByPidIgnoreCase = customerRepo.findByPidIgnoreCase(value); return findByPidIgnoreCase == null; }
From source file:com.haulmont.cuba.core.sys.AppContextLoader.java
public static void createPersistenceXml(String storeName) { String configPropertyName = AppContextLoader.PERSISTENCE_CONFIG; String fileName = "persistence.xml"; if (!Stores.isMain(storeName)) { configPropertyName = configPropertyName + "_" + storeName; fileName = storeName + "-" + fileName; }//from w ww. ja va 2 s.c o m String configProperty = AppContext.getProperty(configPropertyName); if (Strings.isNullOrEmpty(configProperty)) { log.debug("Property {} is not set, assuming {} is not a RdbmsStore", configPropertyName, storeName); return; } List<String> files = Splitter.on(AppProperties.SEPARATOR_PATTERN).omitEmptyStrings().trimResults() .splitToList(configProperty); if (!Stores.isMain(storeName) && !files.contains("base-persistence.xml")) { files = new ArrayList<>(files); files.add(0, "base-persistence.xml"); } PersistenceConfigProcessor processor = new PersistenceConfigProcessor(); processor.setStorageName(storeName); processor.setSourceFiles(files); String dataDir = AppContext.getProperty("cuba.dataDir"); processor.setOutputFile(dataDir + "/" + fileName); processor.create(); }