@VisibleForTesting
  static <E extends Enum<E>> Map<E, LockGraphNode> createNodes(Class<E> clazz) {
    EnumMap<E, LockGraphNode> map = Maps.newEnumMap(clazz);
    E[] keys = clazz.getEnumConstants();
    final int numKeys = keys.length;
    ArrayList<LockGraphNode> nodes = Lists.newArrayListWithCapacity(numKeys);
    // Create a LockGraphNode for each enum value.
    for (E key : keys) {
      LockGraphNode node = new LockGraphNode(getLockName(key));
      nodes.add(node);
      map.put(key, node);
    }
    // Pre-populate all allowedPriorLocks with nodes of smaller ordinal.
    for (int i = 1; i < numKeys; i++) {
      nodes.get(i).checkAcquiredLocks(Policies.THROW, nodes.subList(0, i));
    }
    // Pre-populate all disallowedPriorLocks with nodes of larger ordinal.
    for (int i = 0; i < numKeys - 1; i++) {
      nodes.get(i).checkAcquiredLocks(Policies.DISABLED, nodes.subList(i + 1, numKeys));
    }
    return Collections.unmodifiableMap(map);
  }
@VisibleForTesting
  static <E extends Enum<E>> Map<E, LockGraphNode> createNodes(Class<E> clazz) {
    EnumMap<E, LockGraphNode> map = Maps.newEnumMap(clazz);
    E[] keys = clazz.getEnumConstants();
    final int numKeys = keys.length;
    ArrayList<LockGraphNode> nodes = Lists.newArrayListWithCapacity(numKeys);
    
    for (E key : keys) {
      LockGraphNode node = new LockGraphNode(getLockName(key));
      nodes.add(node);
      map.put(key, node);
    }
    
    for (int i = 1; i < numKeys; i++) {
      nodes.get(i).checkAcquiredLocks(Policies.THROW, nodes.subList(0, i));
    }
    
    for (int i = 0; i < numKeys - 1; i++) {
      nodes.get(i).checkAcquiredLocks(Policies.DISABLED, nodes.subList(i + 1, numKeys));
    }
    return Collections.unmodifiableMap(map);
  }
@ VisibleForTesting static < E extends Enum < E > > Map < E , LockGraphNode > createNodes ( Class < E > clazz ) { EnumMap < E , LockGraphNode > map = Maps . newEnumMap ( clazz ) ; E [ ] keys = clazz . getEnumConstants ( ) ; final int numKeys = keys . length ; ArrayList < LockGraphNode > nodes = Lists . newArrayListWithCapacity ( numKeys ) ; // Create a LockGraphNode for each enum value. for ( E key : keys ) { LockGraphNode node = new LockGraphNode ( getLockName ( key ) ) ; nodes . add ( node ) ; map . put ( key , node ) ; } // Pre-populate all allowedPriorLocks with nodes of smaller ordinal. for ( int i = 1 ; i < numKeys ; i ++ ) { nodes . get ( i ) . checkAcquiredLocks ( Policies . THROW , nodes . subList ( 0 , i ) ) ; } // Pre-populate all disallowedPriorLocks with nodes of larger ordinal. for ( int i = 0 ; i < numKeys - 1 ; i ++ ) { nodes . get ( i ) . checkAcquiredLocks ( Policies . DISABLED , nodes . subList ( i + 1 , numKeys ) ) ; } return Collections . unmodifiableMap ( map ) ; }
For a given Enum type, creates an immutable map from each of the Enum's values to a
corresponding LockGraphNode, with the {@code allowedPriorLocks} and {@code
disallowedPriorLocks} prepopulated with nodes according to the natural ordering of the
associated Enum values.
For a given Enum type creates an immutable map from each of the Enum s values to a corresponding LockGraphNode with the {