本文整理匯總了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();
}