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

com.github.dreamhead.moco.parser.model.RestSingleSetting Maven / Gradle / Ivy

Go to download

Moco is an easy setup stub framework, mainly focusing on testing and integration.

There is a newer version: 1.5.0
Show newest version
package com.github.dreamhead.moco.parser.model;

import com.github.dreamhead.moco.RestIdMatcher;
import com.github.dreamhead.moco.RestSettingBuilder;
import com.google.common.base.Strings;

import static com.github.dreamhead.moco.parser.model.RestIds.asIdMatcher;

public abstract class RestSingleSetting extends RestBaseSetting {
    private String id;

    protected abstract RestSettingBuilder doStartRestSetting();

    protected final boolean hasId() {
        return !Strings.isNullOrEmpty(id);
    }

    protected final RestIdMatcher id() {
        return asIdMatcher(this.id);
    }

    protected boolean isIdRequired() {
        return false;
    }

    @Override
    protected final RestSettingBuilder startRestSetting() {
        if (isIdRequired() && !hasId()) {
            throw new IllegalArgumentException("Required id is missing");
        }

        return doStartRestSetting();
    }

    @Override
    public final String toString() {
        return toStringHelper()
                .add("id", id)
                .toString();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy