Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,17 @@
*/
@XmlRootElement(name = "expression") // must be named expression
@XmlAccessorType(XmlAccessType.FIELD)
public class ExpressionSubElementDefinition {
public class ExpressionSubElementDefinition implements HasExpressionType {
@XmlElementRef
private ExpressionDefinition expressionType;

public ExpressionSubElementDefinition() {
}

public ExpressionSubElementDefinition(ExpressionDefinition expressionType) {
this.expressionType = expressionType;
}

public ExpressionSubElementDefinition(Expression expression) {
this.expressionType = new ExpressionDefinition(expression);
}
Expand All @@ -45,10 +49,12 @@ public ExpressionSubElementDefinition(Predicate predicate) {
this.expressionType = new ExpressionDefinition(predicate);
}

@Override
public ExpressionDefinition getExpressionType() {
return expressionType;
}

@Override
public void setExpressionType(ExpressionDefinition expressionType) {
this.expressionType = expressionType;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* 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.camel.model;

import org.apache.camel.model.language.ExpressionDefinition;

/**
* Marker interface to mark a {@link ProcessorDefinition} that supports expressions.
*/
public interface HasExpressionType {

ExpressionDefinition getExpressionType();

void setExpressionType(ExpressionDefinition expressionType);
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.apache.camel.ExpressionFactory;
import org.apache.camel.Predicate;
import org.apache.camel.PredicateFactory;
import org.apache.camel.model.HasExpressionType;
import org.apache.camel.model.ModelCamelContext;
import org.apache.camel.spi.ExpressionFactoryAware;
import org.apache.camel.spi.Metadata;
Expand All @@ -49,7 +50,8 @@
@XmlAccessorType(XmlAccessType.FIELD)
@SuppressWarnings("rawtypes")
public class ExpressionDefinition
implements Expression, Predicate, ExpressionFactory, ExpressionFactoryAware, PredicateFactory, PredicateFactoryAware {
implements Expression, Predicate, ExpressionFactory, ExpressionFactoryAware, PredicateFactory, PredicateFactoryAware,
HasExpressionType {
@XmlAttribute
@XmlID
private String id;
Expand Down Expand Up @@ -149,10 +151,20 @@ protected void setExpressionValue(Expression expressionValue) {
this.expressionValue = expressionValue;
}

@Override
public ExpressionDefinition getExpressionType() {
return expressionType;
}

/**
* Allows derived classes and DSLs to set a lazily created expressionType instance such as if using the
* {@link org.apache.camel.builder.ExpressionClause}
*/
@Override
public void setExpressionType(ExpressionDefinition expressionType) {
this.expressionType = expressionType;
}

public String getTrim() {
return trim;
}
Expand Down Expand Up @@ -181,14 +193,6 @@ public String getLabel() {
return exp != null ? exp : "";
}

/**
* Allows derived classes to set a lazily created expressionType instance such as if using the
* {@link org.apache.camel.builder.ExpressionClause}
*/
protected void setExpressionType(ExpressionDefinition expressionType) {
this.expressionType = expressionType;
}

//
// ExpressionFactory
//
Expand Down