Example usage for com.google.common.base Optional of

List of usage examples for com.google.common.base Optional of

Introduction

In this page you can find the example usage for com.google.common.base Optional of.

Prototype

public static <T> Optional<T> of(T reference) 

Source Link

Document

Returns an Optional instance containing the given non-null reference.

Usage

From source file:extrabiomes.module.fabrica.block.ItemWoodSlab.java

static void setSlabs(BlockHalfSlab singleSlab, BlockHalfSlab doubleSlab) {
    ItemWoodSlab.singleSlab = Optional.of(singleSlab);
    ItemWoodSlab.doubleSlab = Optional.of(doubleSlab);
}

From source file:extrabiomes.module.fabrica.block.ItemRedRockSlab.java

static void setSlabs(BlockHalfSlab singleSlab, BlockHalfSlab doubleSlab) {
    ItemRedRockSlab.singleSlab = Optional.of(singleSlab);
    ItemRedRockSlab.doubleSlab = Optional.of(doubleSlab);
}

From source file:extrabiomes.module.fabrica.block.ItemNewWoodSlab.java

static void setSlabs(BlockSlab singleSlab, BlockSlab doubleSlab) {
    ItemNewWoodSlab.singleSlab = Optional.of(singleSlab);
    ItemNewWoodSlab.doubleSlab = Optional.of(doubleSlab);
}

From source file:testpackage.OptionalWrapper.java

public static Optional<String> some() {
    return Optional.of("some");
}

From source file:myokun.mods.elex.worldgen.biome.Biomes.java

private static void initializeBiomes() {
    evaporitePlains = Optional.of((new BiomeGenVaporitePlains(ConfigurationSettings.EVAPORITE_PLAINS_ID))
            .setColor(9286496).setBiomeName("Evaporite Plains").setTemperatureRainfall(0.8F, 0.4F));
}

From source file:springfox.documentation.schema.ClassSupport.java

public static Optional<? extends Class> classByName(String className) {
    try {/*  w  ww  . j  a  v a  2s  . com*/
        return Optional.of(Class.forName(className));
    } catch (ClassNotFoundException e) {
        return Optional.absent();
    }
}

From source file:extrabiomes.handlers.ItemHandler.java

private static void createLogTurner() {
    final int itemID = ItemSettings.LOGTURNER.getID();
    if (!ModuleControlSettings.SUMMA.isEnabled() || itemID <= 0)
        return;//from  w ww.  j  a va  2  s . c o  m

    final LogTurner logTurner = new LogTurner(itemID);

    Stuff.logTurner = Optional.of(logTurner);

    logTurner.setUnlocalizedName("extrabiomes.logturner").setCreativeTab(Extrabiomes.tabsEBXL);

    Element.LOGTURNER.set(new ItemStack(logTurner));
}

From source file:extrabiomes.module.summa.biome.WeightedRandomChooser.java

static <T extends WeightedRandomItem> Optional<T> getRandomItem(Random rand, Collection<T> collection,
        int limit) {
    if (limit > 0) {
        int choice = rand.nextInt(limit);

        for (final T item : collection) {
            choice -= item.itemWeight;/* w  w  w.  ja va  2s .  c o  m*/
            if (choice < 0)
                return Optional.of(item);
        }
    }

    return Optional.absent();
}

From source file:org.gluu.oxtrust.model.helper.SCIMHelper.java

/**
 * try to extract an email from the User. 
 * If the User has a primary email address this email will be returned.
 * If not the first email address found will be returned.
 * If no Email has been found email.isPresent() == false 
 * @param user a {@link User} with a possible email
 * @return an email if found//from ww w .  j  av a  2s. co m
 */
public static Optional<Email> getPrimaryOrFirstEmail(User user) {
    for (Email email : user.getEmails()) {
        if (email.isPrimary()) {
            return Optional.of(email);
        }
    }

    if (user.getEmails().size() > 0) {
        return Optional.of(user.getEmails().get(0));
    }
    return Optional.absent();
}

From source file:org.eclipse.epp.internal.logging.aeri.ui.utils.Shells.java

public static Optional<Shell> getWorkbenchWindowShell() {
    IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (workbenchWindow != null) {
        Shell shell = workbenchWindow.getShell();
        if (shell != null) {
            return Optional.of(shell);
        }/*www  .  j a  v a  2 s.co m*/
    }
    return Optional.absent();
}