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:com.dangdang.ddframe.rdb.sharding.parser.result.merger.OrderByColumn.java

public OrderByColumn(final String name, final OrderByType orderByType) {
    super(Optional.<String>absent(), Optional.of(name), Optional.<String>absent(), orderByType);
    index = Optional.absent();/* w ww  .  j  a  va2 s .  co m*/
}

From source file:dagger.internal.codegen.KeyFormatter.java

@Override
public String format(Key request) {
    if (request.bindingMethod().isPresent()) {
        // If there's a binding method, its signature is enough.
        SourceElement bindingMethod = request.bindingMethod().get();
        return methodSignatureFormatter.format(MoreElements.asExecutable(bindingMethod.element()),
                Optional.of(MoreTypes.asDeclared(bindingMethod.contributedBy().get().asType())));
    }/*from   w ww .ja v a2 s.  com*/
    StringBuilder builder = new StringBuilder();
    if (request.qualifier().isPresent()) {
        builder.append(request.qualifier().get());
        builder.append(' ');
    }
    builder.append(request.type());
    return builder.toString();
}

From source file:org.geogit.osm.internal.log.ReadOSMMapping.java

@Override
public Optional<Mapping> call() {
    Preconditions.checkNotNull(entry);//from   ww w  .  ja  va 2  s .c  o m
    final File osmMapFolder = command(ResolveOSMMappingLogFolder.class).call();
    File file = new File(osmMapFolder, entry.getPostMappingId().toString());
    if (!file.exists()) {
        return Optional.absent();
    }
    try {
        List<String> lines = Files.readLines(file, Charsets.UTF_8);
        String s = Joiner.on("\n").join(lines);
        Mapping mapping = Mapping.fromString(s);
        return Optional.of(mapping);
    } catch (IOException e) {
        throw Throwables.propagate(e);
    }
}

From source file:com.urswolfer.intellij.plugin.gerrit.ui.filter.StatusFilter.java

public StatusFilter() {
    value = Optional.of(statuses.get(1));
}

From source file:appeng.items.tools.quartz.ToolQuartzAxe.java

public ToolQuartzAxe(final AEFeature type) {
    super(ToolMaterial.IRON);
    this.feature = new ItemFeatureHandler(EnumSet.of(this.type = type, AEFeature.QuartzAxe), this, this,
            Optional.of(type.name()));
}

From source file:org.robotninjas.util.callable.DecoratedCallableFunction.java

void setRetryer(Retryer<V> retryer) {
    this.retryer = Optional.of(retryer);
}

From source file:com.hellblazer.glassHouse.demo.ExampleAuthenticator.java

@Override
public Optional<AuthenticatedUser> authenticate(final BasicCredentials credentials)
        throws AuthenticationException {
    if ("secret".equals(credentials.getPassword())) {
        AuthenticatedUser user = new AuthenticatedUser() {
            private final String name = credentials.getUsername();

            @Override/*from  w  w w .ja  v  a 2 s .  c o m*/
            public String getName() {
                return name;
            }
        };
        return Optional.of(user);
    }
    return Optional.absent();
}

From source file:appeng.items.tools.quartz.ToolQuartzSword.java

public ToolQuartzSword(final AEFeature type) {
    super(ToolMaterial.IRON);
    this.feature = new ItemFeatureHandler(EnumSet.of(this.type = type, AEFeature.QuartzSword), this, this,
            Optional.of(type.name()));
}

From source file:org.jboss.aerogear.controller.router.rest.pagination.PaginationProperties.java

public PaginationProperties(final int offset, final int limit, final int total) {
    checkValues(offset, limit);/*from   w ww  .ja  v a 2  s.c  o  m*/
    this.offset = offset;
    this.limit = limit;
    this.total = total == -1 ? Optional.<Integer>absent() : Optional.of(Integer.valueOf(total));
}

From source file:com.dowdandassociates.gentoo.bootstrap.JSchProvider.java

public Optional<JSch> get() {
    log.info("Get JSch");
    try {//from  w  ww.j a  va  2s . co  m
        JSch jsch = new JSch();

        jsch.addIdentity(keyPair.getFilename());

        return Optional.of(jsch);
    } catch (JSchException jse) {
        log.error(jse.getMessage(), jse);
        return Optional.absent();
    }
}