47 */ 48 SOURCE_OUTPUT, 49 50 /** 51 * Location to search for user class files. 52 */ 53 CLASS_PATH, 54 55 /** 56 * Location to search for existing source files. 57 */ 58 SOURCE_PATH, 59 60 /** 61 * Location to search for annotation processors. 62 */ 63 ANNOTATION_PROCESSOR_PATH, 64 65 /** 66 * Location to search for modules containing annotation processors. 67 * @since 9 68 */ 69 ANNOTATION_PROCESSOR_MODULE_PATH, 70 71 /** 72 * Location to search for platform classes. Sometimes called 73 * the boot class path. 74 */ 75 PLATFORM_CLASS_PATH, 76 77 /** 78 * Location of new native header files. 79 * @since 1.8 80 */ 81 NATIVE_HEADER_OUTPUT, 82 83 /** 84 * Location to search for the source code of modules. 85 * @since 9 86 */ 87 MODULE_SOURCE_PATH, 88 89 /** 90 * Location to search for upgradeable system modules. 91 * @since 9 92 */ 93 UPGRADE_MODULE_PATH, 94 95 /** 96 * Location to search for system modules. 97 * @since 9 98 */ 99 SYSTEM_MODULES, 100 101 /** 102 * Location to search for precompiled user modules. 103 * @since 9 104 */ 105 MODULE_PATH; 106 107 /** 108 * Returns a location object with the given name. The following 109 * property must hold: {@code locationFor(x) == 110 * locationFor(y)} if and only if {@code x.equals(y)}. 111 * The returned location will be an output location if and only if 112 * name ends with {@code "_OUTPUT"}. It will be considered to 113 * be a module-oriented location if the name contains the word 114 * {@code "MODULE"}. 115 * 116 * @param name a name 117 * @return a location 118 */ 119 public static Location locationFor(final String name) { 120 if (locations.isEmpty()) { 121 // can't use valueOf which throws IllegalArgumentException 122 for (Location location : values()) 123 locations.putIfAbsent(location.getName(), location); 124 } 125 name.getClass(); /* null-check */ 126 locations.putIfAbsent(name, new Location() { 127 @Override 128 public String getName() { return name; } 129 @Override 130 public boolean isOutputLocation() { return name.endsWith("_OUTPUT"); } 131 }); 132 return locations.get(name); 133 } 134 //where 135 private static final ConcurrentMap<String,Location> locations 136 = new ConcurrentHashMap<>(); 137 | 47 */ 48 SOURCE_OUTPUT, 49 50 /** 51 * Location to search for user class files. 52 */ 53 CLASS_PATH, 54 55 /** 56 * Location to search for existing source files. 57 */ 58 SOURCE_PATH, 59 60 /** 61 * Location to search for annotation processors. 62 */ 63 ANNOTATION_PROCESSOR_PATH, 64 65 /** 66 * Location to search for modules containing annotation processors. 67 * @spec JPMS 68 * @since 9 69 */ 70 ANNOTATION_PROCESSOR_MODULE_PATH, 71 72 /** 73 * Location to search for platform classes. Sometimes called 74 * the boot class path. 75 */ 76 PLATFORM_CLASS_PATH, 77 78 /** 79 * Location of new native header files. 80 * @since 1.8 81 */ 82 NATIVE_HEADER_OUTPUT, 83 84 /** 85 * Location to search for the source code of modules. 86 * @spec JPMS 87 * @since 9 88 */ 89 MODULE_SOURCE_PATH, 90 91 /** 92 * Location to search for upgradeable system modules. 93 * @spec JPMS 94 * @since 9 95 */ 96 UPGRADE_MODULE_PATH, 97 98 /** 99 * Location to search for system modules. 100 * @spec JPMS 101 * @since 9 102 */ 103 SYSTEM_MODULES, 104 105 /** 106 * Location to search for precompiled user modules. 107 * @spec JPMS 108 * @since 9 109 */ 110 MODULE_PATH; 111 112 /** 113 * Returns a location object with the given name. The following 114 * property must hold: {@code locationFor(x) == 115 * locationFor(y)} if and only if {@code x.equals(y)}. 116 * The returned location will be an output location if and only if 117 * name ends with {@code "_OUTPUT"}. It will be considered to 118 * be a module-oriented location if the name contains the word 119 * {@code "MODULE"}. 120 * 121 * @param name a name 122 * @return a location 123 * 124 * @revised 9 125 * @spec JPMS 126 */ 127 public static Location locationFor(final String name) { 128 if (locations.isEmpty()) { 129 // can't use valueOf which throws IllegalArgumentException 130 for (Location location : values()) 131 locations.putIfAbsent(location.getName(), location); 132 } 133 name.getClass(); /* null-check */ 134 locations.putIfAbsent(name, new Location() { 135 @Override 136 public String getName() { return name; } 137 @Override 138 public boolean isOutputLocation() { return name.endsWith("_OUTPUT"); } 139 }); 140 return locations.get(name); 141 } 142 //where 143 private static final ConcurrentMap<String,Location> locations 144 = new ConcurrentHashMap<>(); 145 |