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.model;
018
019import java.util.List;
020import java.util.Map;
021import java.util.stream.Collectors;
022
023import javax.xml.bind.annotation.XmlAccessType;
024import javax.xml.bind.annotation.XmlAccessorType;
025import javax.xml.bind.annotation.XmlElement;
026import javax.xml.bind.annotation.XmlRootElement;
027
028import org.apache.camel.spi.Metadata;
029
030/**
031 * Models a series of string key/value pairs for configuring some global options
032 * on a Camel context such as max debug log length.
033 */
034@Metadata(label = "configuration")
035@XmlRootElement(name = "globalOptions")
036@XmlAccessorType(XmlAccessType.FIELD)
037public class GlobalOptionsDefinition {
038    @XmlElement(name = "globalOption")
039    private List<GlobalOptionDefinition> globalOptions;
040
041    public GlobalOptionsDefinition() {
042    }
043
044    /**
045     * A series of global options as key value pairs
046     */
047    public void setGlobalOptions(List<GlobalOptionDefinition> globalOptions) {
048        this.globalOptions = globalOptions;
049    }
050
051    public List<GlobalOptionDefinition> getGlobalOptions() {
052        return globalOptions;
053    }
054
055    public Map<String, String> asMap() {
056        return getGlobalOptions().stream().collect(Collectors.toMap(o -> o.getKey(), o -> o.getValue(), (o1, o2) -> o2));
057    }
058
059}