List of usage examples for com.google.common.base Optional of
public static <T> Optional<T> of(T reference)
From source file:li.klass.fhem.service.graph.gplot.GPlotAxisTestdataBuilder.java
public static GPlotAxis defaultGPlotAxis() { GPlotAxis axis = new GPlotAxis("myLabel", Optional.of(Range.atLeast(10D))); axis.addSeries(defaultGPlotSeriesBuilder().withTitle("series1").withAxis(GPlotSeries.Axis.LEFT).build()); axis.addSeries(defaultGPlotSeriesBuilder().withTitle("series2").withAxis(GPlotSeries.Axis.LEFT).build()); return axis;// w ww . j a v a 2 s .c om }
From source file:org.apache.distributedlog.util.CommandLineUtils.java
public static Optional<Boolean> getOptionalBooleanArg(CommandLine cmdline, String arg) { if (cmdline.hasOption(arg)) { return Optional.of(true); } else {//from ww w . j a va2 s .co m return Optional.absent(); } }
From source file:com.google.template.soy.shared.RangeArgs.java
private static RangeArgs create(List<ExprNode> args) { switch (args.size()) { case 1:/*from w w w .j a v a2 s . c o m*/ return new AutoValue_RangeArgs(Optional.<ExprNode>absent(), args.get(0), Optional.<ExprNode>absent()); case 2: return new AutoValue_RangeArgs(Optional.of(args.get(0)), args.get(1), Optional.<ExprNode>absent()); case 3: return new AutoValue_RangeArgs(Optional.of(args.get(0)), args.get(1), Optional.of(args.get(2))); default: throw new AssertionError(); } }
From source file:ch.epfl.eagle.daemon.util.Serialization.java
public static Optional<InetSocketAddress> strToSocket(String in) { String[] parts = in.split(":"); if (parts.length != 2) { return Optional.absent(); }//from w ww. ja va 2 s .c o m String host = parts[0]; // This deals with the wonky way Java InetAddress toString() represents an address: // "hostname/IP" if (parts[0].contains("/")) { host = parts[0].split("/")[1]; } try { return Optional.of(new InetSocketAddress(host, Integer.parseInt(parts[1]))); } catch (NumberFormatException e) { return Optional.absent(); } }
From source file:com.github.radium226.common.Either.java
public static <L, R> Either<L, R> right(R right) { return new Either(Optional.absent(), Optional.of(right)); }
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(); }/* ww w . java 2 s.co m*/ return getNodeTypeByGDMNodeType(Optional.of(optionalNode.get().getType()), optionalIsType); }
From source file:li.klass.fhem.domain.CulHmHeatingMode.java
public static Optional<CulHmHeatingMode> heatingModeFor(String value) { if (value.equalsIgnoreCase("MANU")) { value = MANUAL.name();/*from ww w.j a va 2s . c o m*/ } try { return Optional.of(CulHmHeatingMode.valueOf(value.toUpperCase(Locale.getDefault()))); } catch (Exception e) { Log.e(CulHmHeatingMode.class.getName(), "cannot set heating mode from value " + value, e); return Optional.absent(); } }
From source file:com.android.camera.one.v1.LegacyOneCameraOpenerImpl.java
public static Optional<OneCameraOpener> create() { OneCameraOpener cameraManager = new LegacyOneCameraOpenerImpl(); return Optional.of(cameraManager); }
From source file:com.android.camera.captureintent.state.StateIntentCompleted.java
public static StateIntentCompleted from(StateSavingPicture savingPicture, RefCountBase<ResourceConstructed> resourceConstructed, Intent resultIntent) { return new StateIntentCompleted(savingPicture, resourceConstructed, Optional.of(resultIntent)); }
From source file:org.fabrician.enabler.util.BuildCmdOptions.java
public static Optional<String> build(RuntimeContextVariable var) { try {// ww w. ja v a2s.c o m BuildCmdOptions val = valueOf(var.getName()); if (var.getTypeInt() != RuntimeContextVariable.OBJECT_TYPE) { String currentValue = StringUtils.trimToEmpty((String) var.getValue()); // empty value means the option is not valid and would be skipped // so that we accept the default if (!currentValue.isEmpty()) { if (val.isBooleanType) { Boolean b = BooleanUtils.toBooleanObject(currentValue); if (b != val.defaultBooleanValue) { return Optional.of(" " + val.optionSwitch + " "); } } else { return Optional.of(" " + val.optionSwitch + " " + currentValue); } } } } catch (Exception ex) { } return Optional.absent(); }