1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19 package org.apache.maven.jxr.pacman;
20
21 import java.util.Collection;
22 import java.util.HashMap;
23 import java.util.Map;
24
25 /**
26 * Represents a Java package and its subclasses.
27 */
28 public class PackageType extends BaseType {
29
30 private Map<String, ClassType> classes = new HashMap<>();
31
32 /**
33 * Creates a Java package.
34 *
35 * @param name name of package
36 */
37 public PackageType(String name) {
38 super(name);
39 }
40
41 /**
42 * Creates a Java package with no name IE the default Java package.
43 */
44 public PackageType() {
45 super("");
46 }
47
48 /**
49 * Gets all the known classes
50 *
51 * @return collection of class types
52 */
53 public Collection<ClassType> getClassTypes() {
54 return classes.values();
55 }
56
57 /**
58 * Adds a class to this package.
59 *
60 * @param classType class type to add
61 */
62 public void addClassType(ClassType classType) {
63
64 this.classes.put(classType.getName(), classType);
65 }
66
67 /**
68 * Given the name of a class, get it from this package or null if it does
69 * not exist.
70 *
71 * @param classType class type String
72 * @return class type object
73 */
74 public ClassType getClassType(String classType) {
75
76 return this.classes.get(classType);
77 }
78 }