ng-tracker/src/main/java/ru/ulstu/odin/model/OdinObjectField.java
2018-05-04 17:08:20 +04:00

27 lines
829 B
Java

package ru.ulstu.odin.model;
import ru.ulstu.core.error.OdinException;
import java.lang.reflect.Field;
import java.lang.reflect.Type;
public class OdinObjectField extends OdinField {
private final String path;
public OdinObjectField(Field field) {
super(field, OdinFieldType.OBJECT);
Type fieldElementClass = field.getType();
try {
OdinDto someInstance = (OdinDto) ((Class) (fieldElementClass)).newInstance();
this.path = someInstance.getControllerPath();
} catch (IllegalAccessException | InstantiationException e) {
throw new OdinException(String.format("Can't create new instance, check default constructor of %s",
fieldElementClass.getTypeName()));
}
}
public String getPath() {
return path;
}
}