List of usage examples for com.google.common.base Preconditions checkNotNull
public static <T> T checkNotNull(T reference)
From source file:edu.byu.nlp.stats.DoubleArrayCategoricalDistribution.java
/** * Given the specified parameters, creates a new distribution, making copies of the parameters, if specified. *///from w w w . ja va 2 s . co m public static CategoricalDistribution newDistributionFromProbs(double[] probs, boolean copy) { Preconditions.checkNotNull(probs); if (copy) { probs = probs.clone(); } DoubleArrays.logToSelf(probs); return new DoubleArrayCategoricalDistribution(probs); }
From source file:org.oiavorskyi.axondemo.kafkaterminal.PrefixTopicStrategy.java
public PrefixTopicStrategy(final String prefix) { this.prefix = Preconditions.checkNotNull(prefix); }
From source file:com.enonic.cms.web.portal.instanttrace.InstantTraceId.java
public InstantTraceId(final Long traceCompletedNumber) { Preconditions.checkNotNull(traceCompletedNumber); this.traceCompletedNumber = traceCompletedNumber; }
From source file:org.apache.james.mailbox.store.mail.model.Username.java
public static Username fromMailboxSession(MailboxSession mailboxSession) { Preconditions.checkNotNull(mailboxSession); Preconditions.checkNotNull(mailboxSession.getUser()); return fromRawValue(mailboxSession.getUser().asString()); }
From source file:gobblin.runtime.locks.JobLockFactory.java
/** * Gets an instance of {@link JobLock}./* ww w . j a v a2s .c o m*/ * * @param properties the properties used to determine which instance of {@link JobLock} to create and the * relevant settings * @param jobLockEventListener the {@link JobLock} event listener * @return an instance of {@link JobLock} * @throws JobLockException throw when the {@link JobLock} fails to initialize */ public static JobLock getJobLock(Properties properties, JobLockEventListener jobLockEventListener) throws JobLockException { Preconditions.checkNotNull(properties); Preconditions.checkNotNull(jobLockEventListener); JobLock jobLock; if (properties.containsKey(ConfigurationKeys.JOB_LOCK_TYPE)) { try { Class<?> jobLockClass = Class.forName( properties.getProperty(ConfigurationKeys.JOB_LOCK_TYPE, FileBasedJobLock.class.getName())); jobLock = (JobLock) ConstructorUtils.invokeConstructor(jobLockClass, properties); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) { throw new JobLockException(e); } } else { jobLock = new FileBasedJobLock(properties); } if (jobLock instanceof ListenableJobLock) { ((ListenableJobLock) jobLock).setEventListener(jobLockEventListener); } return jobLock; }
From source file:org.apache.phoenix.mapreduce.util.ColumnInfoToStringEncoderDecoder.java
public static void encode(Configuration configuration, List<ColumnInfo> columnInfos) { Preconditions.checkNotNull(configuration); Preconditions.checkNotNull(columnInfos); int count = 0; for (int i = 0; i < columnInfos.size(); ++i) { if (columnInfos.get(i) != null) { configuration.set(String.format("%s_%d", CONFIGURATION_VALUE_PREFIX, i), columnInfos.get(i).toString()); ++count;/*from w ww. j av a 2 s . c o m*/ } } configuration.setInt(CONFIGURATION_COUNT, count); }
From source file:org.easy.ldap.importer.CvsRow.java
public static boolean validateHeader(String line) { if (line == null) return false; String[] tokens = line.split(","); Column[] column = Column.values();// ww w. j a va 2s. c om Preconditions.checkNotNull(tokens); Preconditions.checkArgument(tokens.length == column.length); for (int i = 0; i < tokens.length; i++) { if (!(tokens[i].trim().equals(column[i].toString()))) { return false; } } return true; }
From source file:net.centro.rtb.monitoringcenter.infos.ServerInfo.java
public static ServerInfo create(String nameAndVersion, String servletVersion) { Preconditions.checkNotNull(nameAndVersion); Preconditions.checkNotNull(servletVersion); ServerInfo serverInfo = new ServerInfo(); serverInfo.nameAndVersion = nameAndVersion; serverInfo.servletSpecVersion = servletVersion; return serverInfo; }
From source file:fi.vm.sade.organisaatio.service.util.OrganisaatioToSolrInputDocumentUtil.java
public static SolrInputDocument apply(Organisaatio org) { Preconditions.checkNotNull(org); SolrInputDocument doc = new SolrInputDocument(); add(doc, ALKUPVM, org.getAlkuPvm()); add(doc, LAKKAUTUSPVM, org.getLakkautusPvm()); add(doc, NIMIEN, org.getNimi().getString("en")); add(doc, NIMIFI, org.getNimi().getString("fi")); add(doc, NIMISV, org.getNimi().getString("sv")); // Listn organisaation nimihistoria hakuun addNimiHistoria(doc, NIMISEARCH, org.getNimet()); // Haku mahdollista mys y-tunnuksella if (org.getYtunnus() != null) { add(doc, NIMISEARCH, org.getYtunnus()); }/*from w ww. ja v a 2 s. co m*/ // Haku mahdollista mys oppilaitoskoodilla if (org.getOppilaitosKoodi() != null) { add(doc, NIMISEARCH, org.getOppilaitosKoodi()); } add(doc, OID, org.getOid()); add(doc, OPPILAITOSKOODI, org.getOppilaitosKoodi()); add(doc, ALIORGANISAATIOIDEN_LKM, org.getChildCount(new Date())); for (String tyyppi : org.getTyypit()) { add(doc, ORGANISAATIOTYYPPI, tyyppi); } for (String kieli : org.getKielet()) { add(doc, KIELI, kieli); } add(doc, DOMAINNIMI, org.getDomainNimi()); add(doc, OPPILAITOSTYYPPI, org.getOppilaitosTyyppi()); final Organisaatio parent = org.getParent(); add(doc, PARENTOID, parent != null ? parent.getOid() : null); add(doc, YTUNNUS, org.getYtunnus()); add(doc, KUNTA, org.getKotipaikka()); do { add(doc, PATH, org.getOid()); org = org.getParent(); } while (org != null); return doc; }
From source file:com.facebook.buck.zip.ZipOutputStreams.java
/** * Create a new {@link CustomZipOutputStream} that outputs to the given {@code zipFile}. Note that * the parent directory of the {@code zipFile} must exist already. The returned stream will throw * an exception should duplicate entries be added. * * @param zipFile The file to write to./* ww w . java2 s.c o m*/ */ public static CustomZipOutputStream newOutputStream(File zipFile) { Preconditions.checkNotNull(zipFile); try { return newOutputStream(new BufferedOutputStream(new FileOutputStream(zipFile))); } catch (FileNotFoundException e) { throw new RuntimeException(e); } }