All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jtwig.reflection.model.java.JavaConstant Maven / Gradle / Ivy

There is a newer version: 5.87.0.RELEASE
Show newest version
package org.jtwig.reflection.model.java;

import com.google.common.base.Optional;
import org.jtwig.reflection.model.Value;

import java.lang.reflect.Field;

public class JavaConstant {
    private final Field field;

    public JavaConstant(Field field) {
        this.field = field;
        this.field.setAccessible(true);
    }

    public Optional value () {
        try {
            return Optional.of(new Value(field.get(null)));
        } catch (IllegalAccessException e) {
            return Optional.absent();
        }
    }

    public String name () {
        return field.getName();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy