List of usage examples for com.google.common.base Optional fromNullable
public static <T> Optional<T> fromNullable(@Nullable T nullableReference)
From source file:com.facebook.buck.shell.ExportFileBuilder.java
public ExportFileBuilder setSrc(@Nullable SourcePath path) { arg.src = Optional.fromNullable(path); return this; }
From source file:de.flapdoodle.javaparser.tree.Source.java
public Source(Marker marker, JavaPackage jpackage, List<Import> imports, List<AbstractType> types) { super(marker); _types = ImmutableList.copyOf(types); _jpackage = Optional.fromNullable(jpackage); _imports = ImmutableList.copyOf(imports); }
From source file:com.github.jeluard.extend.osgi.OSGILoader.java
private static <T> T setIfAbsentAndReturn(final AtomicReference<Optional<T>> reference, final Supplier<T> callable) { //TODO conc./*from ww w . j av a 2 s. c om*/ final Optional<T> optionalValue = reference.get(); if (optionalValue.isPresent()) { return optionalValue.get(); } final T value = callable.get(); reference.set(Optional.fromNullable(value)); return value; }
From source file:com.googlecode.wmbutil.messages.LocalEnvironment.java
/** * Wrap an existing local environment message, note that this is not the * same {@link MbMessage} as the one containing your data * * @param msg The message to wrap/*from w w w . j a v a 2 s. co m*/ * @return The wrapped message * @throws MbException */ public static Optional<LocalEnvironment> tryWrap(MbMessage msg) throws MbException { return Optional.fromNullable(checkNotNull(msg).getRootElement()) .transform(new Function<MbElement, LocalEnvironment>() { @Override public LocalEnvironment apply(MbElement input) { return new LocalEnvironment(input); } }); }
From source file:io.pelle.mango.client.gwt.modules.hierarchical.HierarchicalTreeModuleUI.java
public HierarchicalTreeModuleUI(HierarchicalTreeModule module) { super(module, HierarchicalTreeModule.MODULE_ID); scrollPanel.setHeight(Window.getClientHeight() / 2 + "px"); scrollPanel.setWidth("100%"); HierarchicalTree hierarchicalTree = new HierarchicalTree(module.getHierarchicalConfiguration(), Optional.fromNullable(getModule().getShowAddNodes()).or(true), getModule().getNodeActivatedHandler()); hierarchicalTree.setWidth("100%"); scrollPanel.add(hierarchicalTree);//ww w. j a va 2s. c o m }
From source file:com.facebook.buck.testutil.FakeReadonlyProjectFilesystem.java
@Override public Optional<String> readFileIfItExists(Path path) { String content = files.get(path.normalize().toString()); return Optional.fromNullable(content); }
From source file:org.terasology.cities.model.MedievalTown.java
/** * @return the town wall, if available */ public Optional<TownWall> getTownWall() { return Optional.fromNullable(townWall); }
From source file:com.pipeline.container.MapContainer.java
@Override public Optional<ByteArray> get(ByteArray key) { return Optional.fromNullable(container.get(key)); }
From source file:org.gradle.ide.xcode.internal.xcodeproj.PBXFileReference.java
public PBXFileReference(String name, String path, SourceTree sourceTree) { super(name, path, sourceTree); // this is necessary to prevent O(n^2) behavior in xcode project loading String fileType = FileTypes.FILE_EXTENSION_TO_UTI.get(Files.getFileExtension(name)); explicitFileType = Optional.fromNullable(fileType); lastKnownFileType = Optional.absent(); }
From source file:com.palantir.atlasdb.keyvalue.api.SweepResults.java
public Optional<byte[]> getNextStartRow() { return Optional.fromNullable(nextStartRow); }