001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.camel; 018 019import javax.xml.bind.annotation.XmlEnum; 020import javax.xml.bind.annotation.XmlType; 021 022/** 023 * Represents the kind of message exchange pattern 024 */ 025@XmlType 026@XmlEnum 027public enum ExchangePattern { 028 InOnly, InOut, InOptionalOut; 029 030 /** 031 * Return true if there can be an IN message 032 */ 033 public boolean isInCapable() { 034 return true; 035 } 036 037 /** 038 * Return true if there can be an OUT message 039 */ 040 public boolean isOutCapable() { 041 switch (this) { 042 case InOnly: 043 return false; 044 default: 045 return true; 046 } 047 } 048 049 /** 050 * Return true if there can be a FAULT message 051 */ 052 public boolean isFaultCapable() { 053 switch (this) { 054 case InOnly: 055 return false; 056 default: 057 return true; 058 } 059 } 060 061 public static ExchangePattern asEnum(String value) { 062 try { 063 return valueOf(value); 064 } catch (Exception e) { 065 throw new IllegalArgumentException("Unknown message exchange pattern: " + value, e); 066 } 067 } 068 069}