<commit_before>package net.redstoneore.rson;

import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import net.redstoneore.rson.tasks.ARsonTask;
import net.redstoneore.rson.tasks.RsonWatch;
import net.redstoneore.rson.tasks.identifiers.WatchTask;

@SuppressWarnings("unchecked")
public abstract class Rson<T extends Rson<T>> {
		
	// Meta
	private transient Path path;
	private transient Charset charset;
	
	// Tasks
	private transient List<ARsonTask<?>> tasks = new ArrayList<ARsonTask<?>>();
	
	public final T setup(Path path, Charset charset) {
		this.path = path;
		this.charset = charset;
		
		// Ensure Rson tool is setup
		RsonTool.get();
		
		// Look over for annotation tasks
		final List<Method> methods = new ArrayList<Method>(Arrays.asList(this.getClass().getDeclaredMethods())); 
		
		for (final Method method : methods) {			
			if (method.isAnnotationPresent(WatchTask.class)) {
				tasks.add(new RsonWatch(this, this.path.toFile(), method).start()); 
			}
		}
		
		return (T) this;
	}
	
	public final T save() throws Exception {
		byte[] data = RsonTool.get().toJSON(this).getBytes(this.charset);
		<commit_msg>Allow extending to be easier<commit_after>package net.redstoneore.rson;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import net.redstoneore.rson.tasks.ARsonTask;
import net.redstoneore.rson.tasks.RsonWatch;
import net.redstoneore.rson.tasks.identifiers.WatchTask;

@SuppressWarnings("unchecked")
public abstract class Rson<T> {
		
	// Meta
	private transient Path path;
	private transient Charset charset;
	
	// Tasks
	private transient List<ARsonTask<?>> tasks = new ArrayList<ARsonTask<?>>();
	
	public final T setup(Path path, Charset charset) {
		this.path = path;
		this.charset = charset;
		
		// Ensure Rson tool is setup
		RsonTool.get();
		
		// Look over for annotation tasks
		final List<Method> methods = new ArrayList<Method>(Arrays.asList(this.getClass().getDeclaredMethods())); 
		
		for (final Method method : methods) {			
			if (method.isAnnotationPresent(WatchTask.class)) {
				tasks.add(new RsonWatch(this, this.path.toFile(), method).start()); 
			}
		}
		
		return (T) this;
	}
	
	public final T save() throws Exception {
		byte[] data = RsonTool.get().toJSON(this).getBytes(this.charset);
		
{'fraction_non_alphanumeric': 0.12504624491305957, 'fraction_numerical': 0.0, 'mean_word_length': 4.365079365079365, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6065672', 'n_tokens_mistral': 946, 'n_tokens_neox': 860, 'n_words': 202}