All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.theangrydev.businessflows.SadCaseSadPath Maven / Gradle / Ivy

/*
 * Copyright 2016 Liam Williams .
 *
 * This file is part of business-flows.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.github.theangrydev.businessflows;

import java.util.Optional;

/**
 * A {@link SadCaseSadPath} is a {@link SadPath} that is actually a {@link SadCase}.
 * 

* {@inheritDoc} */ class SadCaseSadPath extends SadCase implements SadPath { SadCaseSadPath(Sad sad) { super(sad); } @Override public Optional toOptional() { return Optional.of(sad); } @Override public TechnicalFailure ifTechnicalFailure() { return TechnicalFailure.sadPath(sad); } @Override public HappyPath ifHappy() { return HappyPath.sadPath(sad); } @Override public SadPath then(Mapping> action) { try { return action.map(sad).ifSad(); } catch (Exception e) { return SadPath.technicalFailure(e); } } @Override public SadPath map(Mapping mapping) { try { return SadPath.sadPath(mapping.map(sad)); } catch (Exception e) { return SadPath.technicalFailure(e); } } @Override public HappyPath recover(Mapping recovery) { try { return HappyPath.happyPath(recovery.map(sad)); } catch (Exception e) { return HappyPath.technicalFailure(e); } } @Override public HappyPath recover(Attempt recovery) { try { return HappyPath.happyPath(recovery.attempt()); } catch (Exception e) { return HappyPath.technicalFailure(e); } } @Override public SadPath peek(Peek peek) { try { peek.peek(sad); return this; } catch (Exception e) { return SadPath.technicalFailure(e); } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy