本文整理汇总了Java中com.google.common.base.Optional.absent方法的典型用法代码示例。如果您正苦于以下问题:Java Optional.absent方法的具体用法?Java Optional.absent怎么用?Java Optional.absent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.base.Optional
的用法示例。
在下文中一共展示了Optional.absent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseAttribute
import com.google.common.base.Optional; //导入方法依赖的package包/类
@Override
public Optional<ObjectName> parseAttribute(final String attrName, final Object value) {
if (value == null) {
return Optional.absent();
}
Util.checkType(value, ObjectNameAttributeMappingStrategy.MappedDependency.class);
ObjectNameAttributeMappingStrategy.MappedDependency mappedDep =
(ObjectNameAttributeMappingStrategy.MappedDependency) value;
String serviceName = mappedDep.getServiceName();
String refName = mappedDep.getRefName();
String namespace = mappedDep.getNamespace();
LOG.trace("Getting service instance by service name {} : {} and ref name {}", namespace, serviceName, refName);
ObjectName on = serviceTracker.getByServiceAndRefName(namespace, serviceName, refName);
LOG.debug("Attribute {} : {} parsed to type {}", attrName, value, getOpenType());
return Optional.of(on);
}
示例2: prepareRootRB
import com.google.common.base.Optional; //导入方法依赖的package包/类
protected RuntimeBeanEntry prepareRootRB(final List<RuntimeBeanEntry> children) {
final DataNodeContainer nodeContainer = mock(DataNodeContainer.class);
doReturn("DataSchemaNode").when(nodeContainer).toString();
return new RuntimeBeanEntry("pa.cka.ge", nodeContainer,
"module-name", "ModuleName", true, Optional.<String> absent(),
Collections.<AttributeIfc> emptyList(), children,
Collections.<Rpc> emptySet());
}
示例3: RestoreSnapshot
import com.google.common.base.Optional; //导入方法依赖的package包/类
public RestoreSnapshot(QualifiedName name,
@Nullable GenericProperties genericProperties) {
this.name = name;
this.properties = Optional.fromNullable(genericProperties);
this.tableList = Optional.absent();
}
示例4: getSqlTypeFamily
import com.google.common.base.Optional; //导入方法依赖的package包/类
public static Optional<SqlTypeFamily> getSqlTypeFamily(final LayoutField field) {
try {
return Optional.of(SqlTypeFamily.valueOf(field.getTypeFamily()));
} catch (final IllegalArgumentException ex) {
return Optional.absent();
}
}
示例5: FeedbackBlend
import com.google.common.base.Optional; //导入方法依赖的package包/类
@Inject
public FeedbackBlend(FeedbackBlendView view, FeedbackStyleNameConstants styleNameConstants, RootPanelDelegate rootPanelDelegate,
UserInteractionHandlerFactory userInteractionHandlerFactory, TouchReservationCommand touchReservationCommand) {
this.view = view;
this.styleNameConstants = styleNameConstants;
textFeedback = Optional.absent();
rootPanelDelegate.getRootPanel().add(view.asWidget());
userInteractionHandlerFactory.applyUserClickHandler(createClickCommand(), view.asWidget());
EventHandlerProxy userTouchStartHandler = userInteractionHandlerFactory.createUserTouchStartHandler(touchReservationCommand);
userTouchStartHandler.apply(view.asWidget());
}
示例6: getCurrentValue
import com.google.common.base.Optional; //导入方法依赖的package包/类
private <T> Optional<SimpleMdsValue<T>> getCurrentValue(final List<SimpleMdsValue<T>> simpleMdsValues, UserAccountCreationAttribute userAccountCreationAttribute) {
List<SimpleMdsValue<T>> currentValues = ImmutableList.copyOf(simpleMdsValues.stream()
.filter(simpleMdsValue -> simpleMdsValue.getTo() == null)
.collect(toList()));
if (currentValues.size() > 1) {
String message = MessageFormat.format("There cannot be multiple current values for {0} attribute.", userAccountCreationAttribute.getAttributeName());
throw new WebApplicationException(new IllegalStateException(message), Response.Status.INTERNAL_SERVER_ERROR);
}
if (currentValues.isEmpty()) {
return Optional.absent();
}
return Optional.of(currentValues.get(0));
}
开发者ID:alphagov,项目名称:verify-matching-service-adapter,代码行数:14,代码来源:UserAccountCreationAttributeExtractor.java
示例7: getLayout
import com.google.common.base.Optional; //导入方法依赖的package包/类
private Optional<Layout> getLayout(final Acceleration acceleration, LayoutId layoutId) {
for (Layout layout : AccelerationUtils.getAllLayouts(acceleration)) {
if (layout.getId().equals(layoutId)) {
return Optional.fromNullable(layout);
}
}
return Optional.absent();
}
示例8: aNoMatchResponseHasBeenReceivedAndUserAccountCreationIsEnabled
import com.google.common.base.Optional; //导入方法依赖的package包/类
private void aNoMatchResponseHasBeenReceivedAndUserAccountCreationIsEnabled(SessionId sessionId) throws JsonProcessingException {
SamlResponseDto msaSamlResponseDto = new SamlResponseDto("a-saml-response");
InboundResponseFromMatchingServiceDto inboundResponseFromMatchingServiceDto =
new InboundResponseFromMatchingServiceDto(MatchingServiceIdaStatus.NoMatchingServiceMatchFromMatchingService,
translatedAuthnRequest.getId(),
msaEntityId,
Optional.<String>absent(),
Optional.<LevelOfAssurance>absent());
samlEngineStub.setupStubForAttributeResponseTranslate(inboundResponseFromMatchingServiceDto);
List<UserAccountCreationAttribute> userAccountCreationAttributes = ImmutableList.of(UserAccountCreationAttribute.CURRENT_ADDRESS);
configStub.setUpStubForUserAccountCreation(rpEntityId, userAccountCreationAttributes);
URI uri = UriBuilder.fromPath(Urls.PolicyUrls.ATTRIBUTE_QUERY_RESPONSE_RESOURCE).build(sessionId);
postResponse(policy.uri(uri.toASCIIString()), msaSamlResponseDto);
}
示例9: getOnlyChildElementWithSameNamespaceOptionally
import com.google.common.base.Optional; //导入方法依赖的package包/类
public Optional<XmlElement> getOnlyChildElementWithSameNamespaceOptionally() {
Optional<XmlElement> child = getOnlyChildElementOptionally();
if (child.isPresent()
&& child.get().getNamespaceOptionally().isPresent()
&& getNamespaceOptionally().isPresent()
&& getNamespaceOptionally().get().equals(child.get().getNamespaceOptionally().get())) {
return child;
}
return Optional.absent();
}
示例10: createTree
import com.google.common.base.Optional; //导入方法依赖的package包/类
@Override
Optional<BinaryNode> createTree(int size, Random rng) {
Optional<BinaryNode> root = Optional.absent();
for (int i = 0; i < size; i++) {
root = Optional.of(new BinaryNode(rng.nextInt(), root, Optional.<BinaryNode>absent()));
}
return root;
}
示例11: getErrorMessage
import com.google.common.base.Optional; //导入方法依赖的package包/类
@Override
public Optional<String> getErrorMessage(Object objectValue, Annotation annotation) {
if (isCorrect(objectValue, annotation))
return Optional.absent();
return Optional.of(TranslationConfig.getTranslation(Message.NOT_NULL_ERROR_MESSAGE));
}
示例12: shouldNotSetState_whenIsEmpty
import com.google.common.base.Optional; //导入方法依赖的package包/类
@Test
public void shouldNotSetState_whenIsEmpty() {
// given
Optional<JavaScriptObject> jsoOptional = Optional.absent();
when(stateSaver.getExternalState()).thenReturn(jsoOptional);
// when
testObj.setSavedStateInExternal(externalApi);
// then
verify(externalApi, never()).setStateOnExternal(any(JavaScriptObject.class));
}
示例13: typeAdaptersProvider
import com.google.common.base.Optional; //导入方法依赖的package包/类
@Value.Lazy
public Optional<AbstractDeclaring> typeAdaptersProvider() {
Optional<DeclaringType> typeDefining =
declaringType().isPresent()
? Optional.of(declaringType().get().associatedTopLevel())
: Optional.<DeclaringType>absent();
Optional<TypeAdaptersMirror> typeDefined =
typeDefining.isPresent()
? typeDefining.get().typeAdapters()
: Optional.<TypeAdaptersMirror>absent();
Optional<TypeAdaptersMirror> packageDefined = packageOf().typeAdapters();
if (packageDefined.isPresent()) {
if (typeDefined.isPresent()) {
report()
.withElement(typeDefining.get().element())
.annotationNamed(TypeAdaptersMirror.simpleName())
.warning("@%s is also used on the package, this type level annotation is ignored",
TypeAdaptersMirror.simpleName());
}
return Optional.<AbstractDeclaring>of(packageOf());
}
return typeDefined.isPresent()
? Optional.<AbstractDeclaring>of(typeDefining.get())
: Optional.<AbstractDeclaring>absent();
}
示例14: load
import com.google.common.base.Optional; //导入方法依赖的package包/类
@Override
public Optional<T> load(final Class<? extends T> key) {
final AdapterBuilder<? extends T, D> builder = createBuilder(key);
for(final Class<? extends D> reqDeleg : builder.getRequiredDelegates()) {
final D deleg = getDelegate(reqDeleg);
if(deleg != null) {
builder.addDelegate(reqDeleg,deleg);
} else {
return Optional.absent();
}
}
return Optional.<T>of(builder.build());
}
示例15: getParent
import com.google.common.base.Optional; //导入方法依赖的package包/类
public Optional<? extends IJoint> getParent()
{
return Optional.absent();
}