001/* 002 * Copyright 2010-2017 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 final Set<Clazz> result = new HashSet<Clazz>(clazzes.values()); 037 return result; 038 } 039 040 public Clazz getClazz( final String pClazzName ) { 041 final Clazz result = clazzes.get(pClazzName); 042 return result; 043 } 044 045 public Set<Clazz> getDependencies() { 046 final Set<Clazz> result = new HashSet<Clazz>(dependencies.values()); 047 return result; 048 } 049 050 public Set<Clazz> getTransitiveDependencies() { 051 final Set<Clazz> all = new HashSet<Clazz>(); 052 for (Clazz clazz : clazzes.values()) { 053 clazz.findTransitiveDependencies(all); 054 } 055 return all; 056 } 057 058 public String toString() { 059 return id; 060 } 061}