001/* 002 * Copyright 2010-2021 The jdependency developers. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.vafer.jdependency; 017 018import java.util.HashSet; 019import java.util.Map; 020import java.util.Set; 021 022public final class ClazzpathUnit { 023 024 private final String id; 025 026 private final Map<String, Clazz> clazzes; 027 private final Map<String, Clazz> dependencies; 028 029 ClazzpathUnit( final String pId, final Map<String, Clazz> pClazzes, final Map<String, Clazz> pDependencies ) { 030 id = pId; 031 clazzes = pClazzes; 032 dependencies = pDependencies; 033 } 034 035 public Set<Clazz> getClazzes() { 036 return new HashSet<>(clazzes.values()); 037 } 038 039 public Clazz getClazz( final String pClazzName ) { 040 return clazzes.get(pClazzName); 041 } 042 043 public Set<Clazz> getDependencies() { 044 return new HashSet<>(dependencies.values()); 045 } 046 047 public Set<Clazz> getTransitiveDependencies() { 048 final Set<Clazz> all = new HashSet<>(); 049 for (Clazz clazz : clazzes.values()) { 050 clazz.findTransitiveDependencies(all); 051 } 052 return all; 053 } 054 055 public String toString() { 056 return id; 057 } 058}