Generates a unique signature of a collection of types.
168769
public static String createTypeCollectionId(Collection<? extends Type> types) {
        StringBuilder builder = new StringBuilder();
        List<? extends Type> sortedTypes = new ArrayList<Type>(types);
        Collections.sort(sortedTypes, TypeComparator.INSTANCE);
        builder.append("[");
        for (Iterator<? extends Type> iterator = sortedTypes.iterator(); iterator.hasNext();) {
            builder.append(createTypeId(iterator.next()));
            if (iterator.hasNext()) {
                builder.append(",");
            }
        }
        builder.append("]");
        return builder.toString();
    }
545222
public static <T> List<T> getUnique(Collection<T> collection) {
        HashSet<T> set = new HashSet<>();
        List<T> out = new ArrayList<>();
        for (T t : collection) {
            if (!set.contains(t)) {
                out.add(t);
                set.add(t);
            }
        }
        return out;
    }
782947
public static ServiceSpecification generate(
            Iterable<ServiceInfo> services,
            Function<TypeSignature, ? extends NamedTypeInfo> namedTypeInfoFactory) {
        if (Iterables.isEmpty(services)) {
            return emptyServiceSpecification;
        }

        // Collect all named types referred by the services.
        final Set<TypeSignature> namedTypes =
                Streams.stream(services)
                       .flatMap(s -> s.findNamedTypes().stream())
                       .collect(toImmutableSortedSet(comparing(TypeSignature::name)));

        final Map<String, EnumInfo> enums = new HashMap<>();
        final Map<String, StructInfo> structs = new HashMap<>();
        final Map<String, ExceptionInfo> exceptions = new HashMap<>();

        generateNamedTypeInfos(namedTypeInfoFactory, enums, structs, exceptions, namedTypes);

        return new ServiceSpecification(services, enums.values(), structs.values(), exceptions.values());
    }
296568
def generate_value_processor(type_, collectionFormat=None, items=None, **kwargs):
    
    processors = []
    if is_non_string_iterable(type_):
        assert False, "This should not be possible"
    else:
        if type_ == ARRAY and collectionFormat:
            if collectionFormat in DELIMETERS:
                delimeter = DELIMETERS[collectionFormat]
                # split the string based on the delimeter specified by the
                # `collectionFormat`
                processors.append(operator.methodcaller('split', delimeter))
            else:
                if collectionFormat != MULTI:
                    raise TypeError("collectionFormat not implemented")
                processors.append(add_string_into_list)
            # remove any Falsy values like empty strings.
            processors.append(functools.partial(filter, bool))
            # strip off any whitespace
            processors.append(functools.partial(map, operator.methodcaller('strip')))
            if items is not None:
                if isinstance(items, collections.Mapping):
                    items_processors = itertools.repeat(
                        generate_value_processor(**items)
                    )
                elif isinstance(items, collections.Sequence):
                    items_processors = itertools.chain(
                        (generate_value_processor(**item) for item in items),
                        itertools.repeat(lambda v: v),
                    )
                elif isinstance(items, six.string_types):
                    raise NotImplementedError("Not implemented")
                else:
                    assert False, "Should not be possible"
                # 1. zip the processor and the array items together
                # 2. apply the processor to each array item.
                # 3. cast the starmap generator to a list.
                processors.append(
                    chain_reduce_partial(
                        functools.partial(zip, items_processors),
                        functools.partial(itertools.starmap, lambda fn, v: fn(v)),
                        list,
                    )
                )
        else:
            processors.append(
                functools.partial(cast_value_to_type, type_=type_)
            )

    def processor(value, **kwargs):
        try:
            return chain_reduce_partial(*processors)(value)
        except (ValueError, TypeError):
            return value

    return processor
680336
function generateTypeIdentifier(identifier) {
    var o = type.parse (identifier);
    return (
      (o.namespace || 'concurrify') + '/Concurrent' + o.name + '@' + o.version
    );
  }
729585
public static <T> ArrayList<T> distinct(Collection<T> collection) {
		if (isEmpty(collection)) {
			return new ArrayList<>();
		} else if (collection instanceof Set) {
			return new ArrayList<>(collection);
		} else {
			return new ArrayList<>(new LinkedHashSet<>(collection));
		}
	}
429135
def signature(cls):
    
    snake_scope = cls.options_scope.replace('-', '_')
    partial_construct_optionable = functools.partial(_construct_optionable, cls)
    partial_construct_optionable.__name__ = 'construct_scope_{}'.format(snake_scope)
    return dict(
        output_type=cls.optionable_cls,
        input_selectors=tuple(),
        func=partial_construct_optionable,
        input_gets=(Get.create_statically_for_rule_graph(ScopedOptions, Scope),),
        dependency_optionables=(cls.optionable_cls,),
      )
778899
def signature(self):
        """"""
        mods = ", ".join(self.modifiers)
        return "{} SUBROUTINE {}({})".format(mods, self.name,
                                             self.parameters_as_string())
1028143
def generate_signature(method, version, endpoint,
                       date, rel_url, content_type, content,
                       access_key, secret_key, hash_type):
    '''
    
    '''
    hash_type = hash_type
    hostname = endpoint._val.netloc  # FIXME: migrate to public API
    if version >= 'v4.20181215':
        content = b''
    else:
        if content_type.startswith('multipart/'):
            content = b''
    body_hash = hashlib.new(hash_type, content).hexdigest()

    sign_str = '{}\n{}\n{}\nhost:{}\ncontent-type:{}\nx-backendai-version:{}\n{}'.format(  # noqa
        method.upper(),
        rel_url,
        date.isoformat(),
        hostname,
        content_type.lower(),
        version,
        body_hash
    )
    sign_bytes = sign_str.encode()

    sign_key = hmac.new(secret_key.encode(),
                        date.strftime('%Y%m%d').encode(), hash_type).digest()
    sign_key = hmac.new(sign_key, hostname.encode(), hash_type).digest()

    signature = hmac.new(sign_key, sign_bytes, hash_type).hexdigest()
    headers = {
        'Authorization': 'BackendAI signMethod=HMAC-{}, credential={}:{}'.format(
            hash_type.upper(),
            access_key,
            signature
        ),
    }
    return headers, signature
344226
public String[] generateTypeMismatchCodes(final String objectName, final String field, final Class<?> filedType) {
        return generateCodes(getTypeMismatchCode(), objectName, field, filedType);
    }
1141717
function generateTypeDefs(models) {

    types = Object.assign({}, types, getCustomTypeDefs());

    _.forEach(models, (model) => {
        mapType(model);
        mapInputType(model);
    });

    return types;
}
522164
public static void generateImmutableCollectionIfPossible(ModelClass<?> entity, Builder methodBuilder, String name,
			TypeName typeName) {
		if (TypeUtility.isList(typeName)
				&& ((ParameterizedTypeName) typeName).rawType.equals(ClassName.get(List.class))) {
			methodBuilder.addCode("($L==null ? null : $T.unmodifiableList($L))", name, Collections.class, name);
		} else if (TypeUtility.isSet(typeName)
				&& ((ParameterizedTypeName) typeName).rawType.equals(ClassName.get(SortedSet.class))) {
			methodBuilder.addCode("($L==null ? null : $T.unmodifiableSortedSet($L))", name, Collections.class, name);
		} else if (TypeUtility.isSet(typeName)
				&& ((ParameterizedTypeName) typeName).rawType.equals(ClassName.get(Set.class))) {
			methodBuilder.addCode("($L==null ? null : $T.unmodifiableSet($L))", name, Collections.class, name);
		} else if (TypeUtility.isMap(typeName)
				&& ((ParameterizedTypeName) typeName).rawType.equals(ClassName.get(SortedMap.class))) {
			methodBuilder.addCode("($L==null ? null : $T.unmodifiableSortedMap($L))", name, Collections.class, name);
		} else if (TypeUtility.isMap(typeName)
				&& ((ParameterizedTypeName) typeName).rawType.equals(ClassName.get(Map.class))) {
			methodBuilder.addCode("($L==null ? null : $T.unmodifiableMap($L))", name, Collections.class, name);
		} else {
			methodBuilder.addCode(name);
		}
	}
835500
public Signature appendArgs(String[] names, Class<?>... types) {
        assert names.length == types.length : "names and types must be of the same length";

        String[] newArgNames = new String[argNames.length + names.length];
        System.arraycopy(argNames, 0, newArgNames, 0, argNames.length);
        System.arraycopy(names, 0, newArgNames, argNames.length, names.length);
        MethodType newMethodType = methodType.appendParameterTypes(types);
        return new Signature(newMethodType, newArgNames);
    }
1252809
private void genFormalTypeParameter(TypeParameterElement typeParam, StringBuilder sb) {
    sb.append(ElementUtil.getName(typeParam));
    List<? extends TypeMirror> bounds = typeParam.getBounds();
    if (bounds.isEmpty()) {
      sb.append(':').append(JAVA_OBJECT_SIGNATURE);
    } else {
      if (TypeUtil.isInterface(bounds.get(0))) {
        sb.append(':');
      }
      for (TypeMirror bound : bounds) {
        sb.append(':');
        genTypeSignature(bound, sb);
      }
    }
  }
1238970
def _generate_struct_cstor_signature(self, struct):
        """"""
        fields = struct.all_fields
        self.emit(comment_prefix)
        description_str = 'Full constructor for the struct (exposes all instance variables).'
        self.emit_wrapped_text(description_str, prefix=comment_prefix)
        signature = fmt_signature(
            func=self._cstor_name_from_fields(fields),
            args=self._cstor_args_from_fields(fields, is_struct=True),
            return_type='instancetype')
        self.emit(comment_prefix)
        for field in struct.all_fields:
            doc = self.process_doc(field.doc,
                                   self._docf) if field.doc else undocumented
            self.emit_wrapped_text(
                '@param {} {}'.format(fmt_var(field.name), doc),
                prefix=comment_prefix)
        if struct.all_fields:
            self.emit(comment_prefix)
        self.emit_wrapped_text(
            '@return An initialized instance.', prefix=comment_prefix)
        self.emit(comment_prefix)
        self.emit('{};'.format(signature))

        self.emit()
41567
function() {
    if (arguments.length === 1) {
      var signatures = arguments[0];
      if (lib.type.isObject(signatures)) {
        var keys = Object.keys(signatures).sort();
        var length = keys.length;
        for (var i = length; i > 0; i--) {
          this.addSignature(keys[i-1],signatures[keys[i-1]]);
        }
      } else if (lib.type.isFunction(signatures)) {
        this.addSignature("_",signatures);
      }
    } else if (arguments.length === 2) {
      var signature = arguments[0];
      var func = arguments[1];
      if (signature === "_") {
        this.tree._ = this.addFunction(func);
      } else if (regExp.number.test(signature)) {
        (this.tree[signature] || (this.tree[signature] = {}))._ = this.addFunction(func);
      } else if (regExp.letter.test(signature)) {
        var length = signature.length;
        var tree = this.tree[length] || (this.tree[length] = {});
        for (var i = 0; i < length; i++) {
          tree = tree[signature[i]] || (tree[signature[i]] = {});
        }
        tree._ = this.addFunction(func,parseArgs(signature));
      }
    }
  }
251887
public static void generateFieldPersistance(BindTypeContext context, List<? extends ManagedModelProperty> collection, PersistType persistType, boolean forceName, Modifier... modifiers) {

		for (ManagedModelProperty property : collection) {
			if (property.bindProperty != null && !property.hasTypeAdapter()) {
				// if defined a forced typeName, we use it to define every json
				// mapping, to allow comparison with parameters
				if (forceName)
					property.bindProperty.label = DEFAULT_FIELD_NAME;

				BindTransformer.checkIfIsInUnsupportedPackage(property.bindProperty.getPropertyType().getTypeName());
				
				generateFieldSerialize(context, persistType, property.bindProperty, modifiers);
				generateFieldParser(context, persistType, property.bindProperty, modifiers);
			}
		}

	}