/** * Returns a new ModelCodec. * * @param <ModelType> a model type * @param modelClass a model class * @return a new ModelCodec */ public static <ModelType> ModelCodec<ModelType> to(Class<ModelType> modelClass) { ModelCodec<ModelType> result = new ModelCodec(); result.entityClass = modelClass; return result; }
/** * Returns a new ModelCodec. * * @param <ModelType> a model type * @param model a model instance to serialize * @return a new ModelCodec */ public static <ModelType> ModelCodec<ModelType> from(ModelType model) { ModelCodec<ModelType> result = new ModelCodec(); result.entity = model; result.entityClass = (Class<ModelType>) model.getClass(); return result; }