コード例 #1
0
 /**
  * Find all types that are used as an array member, for generation of a parser for a list of a
  * type. Only applies to types that are wrapped in a common element.
  */
 public static ImmutableSet<String> getArrayMemberTypes(
     final Ds3ApiSpec spec, final ImmutableSet<String> enumTypes) {
   return spec.getTypes()
       .values()
       .stream()
       .flatMap(type -> type.getElements().stream())
       .filter(
           element ->
               element
                   .getType()
                   .equalsIgnoreCase("array")) // only want types that array member types
       .filter(element -> !element.getComponentType().contains("UUID")) // ignore UUID
       .filter(
           element ->
               element
                   .getDs3Annotations()
                   .stream()
                   .flatMap(anno -> anno.getDs3AnnotationElements().stream())
                   .anyMatch(
                       annoElem ->
                           annoElem
                               .getValue()
                               .equals(
                                   "SINGLE_BLOCK_FOR_ALL_ELEMENTS"))) // only want wrapped array
                                                                      // types
       .filter(
           element ->
               !enumTypes.contains(
                   EnumHelper.getDs3Type(element.getComponentType()))) // ignore enums
       .map(element -> StructHelper.getResponseTypeName(element.getComponentType()))
       .collect(GuavaCollectors.immutableSet());
 }