List of usage examples for com.google.common.base Optional get
public abstract T get();
From source file:org.sonar.server.computation.measure.BatchMeasureToMeasure.java
private static Optional<Measure> toLevelMeasure(Measure.NewMeasureBuilder builder, BatchReport.Measure batchMeasure) { if (!batchMeasure.hasStringValue()) { return toNoValueMeasure(builder, batchMeasure); }/*from w ww . jav a 2 s. c o m*/ Optional<Measure.Level> level = Measure.Level.toLevel(batchMeasure.getStringValue()); if (!level.isPresent()) { return toNoValueMeasure(builder, batchMeasure); } return of(builder.create(level.get())); }
From source file:io.mesosphere.mesos.util.ProtoUtils.java
@NotNull public static TreeSet<Long> resourceValueRange(@NotNull final Optional<Resource> resource) { if (resource.isPresent()) { return resourceValueRange(resource.get()); } else {/*from w ww.ja v a 2 s . c o m*/ return newTreeSet(); } }
From source file:dagger2.internal.codegen.Util.java
/** * Wraps an {@link Optional} of a type in an {@code Optional} of a {@link Wrapper} for that type. *//*from w w w . j av a 2s.c o m*/ static <T> Optional<Equivalence.Wrapper<T>> wrapOptionalInEquivalence(Equivalence<T> equivalence, Optional<T> optional) { return optional.isPresent() ? Optional.of(equivalence.wrap(optional.get())) : Optional.<Equivalence.Wrapper<T>>absent(); }
From source file:org.dswarm.graph.gdm.utils.NodeTypeUtils.java
public static Optional<NodeType> getNodeType(final Optional<Node> optionalNode, final Optional<Boolean> optionalIsType) { if (!optionalNode.isPresent()) { return Optional.absent(); }//w ww.j a va2 s . co m return getNodeTypeByGDMNodeType(Optional.of(optionalNode.get().getType()), optionalIsType); }
From source file:org.anhonesteffort.flock.NotificationDrawer.java
public static void showSubscriptionExpiredNotification(Context context) { Log.w(TAG, "showSubscriptionExpiredNotification()"); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context); Intent clickIntent = new Intent(context, ManageSubscriptionActivity.class); notificationBuilder.setContentTitle(context.getString(R.string.notification_flock_subscription_expired)); notificationBuilder.setContentText(context.getString(R.string.notification_tap_to_update_subscription)); notificationBuilder.setSmallIcon(R.drawable.flock_actionbar_icon); notificationBuilder.setAutoCancel(true); Optional<DavAccount> account = DavAccountHelper.getAccount(context); clickIntent.putExtra(ManageSubscriptionActivity.KEY_DAV_ACCOUNT_BUNDLE, account.get().toBundle()); notificationBuilder.setContentIntent(getPendingActivityIntent(context, clickIntent)); getNotificationManager(context).notify(ID_NOTIFICATION_SUBSCRIPTION, notificationBuilder.build()); }
From source file:org.apache.gobblin.source.extractor.extract.google.GoogleCommon.java
private static FileSystem getFileSystem(Optional<String> fsUri) throws IOException { if (fsUri.isPresent()) { return FileSystem.get(URI.create(fsUri.get()), new Configuration()); }//from ww w .j av a2 s.com return FileSystem.get(new Configuration()); }
From source file:org.semanticweb.owlapi.util.OWLAPIPreconditions.java
/** * check for absent and throw IllegalArgumentException if null or absent * /* w w w. j a v a2 s .com*/ * @param object * reference to check * @param message * message for the illegal argument exception * @param <T> * reference type * @return the input reference if not null * @throws IllegalArgumentException * if object is null */ @Nonnull public static <T> T checkNotNull(Optional<T> object, @Nonnull String message) { if (object == null || !object.isPresent()) { throw new IllegalArgumentException(message); } return verifyNotNull(object.get()); }
From source file:org.anhonesteffort.flock.crypto.KeyHelper.java
public static void generateAndSaveSaltAndKeyMaterial(Context context) throws IOException, GeneralSecurityException { Log.d(TAG, "GENERATING SALT AND KEY MATERIAL!"); byte[] cipherKey = KeyUtil.generateCipherKey(); byte[] macKey = KeyUtil.generateMacKey(); byte[] salt = KeyUtil.generateSalt(); Log.d(TAG, "SAVING SALT AND KEY MATERIAL!"); KeyStore.saveCipherKey(context, cipherKey); KeyStore.saveMacKey(context, macKey); KeyStore.saveKeyMaterialSalt(context, salt); Optional<String> encryptedKeyMaterial = buildEncryptedKeyMaterial(context); if (encryptedKeyMaterial.isPresent()) KeyStore.saveEncryptedKeyMaterial(context, encryptedKeyMaterial.get()); }
From source file:extrabiomes.handlers.ConfigurationHandler.java
public static void init(File configFile) { Optional<EnhancedConfiguration> optionalConfig = Optional.absent(); try {//from w w w . j av a 2 s.co m optionalConfig = Optional.of(new EnhancedConfiguration(configFile)); final EnhancedConfiguration configuration = optionalConfig.get(); for (final BiomeSettings setting : BiomeSettings.values()) { setting.load(configuration); } for (final DecorationSettings setting : DecorationSettings.values()) { setting.load(configuration); } for (final BlockSettings setting : BlockSettings.values()) { setting.load(configuration); } for (final ItemSettings setting : ItemSettings.values()) { setting.load(configuration); } configuration.addCustomCategoryComment("saplingreplanting", "Settings to configure the chance that saplings will replant themselves up despawning on valid soil."); for (final SaplingSettings setting : SaplingSettings.values()) { setting.load(configuration); } for (final ModuleControlSettings setting : ModuleControlSettings.values()) { setting.load(configuration); } Property bigTreeSaplingDropRateProperty = configuration.get(Configuration.CATEGORY_GENERAL, "Relative sapling drops", false); bigTreeSaplingDropRateProperty.comment = "Setting relative sapling drops to true will decrease the amount of saplings dropped by decaying fir and redwood leaf blocks to a more reasonable amount."; GeneralSettings.bigTreeSaplingDropModifier = bigTreeSaplingDropRateProperty.getBoolean(false); // Property consoleCommandsDisabled = configuration.get(Configuration.CATEGORY_GENERAL, "DisableConsoleCommands", true); consoleCommandsDisabled.comment = "Set to false to enable console commands."; GeneralSettings.consoleCommandsDisabled = consoleCommandsDisabled.getBoolean(true); } catch (final Exception e) { LogHelper.log(Level.SEVERE, e, "%s had had a problem loading its configuration", Reference.MOD_NAME); } finally { if (optionalConfig.isPresent()) optionalConfig.get().save(); } }
From source file:net.caseif.voxem.world.Block.java
public static boolean isAir(Optional<Block> block) { return !block.isPresent() || block.get().getType() == Material.AIR; }