com.speedment.runtime.config.Document Maven / Gradle / Ivy
Show all versions of generator-deploy Show documentation
/*
*
* Copyright (c) 2006-2019, Speedment, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"); You may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.speedment.runtime.config;
import com.speedment.common.function.OptionalBoolean;
import com.speedment.runtime.config.util.DocumentUtil;
import java.util.*;
import java.util.function.BiFunction;
import java.util.stream.Stream;
/**
* The {@code Document} is the base structure for storing configuration
* parameters and can be seen as a hierarchical key-value store. Parameters can
* be retrieved using the different typed {@code getAsXXX()} methods listed
* here:
*
* - {@link #get(String)}
*
- {@link #getAsBoolean(String)}
*
- {@link #getAsLong(String)}
*
- {@link #getAsDouble(String)}
*
- {@link #getAsInt(String)}
*
- {@link #getAsString(String)}
*
*
* To traverse the document tree, the {@link #children(String, BiFunction)}
* method can be used. It takes a key and a constructor method reference and
* returns a stream of constructed children.
*
* {@code Document} instances are typically short-lived objects that are
* recreated every time they are used. References to other instances than the
* root should therefore not be stored outside the tree.
*
* @author Emil Forsund
* @since 2.3.0
*/
public interface Document {
/**
* Returns the parent of this Document or {@link Optional#empty()} if the
* Document does not have a parent.
*
* @return the parent
*/
Optional getParent();
/**
* Returns the raw data-map used in this {@code Document}.
*
* @return the raw map
*/
Map getData();
/**
* Returns the value mapped to the specified key, or an empty
* {@code Optional} if no value was found.
*
* @param key the key
* @return the mapped value or an empty {@code Optional}
*/
Optional