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

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

Introduction

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

Prototype

public static <T> Optional<T> fromNullable(@Nullable T nullableReference) 

Source Link

Document

If nullableReference is non-null, returns an Optional instance containing that reference; otherwise returns Optional#absent .

Usage

From source file:com.github.rinde.rinsim.event.Event.java

/**
 * Create a new event instance.// ww w . ja va  2s  .  c  o  m
 * @param type the event type.
 * @param pIssuer The event issuer, may be null.
 */
public Event(Enum<?> type, @Nullable Object pIssuer) {
    eventType = type;
    issuer = Optional.fromNullable(pIssuer);
}

From source file:com.facebook.buck.rules.ProjectConfigBuilder.java

public ProjectConfigBuilder setSrcRule(@Nullable BuildRule srcRule) {
    arg.srcTarget = Optional.fromNullable(srcRule);
    return this;
}

From source file:com.vino.repositories.CellarRepository.java

public Optional<WineCellar> getCellarByKey(String key) {
    return Optional
            .fromNullable(collections.from(EntityType.CELLAR).findOne(new ObjectId(key)).as(WineCellar.class));
}

From source file:org.locationtech.geogig.plumbing.diff.DiffPathTracker.java

public Optional<Node> currentRightTree() {
    return Optional.fromNullable(rightTrees.peek());
}

From source file:org.geogit.api.RevPerson.java

/**
 * @return the name
 */
public Optional<String> getName() {
    return Optional.fromNullable(name);
}

From source file:ph.devcon.android.speaker.fragment.SpeakerOnlyFragment.java

@Override
public void onResume() {
    super.onResume();
    FetchedSpeakerListEvent event = eventBus.getStickyEvent(FetchedSpeakerListEvent.class);
    Optional<FetchedSpeakerListEvent> eventOptional = Optional.fromNullable(event);
    if (eventOptional.isPresent()) {
        setSpeakerList(eventOptional.get().speakers);
    }/*  ww  w. jav  a  2 s  .c o  m*/
}

From source file:org.n52.shetland.aqd.EReportingChange.java

public EReportingChange(boolean changed, String description) {
    this.changed = changed;
    this.description = Optional.fromNullable(description);
}

From source file:org.eclipse.che.plugin.languageserver.ide.editor.signature.SignatureHelpImpl.java

public SignatureHelpImpl(SignatureHelpDTO dto) {
    activeParameter = Optional.fromNullable(dto.getActiveParameter());
    activeSignature = Optional.fromNullable(dto.getActiveSignature());
    signatureInfos = new ArrayList<>(dto.getSignatures().size());
    for (SignatureInformationDTO signatureInformationDTO : dto.getSignatures()) {
        signatureInfos.add(new SignatureInfoImpl(signatureInformationDTO));
    }//  w  w  w.j a  v  a  2s.  c  o m
}

From source file:org.croudtrip.db.AbstractDAO.java

public final Optional<T> findById(long id) {
    return Optional.fromNullable(get(id));
}

From source file:se.sics.ktoolbox.util.Either.java

public Optional<R> getOptionalRight() {
    if (this.isRight()) {
        return Optional.fromNullable(this.getRight());
    } else {/*w ww . ja  va2  s .  c  om*/
        return Optional.absent();
    }
}