Search in sources :

Example 1 with Serializer

use of org.gradle.internal.serialize.Serializer in project gradle by gradle.

the class DefaultMethodArgsSerializer method forTypes.

@Override
public Serializer<Object[]> forTypes(Class<?>[] types) {
    if (types.length == 0) {
        return new EmptyArraySerializer();
    }
    SerializerRegistry selected = null;
    for (SerializerRegistry serializerRegistry : serializerRegistries) {
        if (serializerRegistry.canSerialize(types[0])) {
            selected = serializerRegistry;
            break;
        }
    }
    if (selected == null) {
        return defaultArgsSerializer.forTypes(types);
    }
    final Serializer<Object>[] serializers = new Serializer[types.length];
    for (int i = 0; i < types.length; i++) {
        Class<?> type = types[i];
        serializers[i] = (Serializer<Object>) selected.build(type);
    }
    return new ArraySerializer(serializers);
}
Also used : SerializerRegistry(org.gradle.internal.serialize.SerializerRegistry) Serializer(org.gradle.internal.serialize.Serializer)

Aggregations

Serializer (org.gradle.internal.serialize.Serializer)1 SerializerRegistry (org.gradle.internal.serialize.SerializerRegistry)1