List of usage examples for com.google.common.base Optional get
public abstract T get();
From source file:org.icgc.dcc.submission.service.MongoMaxSizeHack.java
static Optional<FileReport> augmentScriptErrors(Optional<FileReport> optional, ReleaseRepository releaseRepository, DictionaryRepository dictionaryRepository) { if (optional.isPresent()) { val fileReport = optional.get(); val errorReports = fileReport.getErrorReports(); val dictionary = dictionaryRepository .findDictionaryByVersion(releaseRepository.findNextReleaseDictionaryVersion()); val fileType = fileReport.getFileType(); val fileSchema = dictionary.getFileSchema(fileType); for (val errorReport : errorReports) { if (errorReport.getErrorType() == SCRIPT_ERROR) { for (val fieldReport : errorReport.getFieldErrorReports()) { fieldReport.addParameter(EXPECTED, getScript(fileSchema, getScriptRestrictionFieldName(fieldReport))); }//from w ww. java2s. c o m } } } return optional; }
From source file:be.nbb.demetra.dfm.output.news.NewsWeightsViewFactory.java
private static ItemUI<IProcDocumentView<VersionedDfmDocument>, Optional<DfmNews>> newItemUI() { return new DefaultItemUI<IProcDocumentView<VersionedDfmDocument>, Optional<DfmNews>>() { @Override//from w w w.j av a 2 s .c o m public JComponent getView(IProcDocumentView<VersionedDfmDocument> host, Optional<DfmNews> information) { if (information.isPresent()) { NewsWeightsView v = new NewsWeightsView(); v.setResults(host.getDocument().getCurrent().getDfmResults(), information.get()); return v; } else { JLabel label = new JLabel("No results found", JLabel.CENTER); label.setFont(label.getFont().deriveFont(18f)); return label; } } }; }
From source file:net.es.nsi.pce.pf.PfUtils.java
private static String getStringValue(String attributeName, AttrConstraints constraints) { Optional<String> value = getValue(constraints.getStringAttrConstraint(attributeName)); if (value.isPresent()) { return value.get(); }//from www . j a v a2 s .co m throw Exceptions.missingParameter(Point2PointTypes.P2PS, attributeName, null); }
From source file:be.nbb.demetra.dfm.output.news.NewsImpactsViewFactory.java
private static ItemUI<IProcDocumentView<VersionedDfmDocument>, Optional<DfmNews>> newItemUI() { return new DefaultItemUI<IProcDocumentView<VersionedDfmDocument>, Optional<DfmNews>>() { @Override//w ww . j a va2s .c o m public JComponent getView(IProcDocumentView<VersionedDfmDocument> host, Optional<DfmNews> information) { if (information.isPresent()) { NewsImpactsView v = new NewsImpactsView(); v.setResults(host.getDocument().getCurrent().getDfmResults(), information.get()); return v; } else { JLabel label = new JLabel("No results found", JLabel.CENTER); label.setFont(label.getFont().deriveFont(18f)); return label; } } }; }
From source file:springfox.bean.validators.plugins.BeanValidators.java
public static <T extends Annotation> Optional<T> validatorFromBean(ModelPropertyContext context, Class<T> annotationType) { Optional<BeanPropertyDefinition> propertyDefinition = context.getBeanPropertyDefinition(); Optional<T> notNull = Optional.absent(); if (propertyDefinition.isPresent()) { notNull = annotationFrom(propertyDefinition.get().getGetter(), annotationType) .or(annotationFrom(propertyDefinition.get().getField(), annotationType)); }/*from w w w . ja va 2 s . c om*/ return notNull; }
From source file:com.google.devtools.build.xcode.xcodegen.testing.PbxTypes.java
/** * Converts a PBX file reference to its domain equivalent. *///from w ww. j a v a 2 s . c o m public static FileReference fileReference(PBXReference reference) { FileReference fileReference = FileReference.of(reference.getName(), reference.getPath(), reference.getSourceTree()); if (reference instanceof PBXFileReference) { Optional<String> explicitFileType = ((PBXFileReference) reference).getExplicitFileType(); if (explicitFileType.isPresent()) { return fileReference.withExplicitFileType(explicitFileType.get()); } } return fileReference; }
From source file:edu.berkeley.sparrow.daemon.util.ConfigUtil.java
/** * Parses the list of backends from a {@link Configuration}. * * Returns a map of address of backends to a {@link TResourceVector} describing the * total resource capacity for that backend. *///w w w. ja va 2 s. c o m public static Set<InetSocketAddress> parseBackends(Configuration conf) { if (!conf.containsKey(SparrowConf.STATIC_NODE_MONITORS)) { throw new RuntimeException("Missing configuration node monitor list"); } Set<InetSocketAddress> backends = new HashSet<InetSocketAddress>(); for (String node : conf.getStringArray(SparrowConf.STATIC_NODE_MONITORS)) { Optional<InetSocketAddress> addr = Serialization.strToSocket(node); if (!addr.isPresent()) { LOG.warn("Bad backend address: " + node); continue; } backends.add(addr.get()); } return backends; }
From source file:org.opendaylight.controller.md.sal.dom.store.impl.tree.TreeNodeUtils.java
/** * Finds a node in tree/*from w w w . j a v a 2 s.com*/ * * @param tree Data Tree * @param path Path to the node * @return Optional with node if the node is present in tree, {@link Optional#absent()} otherwise. * */ public static <T extends StoreTreeNode<T>> Optional<T> findNode(final T tree, final InstanceIdentifier path) { Optional<T> current = Optional.<T>of(tree); Iterator<PathArgument> pathIter = path.getPath().iterator(); while (current.isPresent() && pathIter.hasNext()) { current = current.get().getChild(pathIter.next()); } return current; }
From source file:bear.task.TaskResult.java
public static <T extends TaskResult<?>> Optional<T> okOrAbsent(@Nonnull Optional<T> result) { Preconditions.checkNotNull(result);/*from w ww. ja v a2s . c o m*/ if (!result.isPresent() || !result.get().ok()) return Optional.absent(); return result; }
From source file:li.klass.fhem.adapter.devices.core.generic.detail.actions.devices.CulHmDetailActionProvider.java
private static boolean supportsHeating(XmlListDevice xmlListDevice) { Optional<String> controlMode = xmlListDevice.getState(MODE_STATE_NAME); return controlMode.isPresent() && heatingModeFor(controlMode.get()).isPresent(); }