1 8 package org.codehaus.loom.components.util.metadata; 9 10 19 public class PartitionTemplate 20 { 21 22 public static final PartitionTemplate[] EMPTY_SET = new PartitionTemplate[ 0 ]; 23 24 28 private final String m_name; 29 30 35 private final String [] m_depends; 36 37 38 private final PartitionTemplate[] m_partitions; 39 40 41 private final ComponentTemplate[] m_components; 42 43 51 public PartitionTemplate( final String name, 52 final String [] depends, 53 final PartitionTemplate[] partitions, 54 final ComponentTemplate[] components ) 55 { 56 if( null == name ) 57 { 58 throw new NullPointerException ( "name" ); 59 } 60 if( null == depends ) 61 { 62 throw new NullPointerException ( "depends" ); 63 } 64 if( null == partitions ) 65 { 66 throw new NullPointerException ( "partitions" ); 67 } 68 if( null == components ) 69 { 70 throw new NullPointerException ( "components" ); 71 } 72 73 m_name = name; 74 m_depends = depends; 75 m_partitions = partitions; 76 m_components = components; 77 } 78 79 84 public String getName() 85 { 86 return m_name; 87 } 88 89 94 public String [] getDepends() 95 { 96 return m_depends; 97 } 98 99 104 public PartitionTemplate[] getPartitions() 105 { 106 return m_partitions; 107 } 108 109 114 public ComponentTemplate[] getComponents() 115 { 116 return m_components; 117 } 118 119 124 public PartitionTemplate getPartition( final String name ) 125 { 126 for( int i = 0; i < m_partitions.length; i++ ) 127 { 128 final PartitionTemplate partition = m_partitions[ i ]; 129 if( partition.getName().equals( name ) ) 130 { 131 return partition; 132 } 133 } 134 135 throw new IllegalArgumentException ( "Missing partition named " + name ); 136 } 137 138 143 public ComponentTemplate getComponent( final String name ) 144 { 145 for( int i = 0; i < m_components.length; i++ ) 146 { 147 final ComponentTemplate component = m_components[ i ]; 148 if( component.getName().equals( name ) ) 149 { 150 return component; 151 } 152 } 153 return null; 154 } 155 } 156 | Popular Tags |