Code example for FluentIterable

Methods: transform

0
 * Zones, Geo Services, and Geo region groups come back encoded in REST paths, such as 
 * {@code /REST/Geo/srv-global/} 
 */ 
public final class ExtractLastPathComponent implements Function<FluentIterable<String>, FluentIterable<String>> {
   public FluentIterable<String> apply(FluentIterable<String> in) {
      return in.transform(ExtractNameInPath.INSTANCE);
   } 
 
   static enum ExtractNameInPath implements Function<String, String> {
      INSTANCE;
      public static final Pattern DEFAULT_PATTERN = Pattern.compile("/REST.*/([^/]+)/?$");
 
      public String apply(String in) {
         Matcher matcher = DEFAULT_PATTERN.matcher(in);
         checkState(matcher.find() && matcher.groupCount() == 1, "%s didn't match %s", in, DEFAULT_PATTERN);
         return matcher.group(1);
      } 
   } 
}