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

org.apache.myfaces.flow.builder.SwitchCaseBuilderImpl Maven / Gradle / Ivy

Go to download

The private implementation classes of the Apache MyFaces Core JSF-2.3-next Implementation

There is a newer version: 4.1.0-RC2
Show newest version
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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 org.apache.myfaces.flow.builder;

import javax.el.ValueExpression;
import javax.faces.flow.builder.SwitchCaseBuilder;
import org.apache.myfaces.flow.FlowImpl;
import org.apache.myfaces.flow.SwitchCaseImpl;
import org.apache.myfaces.flow.SwitchNodeImpl;
import org.apache.myfaces.view.facelets.el.ELText;

/**
 *
 * @since 2.2
 * @author Leonardo Uribe
 */
public class SwitchCaseBuilderImpl extends SwitchCaseBuilder
{
    private FlowBuilderImpl _flowBuilder;
    private FlowImpl _facesFlow;
    private SwitchBuilderImpl _switchBuilderImpl;
    private SwitchNodeImpl _switchNodeImpl;
    private SwitchCaseImpl _switchCase;

    public SwitchCaseBuilderImpl(FlowBuilderImpl flowBuilder, FlowImpl facesFlow, 
        SwitchBuilderImpl switchBuilderImpl, SwitchNodeImpl switchNode)
    {
        this._flowBuilder = flowBuilder;
        this._facesFlow = facesFlow;
        this._switchBuilderImpl = switchBuilderImpl;
        this._switchNodeImpl = switchNode;
        this._switchCase = null;
    }
    
    @Override
    public SwitchCaseBuilder condition(String expression)
    {
        if (ELText.isLiteral(expression))
        {
            this._switchCase.setCondition(Boolean.valueOf(expression));
        }
        else
        {
            this._switchCase.setCondition(_flowBuilder.createValueExpression(expression));
        }
        return this;
    }

    @Override
    public SwitchCaseBuilder condition(ValueExpression expression)
    {
        this._switchCase.setCondition(expression);
        return this;
    }

    @Override
    public SwitchCaseBuilder fromOutcome(String outcome)
    {
        this._switchCase.setFromOutcome(outcome);
        return this;
    }

    @Override
    public SwitchCaseBuilder switchCase()
    {
        this._switchCase =  new SwitchCaseImpl();
        this._switchNodeImpl.addCase(this._switchCase);
        return this;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy