Newer
Older
sanitizer / src / main / java / com / ljunggren / sanitizer / sanitation / UppercaseSanitation.java
@aljunggren aljunggren on 19 Sep 2020 804 bytes Renamed annotations and classes
package com.ljunggren.sanitizer.sanitation;

import java.lang.annotation.Annotation;

import com.ljunggren.sanitizer.Item;
import com.ljunggren.sanitizer.annotation.Uppercase;
import com.ljunggren.sanitizer.cleanser.Cleanser;
import com.ljunggren.sanitizer.cleanser.UppercaseCleanser;

public class UppercaseSanitation extends SanitationChain {
    
    private Class<?> annotationClass = Uppercase.class;
    private Cleanser<String> cleanser = new UppercaseCleanser();

    @Override
    public void sanitize(Annotation annotation, Item item) {
        if (annotation.annotationType() == annotationClass && item.getValue() instanceof String) {
            item.setValue(cleanser.cleanse(item.getValue().toString()));
            return;
        }
        nextChain.sanitize(annotation, item);
    }

}