    001    // Copyright 2007 The Apache Software Foundation
    002    //
    003    // Licensed under the Apache License, Version 2.0 (the "License");
    004    // you may not use this file except in compliance with the License.
    005    // You may obtain a copy of the License at
    006    //
    007    //     http://www.apache.org/licenses/LICENSE-2.0
    008    //
    009    // Unless required by applicable law or agreed to in writing, software
    010    // distributed under the License is distributed on an "AS IS" BASIS,
    011    // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    012    // See the License for the specific language governing permissions and
    013    // limitations under the License.
    014
    015    package org.apache.tapestry5.internal;
    016
    017    import org.apache.tapestry5.OptionGroupModel;
    018    import org.apache.tapestry5.OptionModel;
    019
    020    import java.util.List;
    021    import java.util.Map;
    022
    023    public final class OptionGroupModelImpl implements OptionGroupModel
    024    {
    025        private final String label;
    026
    027        private final boolean disabled;
    028
    029        private final List<OptionModel> options;
    030
    031        private final Map<String, String> attributes;
    032
    033        public OptionGroupModelImpl(String label, boolean disabled, List<OptionModel> options,
    034                                    String... attributeKeysAndValues)
    035        {
    036            this(label, disabled, options, attributeKeysAndValues.length == 0 ? null : TapestryInternalUtils
    037                    .mapFromKeysAndValues(attributeKeysAndValues));
    038        }
    039
    040        public OptionGroupModelImpl(String label, boolean disabled, List<OptionModel> options,
    041                                    Map<String, String> attributes)
    042        {
    043            this.label = label;
    044            this.disabled = disabled;
    045            this.options = options;
    046            this.attributes = attributes;
    047        }
    048
    049        public Map<String, String> getAttributes()
    050        {
    051            return attributes;
    052        }
    053
    054        public String getLabel()
    055        {
    056            return label;
    057        }
    058
    059        public List<OptionModel> getOptions()
    060        {
    061            return options;
    062        }
    063
    064        public boolean isDisabled()
    065        {
    066            return disabled;
    067        }
    068
    069        @Override
    070        public String toString()
    071        {
    072            return String.format("OptionGroupModel[%s]", label);
    073        }
    074
    075    }