3

Вопрос по new-operator, java – SimpleXML перечисление чувствительность к регистру

Error: User Rate Limit ExceededError: User Rate Limit Exceeded [http://simple.sourceforge.net/home.php] Error: User Rate Limit Exceeded package pojos; public enum MyEnum { NEW("new"), OLD("old"); private final String value; MyEnum(String v) { ...

3 ответа

12

Error: User Rate Limit ExceededTransformError: User Rate Limit ExceededEnumTransformError: User Rate Limit ExceededTransformError: User Rate Limit ExceededtoString()Error: User Rate Limit Exceededname()Error: User Rate Limit Exceeded

class MyEnumTransform implements Transform<Enum> {
    private final Class type;

    public MyEnumTransform(Class type) {
        this.type = type;
    }

    public Enum read(String value) throws Exception {
        for (Object o : type.getEnumConstants()) {
            if (o.toString().equals(value)) {
                return (Enum) o;
            }
        }
        return null;
    }

    public String write(Enum value) throws Exception {
        return value.toString();
    }
}

TransformError: User Rate Limit ExceededmatchError: User Rate Limit ExceededMatcherError: User Rate Limit ExceededMatcherError: User Rate Limit ExceededTransformerError: User Rate Limit ExceededMatcherError: User Rate Limit ExceededPersisterError: User Rate Limit Exceeded

Persister serializer = new Persister(new Matcher() {
    public Transform match(Class type) throws Exception {
        if (type.isEnum()) {
            return new MyEnumTransform(type);
        }
        return null;
    }
 });

Error: User Rate Limit Exceeded

1

Error: User Rate Limit ExceededtoString()

@Override 
public String toString() {
       return this.value.toLowerCase();
}

Error: User Rate Limit Exceeded

serializer.write(example.toString(), result);
0

Error: User Rate Limit ExceededError: User Rate Limit ExceededError: User Rate Limit Exceeded

Похожие вопросы