class BaseDocument implements Document {
    
    private final Document parent; // Nullable
    private final Map<String, Object> config;

    public BaseDocument(Document parent, Map<String, Object> data) {
        this.parent = parent;
        this.config = requireNonNull(data);
    }

    @Override
    public Optional<? extends Document> getParent() {
        return Optional.ofNullable(parent);
    }

    @Override
    public Map<String, Object> getData() {
        return config;
    }

    @Override
    public Optional<Object> get(String key) {
        return Optional.ofNullable(config.get(key));
    }
    
    @Override
    public OptionalBoolean getAsBoolean(String key) {
        return OptionalBoolean.ofNullable((Boolean) config.get(key));
    }

    @Override
    public OptionalLong getAsLong(String key) {<FILL_FUNCTION_BODY>}

    @Override
    public OptionalDouble getAsDouble(String key) {
        final Number value = (Number) config.get(key);
        return value == null 
            ? OptionalDouble.empty() 
            : OptionalDouble.of(value.doubleValue());
    }

    @Override
    public OptionalInt getAsInt(String key) {
        final Number value = (Number) config.get(key);
        return value == null 
            ? OptionalInt.empty() 
            : OptionalInt.of(value.intValue());
    }
    
    @Override
    public Optional<String> getAsString(String key) {
        return get(key).map(String.class::cast);
    }

    @Override
    public void put(String key, Object value) {
        requireNonNull(value);
        config.put(key, value);
    }

    @Override
    public Stream<Document> children() {
        return childrenOf(this, BaseDocument::new);
    }
}

        final Number value = (Number) config.get(key);
        return value == null 
            ? OptionalLong.empty() 
            : OptionalLong.of(value.longValue());
    
<no_super_class>