public static <T> AvroSchema<T> of(SchemaDefinition<T> schemaDefinition) {
        if (schemaDefinition.getSchemaReaderOpt().isPresent() && schemaDefinition.getSchemaWriterOpt().isPresent()) {
            return new AvroSchema<>(schemaDefinition.getSchemaReaderOpt().get(),
                    schemaDefinition.getSchemaWriterOpt().get(), parseSchemaInfo(schemaDefinition, SchemaType.AVRO));
        }
        ClassLoader pojoClassLoader = null;
        if (schemaDefinition.getClassLoader() != null) {
            pojoClassLoader = schemaDefinition.getClassLoader();
        } else if (schemaDefinition.getPojo() != null) {
            pojoClassLoader = schemaDefinition.getPojo().getClassLoader();
        }

        return new AvroSchema<>(parseSchemaInfo(schemaDefinition, SchemaType.AVRO), pojoClassLoader);
    }
@Test
    public void testAvroSchemaUserDefinedReadAndWriter() {
        SchemaReader<Foo> reader = new JacksonJsonReader<>(new ObjectMapper(), Foo.class);
        SchemaWriter<Foo> writer = new JacksonJsonWriter<>(new ObjectMapper());
        SchemaDefinition<Foo> schemaDefinition = SchemaDefinition.<Foo>builder()
                .withPojo(Bar.class)
                .withSchemaReader(reader)
                .withSchemaWriter(writer)
                .build();

        AvroSchema<Foo> schema = AvroSchema.of(schemaDefinition);
        Foo foo = new Foo();
        foo.setColor(SchemaTestUtils.Color.RED);
        String field1 = "test";
        foo.setField1(field1);
        schema.encode(foo);
        foo = schema.decode(schema.encode(foo));
        assertEquals(foo.getColor(), SchemaTestUtils.Color.RED);
        assertEquals(field1, foo.getField1());
    }