List of usage examples for com.google.common.base Optional get
public abstract T get();
From source file:org.opendaylight.yangtools.yang.data.operations.LeafSetNodeModification.java
private static boolean contains(Optional<LeafSetNode<?>> actual, LeafSetEntryNode<?> leafListModification) { boolean contains = actual.isPresent(); contains &= actual.get().getChild(leafListModification.getIdentifier()).isPresent(); return contains; }
From source file:org.locationtech.geogig.storage.impl.Blobs.java
public static Optional<String> getBlobAsString(BlobStore blobStore, String blobName) { Optional<byte[]> blob = getBlob(blobStore, blobName); Optional<String> str = Optional.absent(); if (blob.isPresent()) { str = Optional.of(new String(blob.get(), Charsets.UTF_8)); }/*from w w w .j av a2 s. c om*/ return str; }
From source file:de.Keyle.MyPet.api.entity.PropertyConverter.java
@Deprecated @Since("24.11.2016") public static TagCompound convertEntity(LivingEntity entity) { Optional<EntityConverterService> converter = MyPetApi.getServiceManager() .getService(EntityConverterService.class); if (converter.isPresent()) { return converter.get().convertEntity(entity); }/*from w w w . j ava 2s . c o m*/ return new TagCompound(); }
From source file:com.arpnetworking.clusteraggregator.AggDataUnifier.java
private static Optional<Unit> getSmaller(final Optional<Unit> a, final Optional<Unit> b) { if (a.isPresent() && b.isPresent()) { return a.get().isSmallerThan(b.get()) ? a : b; } else {/*from w w w. j av a 2 s . c om*/ return a.or(b); } }
From source file:org.opendaylight.netvirt.openstack.netvirt.NetvirtProvider.java
public static boolean isMasterProviderInstance() { if (entityOwnershipService != null) { Optional<EntityOwnershipState> state = entityOwnershipService.getOwnershipState(ownerInstanceEntity); return state.isPresent() && state.get().isOwner(); }/*from www .j ava 2 s .co m*/ return false; }
From source file:org.opendaylight.netvirt.openstack.netvirt.NetvirtProvider.java
public static boolean isMasterElected() { if (entityOwnershipService != null) { Optional<EntityOwnershipState> state = entityOwnershipService.getOwnershipState(ownerInstanceEntity); return state.isPresent() && state.get().hasOwner(); }// ww w .ja v a 2 s . c om return false; }
From source file:org.anhonesteffort.flock.AccountAndKeyRequiredActivity.java
protected static MasterCipher handleGetMasterCipherOrFail(Activity activity) { try {/* ww w . j a v a2 s. c o m*/ Optional<MasterCipher> cipher = KeyHelper.getMasterCipher(activity); if (cipher.isPresent()) return cipher.get(); else { Log.e(TAG, "master cipher is missing, fuck"); throw new IOException("Where did master chipher GO!?!?"); } } catch (IOException e) { // TODO: import account from scratch... activity.finish(); return null; } }
From source file:org.pshdl.model.types.builtIn.HDLGenerators.java
public static Optional<HDLInterface> getInterface(HDLDirectGeneration hdl) { final IHDLGenerator generator = generators.get(hdl.getGeneratorID()); if (generator != null) { final Optional<HDLInterface> hif = generator.getInterface(hdl); if (hif.isPresent()) return Optional.of(hif.get().copyDeepFrozen(hdl)); return hif; }/*from w ww . ja va2 s. co m*/ return Optional.absent(); }
From source file:org.apache.beam.sdk.extensions.sql.impl.interpreter.operator.date.BeamSqlIntervalMultiplyExpression.java
/** * Output type is null if no operands found with matching types. Execution will later fail when * calling accept()/*w w w . j a va 2 s . com*/ */ private static SqlTypeName deduceOutputType(List<BeamSqlExpression> operands) { Optional<BeamSqlExpression> intervalOperand = findExpressionOfType(operands, SqlTypeName.INTERVAL_TYPES); return intervalOperand.isPresent() ? intervalOperand.get().getOutputType() : null; }
From source file:gobblin.util.CLIPasswordEncryptor.java
private static String getMasterPassword(CommandLine cl) { if (cl.hasOption(MASTER_PWD_OPTION)) { if (cl.hasOption(MASTER_PWD_FILE_OPTION)) { System.out.println(String.format("both -%s and -%s are provided. Using -%s", MASTER_PWD_OPTION, MASTER_PWD_FILE_OPTION, MASTER_PWD_OPTION)); }// w ww.ja va 2s . co m return cl.getOptionValue(MASTER_PWD_OPTION); } Path masterPwdLoc = new Path(cl.getOptionValue(MASTER_PWD_FILE_OPTION)); Optional<String> masterPwd = PasswordManager.getMasterPassword(masterPwdLoc); if (masterPwd.isPresent()) { return masterPwd.get(); } throw new RuntimeException("Failed to get master password from " + masterPwdLoc); }