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

com.tomtom.james.common.api.configuration.StructuredConfiguration Maven / Gradle / Ivy

There is a newer version: 2.0.8
Show newest version
/*
 * Copyright 2017 TomTom International B.V.
 *
 * 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.tomtom.james.common.api.configuration;

import java.util.List;
import java.util.Map;
import java.util.Optional;

public interface StructuredConfiguration {

    Optional get(String path);
    Optional get(String... pathSegments);

    List asList();
    Map asMap();

    String asString();
    boolean asBoolean();
    int asInteger();
    long asLong();

    class Empty implements StructuredConfiguration {
        @Override
        public Optional get(String path) {
            return Optional.empty();
        }

        @Override
        public Optional get(String... pathSegments) {
            return Optional.empty();
        }

        @Override
        public String asString() {
            throw new IllegalStateException();
        }

        @Override
        public boolean asBoolean() {
            throw new IllegalStateException();
        }

        @Override
        public int asInteger() {
            throw new IllegalStateException();
        }

        @Override
        public long asLong() {
            throw new IllegalStateException();
        }

        @Override
        public List asList() {
            throw new IllegalStateException();
        }

        @Override
        public Map asMap() {
            throw new IllegalStateException();
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy