001    /*
002     * Created on Sep 29, 2006
003     * 
004     * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
005     * in compliance with the License. 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 distributed under the License
010     * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
011     * or implied. See the License for the specific language governing permissions and limitations under
012     * the License.
013     * 
014     * Copyright @2006-2010 the original author or authors.
015     */
016    package org.fest.swing.exception;
017    
018    import java.awt.Component;
019    import java.util.*;
020    
021    /**
022     * Understands an error thrown when looking up a component using a <code>{@link org.fest.swing.core.ComponentFinder}</code>.
023     *
024     * @author Alex Ruiz
025     */
026    public class ComponentLookupException extends RuntimeException {
027    
028      private static final long serialVersionUID = 1L;
029    
030      private final Collection<Component> found = new ArrayList<Component>();
031      
032      /**
033       * Creates a new </code>{@link ComponentLookupException}</code>.
034       * @param message the detail message.
035       * @param found the <code>Component</code>s found by the lookup (if any.)
036       */
037      public ComponentLookupException(String message, Collection<? extends Component> found) {
038        this(message);
039        this.found.addAll(found);
040      }
041    
042      /**
043       * Creates a new <code>{@link ComponentLookupException}</code>.
044       * @param message the detail message.
045       */
046      public ComponentLookupException(String message) {
047        super(message);
048      }
049    
050      /**
051       * Returns the <code>Component</code>s found by the lookup (if any.)
052       * @return the <code>Component</code>s found by the lookup (if any.)
053       */
054      public final Collection<? extends Component> found() {
055        return Collections.<Component>unmodifiableCollection(found);
056      }
057    }