Java 类org.joda.time.base.BaseDuration 实例源码

项目:jfixture    文件:BaseDurationRelay.java   
@Override
public Object create(Object request, SpecimenContext context) {
    if (!(request instanceof SpecimenType)) {
        return new NoSpecimen();
    }

    SpecimenType<?> type = (SpecimenType) request;
    if (!BaseDuration.class.isAssignableFrom(type.getRawType())) {
        return new NoSpecimen();
    }

    // There's only one implementation of BaseDuration so we're safe to do this
    Interval interval = (Interval) context.resolve(Interval.class);
    return interval.toDuration();
}